[antlr-interest] New to antlr pls help
solmalik
boy_wonder48 at hotmail.com
Wed May 14 09:59:53 PDT 2003
Hi there I am trying to write a formal grammar using antlr but am
having some problems in getting the right syntax. The grammr is to
be used in order to parse process expression, some examples of the
expressions are:
(a || b) ^ (a || c)
or
(a;b)
or e sy b sy a
I have tried to capture the three different above forms in the
grammar but am having trouble getting it right, is there anyone who
has an idea on how to do it? Below is the code i have so far:
class P extends Parser;
startRule
: e:EQUATION
{System.out.println("The eqn entered is, "+e.getText());}
;
class L extends Lexer;
EQUATION: OPEN (MINEQN)+ CLOSE
;
OPEN: '(' ;
CLOSE: ')' ;
MINEQN : OPEN LETTER KEYWORD LETTER CLOSE (KEYWORD)?
| OPEN LETTER KEYWORD LETTER CLOSE (KEYWORD LETTER)?
| LETTER KEYWORD LETTER
;
KEYWORD : ';'
| '||'
| 'sy'
| 'rs'
| '^'
| '*'
;
LETTER : ('a' .. 'z' | 'A' .. 'Z');
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list