Last active
December 25, 2015 16:59
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grammar MathExpression; | |
INT : [0-9]+; | |
DOUBLE : [0-9]+'.'[0-9]+; | |
PI : 'pi'; | |
E : 'e'; | |
POW : '^'; | |
WS : [ \t\r\n]+ -> skip; | |
ID : [a-zA-Z_][a-zA-Z_0-9]*; | |
PLUS : '+'; | |
MINUS : '-'; | |
MULT : '*'; | |
DIV : '/'; | |
LPAR : '('; | |
RPAR : ')'; | |
input | |
: expr EOF | |
; | |
expr | |
: term ((PLUS | MINUS) term)* | |
; | |
term | |
: factor ((MULT | DIV) factor)* | |
; | |
factor | |
: pow (POW factor)? | |
; | |
pow | |
: MINUS pow | |
| atom | |
; | |
atom | |
: PI | |
| E | |
| DOUBLE | |
| INT | |
| LPAR expr RPAR | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment