[antlr-interest] More ANTLR meta-syntax questions

Brian Smith brian-l-smith at uiowa.edu
Tue May 14 13:23:25 PDT 2002


Thanks for your reply (and thanks to everybody else as well). I have 
responded inline below.

Another question I forgot to ask is: would it be possible to combine the 
ANTLR syntax for characters and strings, so that the single-quote (') 
and the double-quote (") become synonyms for each other? I have seen 
that some other parser-generating tools do not seem to distingush 
between strings and characters syntactically. This would allow me to 
write "'" instead of '\'' and '""' instead of "\"\"". Also, I think this 
kind of change would be backwards-compatibile.

Also, I would like to contribute an appropriate JAR manifest for 
antlr.jar but I don't see any place where I can send it. Can I just send 
it to the list as an attachment? I would like in particular to add the 
versioning information to the manifest so that a better answer to the 
"how can I tell what version of antlr.jar I have" FAQ.

Terence Parr wrote:

>Take a look at my "building a translator by hand" PDF draft chapter of 
>my book at the antlr.org site.   Look for "The Limitations of Combined 
>Syntactic and Lexical Recognizers". It explains that you need a queue of 
>tokens between lexer and parser (at least with k>1 top-down approach...I 
>suspect that LR-based systems can do without it much of the time).  The 
>difference is doing either:
Thanks, I will read the chapter. As Loring pointed out, when I add 
actions, tree annotations, etc., I will likely see that there is not 
much similarity between lexer and parser rules anymore. But, I still 
don't see why it is necessary to use character case to distinguish 
between lexer rules and parser rules.

 >> sufficient? If not, is it (theoretically) possible for ANTLR to 
compute the minimum value
 >> of k needed for my grammar to be unambiguous?
 > Yes. this is automatic. Slick, eh?

Yes, that is cool.

 > LR reduces to LL(k) if I put actions in the "right" spot. ;)
 > Nice little proof of this.

Could you point me to the proof? Also, if you have "functional" actions, 
are LL(k) and LR(k) then equivalent? Also, with functional actions, is 
your "approximate" LL(k) equivalent to full LL(k)?

 > Anyway, adding syntactic predicates to any parser technology takes you
 > beyond full LR(k) in strength as it is essentially backtracking.


>I got really pissed off the other day when i was updating the Java 
>grammar--I wanted full LL(k) rather than my approx decisions...almost 
>made me take a week off to go implement it! ;)
Would you mind posting this example? I'm really curious to see a 
"real-world" case where you would want full LL(k) instead of the linear 



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

More information about the antlr-interest mailing list