[antlr-interest] lexical nondeterminism between IDENT & LABEL
thoth2487
thoth2487 at libero.it
Wed Nov 3 04:57:56 PST 2004
Hi to all, I've a very simple language in which there are IDENTifiers
and jump LABELs. An IDENTifier start with ('a'...'z')|('A'..'Z') and
continue with ('a'...'z')|('A'..'Z')|('0'..'9') and a LABEL is like an
IDENTifier but ends with a ':'. When I try following .g I obtain
always a lexical nondeterminsim which I isn't to solve:
//
// QCL parser
//
class QCLParser extends Parser;
task_unit
: ( EOL { System.out.println("<EOL>"); }
| n:SL_COMMENT { System.out.println("<SL_COMMENT = '" + n.getText()
+ "'"); }
| m:IDENT { System.out.println("<IDENT = '" + m.getText() + "'"); }
| o:LABEL { System.out.println("<LABEL = '" + o.getText() + "'"); }
)*
EOF!
;
//
// QCL lexer
//
class QCLLexer extends Lexer;
options {
k = 2; // characters of lookahead
caseSensitive = true; // enable case sensitive mode
charVocabulary = '\0'..'\377'; // ANSI range 0..255
}
// whitespace
WS
: ( ' '
| '\t'
| '\f'
)
{ $setType(Token.SKIP); }
;
// end of line
EOL
: ( "\r\n" // DOS & Windows file format
| '\r' // Macintosh file format [6.0.1]
| '\n' // Unix file format [6.0.1]
)
{ newline(); }
;
// single line comment
SL_COMMENT
: ';'
(~( '\r' | '\n' ))*
;
// identifier
IDENT
: ('a'..'z' | 'A'..'Z')
('a'..'z' | 'A'..'Z' | '0'..'9')*
;
// label
LABEL
: ('a'..'z' | 'A'..'Z')
('a'..'z' | 'A'..'Z' | '0'..'9')*
':'
;
Example:
MAIN is an IDENT
MAIN: is a LABEL
Can you help me ?
Thank you very much
Silverio Diquigiovanni
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