Hello,

To be up front, I am currently a student taking a class that uses
ANTLR as a teaching tool.  Unfortunately the professor provides no
guidance on ANTLR, and has recommended that we read the available
tutorials. I was hoping some of the forum members might be able to
shed some light on an issue, and provide an external reference.

This post is a 2-parter:
1) If possibly I'd like to understand why a piece of code does not
work. The code is provided below.

2)  On a more general note I'm hoping someone can point me to an
article that lists the applicable rules and limitations for Parser,
lexer, and token usage so as to avoid future difficulties. For
example, I have discovered through much hair pulling and a post on
this forum that the '!' character cannot be used in Lexer rules.  It
is this kind of information that I am hoping to find in a concise
summary.  Something similar to Java and .net's introduction to data-
types and usage (mutability, casting, constraints, etc) would be
fantastic.  Not that these concepts map, but a similar exploration of
the syntactic application of parsers, lexers and tokens would be
greatly appreciated.  Given that the debug info can be hard to
interpret at times, such a document would be a fantastic way to ensure
that more time is spent exploring the language than fighting to get
the simplest piece of code to work.

I guess I've rambled on enough.
Re my first issue.  Can someone please explain why the following does
not work:

-------------------------------------------------------------
tokens {
    PLUS        =  '+';
    MINUS       =  '-';
    MULT        =  '*';
    DIV         =  '/';
    LPAREN      =  '(';
    RPAREN      =  ')';
}

expr    : Op LPAREN RPAREN;

Op      :       PLUS | MINUS | MULT | DIV;
-------------------------------------------------------------

The error reported is "The following token definitions can never be
matched because prior tokens match the same input: Op"

I do not understand why this is the case.  As I (incorrectly) see it,
the tokens are hard coded values, to which the lexer rule would match
the appropriate input strings.  Can someone please straighten me out?
I'm not sure from a high level where I'm going wrong, and what the
appropriate implementation would be.

Help is very much appreciated on both issues.
Thank you in advance!

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to