Hi Hugh Sasse and thank you for you message :)
Well... I had write on my file .g this, how you told to me:
// PARSER
class RubyParser extends Parser;
options { buildAST=true; }
program : compstmt;
compstmt : stmt;
stmt : stmt IF expr
| stmt WHILE expr
| stmt UNLESS expr
| ;
expr : ;
// LEXER
class RubyLexer extends Lexer;
IF : "if";
WHILE : "while";
UNLESS : "unless";
UNTIL : "until";
but there is left recursione now! What do you think about? You can see
that there is left recursion!
The output is:
C:\Personal\Universit߽Materiale Esami\Teconologie dei Linguaggi di
Programmazio
ne + Lab>antlr provaLexerParser.g
java -classpath "C:\antlr\275\lib\antlr.jar;" antlr.Tool
provaLexerParser.g
ANTLR Parser Generator Version 2.7.5 (20050128) 1989-2005 jGuru.com
provaLexerParser.g:8:17: infinite recursion to rule stmt from rule stmt
provaLexerParser.g:9:17: infinite recursion to rule stmt from rule stmt
provaLexerParser.g:10:17: infinite recursion to rule stmt from rule
stmt
provaLexerParser.g:8:17: infinite recursion to rule stmt from rule stmt
provaLexerParser.g:9:17: infinite recursion to rule stmt from rule stmt
provaLexerParser.g:10:17: infinite recursion to rule stmt from rule
stmt
provaLexerParser.g:8: warning:nondeterminism between alts 1 and 4 of
block upon
provaLexerParser.g:8: k==1:IF
provaLexerParser.g:8: warning:nondeterminism between alts 2 and 4 of
block upon
provaLexerParser.g:8: k==1:WHILE
provaLexerParser.g:8: warning:nondeterminism between alts 3 and 4 of
block upon
provaLexerParser.g:8: k==1:UNLESS
Exiting due to errors.
I think the problem finish when I know how I can write on ANTLR the
empty string. I try to rappresent this with " ", when I write "| ;". I
hope you undestand what I would tell to you.
Thank you so much for your message
bye,
puellula