You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
792 B
Plaintext
26 lines
792 B
Plaintext
15 years ago
|
start : _ additive { return $2; }
|
||
15 years ago
|
|
||
15 years ago
|
additive : multiplicative plus additive { return $1 + $3; }
|
||
|
/ multiplicative minus additive { return $1 - $3; }
|
||
15 years ago
|
/ multiplicative
|
||
|
|
||
15 years ago
|
multiplicative : primary times multiplicative { return $1 * $3; }
|
||
|
/ primary divide multiplicative { return $1 / $3; }
|
||
15 years ago
|
/ primary
|
||
|
|
||
|
primary : integer
|
||
15 years ago
|
/ lparen additive rparen { return $2 }
|
||
15 years ago
|
|
||
|
integer "integer"
|
||
|
: [0-9]+ _ { return parseInt($1.join("")); }
|
||
|
|
||
|
plus : "+" _ { return $1; }
|
||
|
minus : "-" _ { return $1; }
|
||
|
times : "*" _ { return $1; }
|
||
|
divide : "/" _ { return $1; }
|
||
|
lparen : "(" _
|
||
|
rparen : ")" _
|
||
|
|
||
|
_ "whitespace"
|
||
|
: [ \t\n\r]*
|