Adding functions to bison/jison calculator language
问题 I'm trying to expand the Jison calculator example with some simple functions. I'm rather new to parsing and bison/jison, but this is a bit of what I have so far: /* lexical grammar */ %lex %{ var funcs = { pow: function(a, b) { return Math.pow(a, b); }, test: function(a) { return a*2; } } %} %% \s+ /* skip whitespace */ [0-9]+("."[0-9]+)?\b return 'NUMBER' [a-zA-Z]+ return 'NAME' "," return ',' "*" return '*' "(" return '(' ")" return ')' <<EOF>> return 'EOF' . return 'INVALID' /lex %start