Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- grammar oskarLab1;
- plik : (expr {System.out.println ("Result: " + $expr.text )}
- ;
- expr returns [integer wy]
- : term ((PLUS term | MINUS term))* NL;
- term : atom (MUL atom| DIV atom)*;
- atom : INT | (LP expr RP);
- ID : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')*
- ;
- INT : '0'..'9'+
- ;
- COMMENT
- : '//' ~('\n'|'\r')* '\r'? '\n' {$channel=HIDDEN;}
- | '/*' ( options {greedy=false;} : . )* '*/' {$channel=HIDDEN;}
- ;
- WS : ( ' '
- | '\t'
- | '\r'
- ) {$channel=HIDDEN;}
- ;
- LP :'(';
- RP :')';
- PLUS : '+';
- MINUS: '-' ;
- MUL : '*' ;
- DIV : '/' ;
- NL : '\n' ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement