Created
September 12, 2012 13:58
-
-
Save stephpy/3706786 to your computer and use it in GitHub Desktop.
This file contains 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
%skip space \s | |
%token bracket_ \( | |
%token _bracket \) | |
%token comma , | |
%token number (0|[1-9]\d*)(\.\d+)?([eE][\+\-]?\d+)? | |
%token plus \+ | |
%token minus \-|− | |
%token pow \*\* | |
%token times \*|× | |
%token percent % | |
%token div /|÷ | |
%token ID [A-Z_0-9]+ | |
%token id [a-z_0-9]+ | |
expression: | |
primary() | |
( ( ::plus:: #addition | ::minus:: #substraction ) expression() )? | |
primary: | |
term() | |
( ( | |
::times:: #multiplication | | |
::div:: #division | | |
::pow:: #pow | | |
::percent:: #modulo | |
) | |
expression() )? | |
term: | |
( ::bracket_:: expression() ::_bracket::) | |
| number() | |
| function() | |
| constant() #constant | |
| ( ::minus:: #negative | ::plus:: ) term() | |
number: | |
<number> | |
constant: | |
<ID> | |
#function: | |
<id> ::bracket_:: | |
( expression() ( ::comma:: expression() )* )? | |
::_bracket:: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment