mirror of
https://github.com/jashkenas/coffeescript.git
synced 2022-11-09 12:23:24 -05:00
26 lines
645 B
JSON
26 lines
645 B
JSON
{
|
|
"comment": "Grammar showing precedence operators and semantic actions.",
|
|
|
|
"lex": {
|
|
"rules": [
|
|
["\\s+", "/* skip whitespace */"],
|
|
["[0-9]+", "return 'NAT';"],
|
|
["\\+", "return '+';"],
|
|
["\\*", "return '*';"],
|
|
["$", "return 'EOF';"]
|
|
]
|
|
},
|
|
|
|
"tokens": "NAT + * EOF",
|
|
"operators": [
|
|
["left", "+"],
|
|
["left", "*"]
|
|
],
|
|
"bnf": {
|
|
"S" :[[ "e EOF", "return $1;" ]],
|
|
"e" :[[ "e + e", "$$ = [$1,'+', $3];" ],
|
|
[ "e * e", "$$ = [$1, '*', $3];" ],
|
|
[ "NAT", "$$ = parseInt(yytext);" ]]
|
|
}
|
|
}
|
|
|