[antlr-interest] Nondeterminism on Keywords with multiple meanings

Martin Probst mail at martin-probst.com
Thu Nov 18 12:01:13 PST 2004


Hi,
for some time I thought I had actually managed to come over XQuery's
keyword ambiguities but after the last "Grammar update" I'm boned again.

In XQuery every keyword may also be used to identify an XML tag. My
specific problem is with declarations - from the grammar:

Setter ::= XMLSpaceDecl | DefaultCollationDecl 
	   | BaseURIDecl | ConstructionDecl | OrderingModeDecl 
	   | EmptyOrderingDecl | InheritNamespacesDecl

And all these setters start with a "declare". Without switching to LA(2)
the XQuery team "solves" this problem by defining 25 different lexical
states with ~10 different transitions in each state. I wanted to avoid
this by using syntatic predicates like this:

( ( "declare" "xmlspace" ) => xmlSpaceDecl
| ( "declare" "default" ) => defaultDecl 
| ( "declare" "base-uri" ) => baseURIDecl 
| ( "declare" "construction" ) => constructionDecl 
| ( "declare" "ordering" ) => orderingModeDecl 
| ( "import" "schema" ) => schemaImport 
| ( "import" "module" ) => moduleImport 
| ( "declare" "namespace" ) => namespaceDecl 
| ( "declare" "variable" ) => varDecl 
| ( "declare" "function" ) => functionDecl ) SEPARATOR )*

Which somewhat works, though there is an ambiguity between
end-of-the-block on "declare" and "import".
So a statement like:
> declare base-uri "foo";
> declare
- which is valid XQuery - will fail.

Now my question is: can anyone see an easy (and not too slow) way out of
this situation? I'm using C++ btw.

mfg
Martin



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





More information about the antlr-interest mailing list