'Build Your Own Lisp' Solutions: 6.4

Q: Change the grammar to add a new operator such as '%'.


A:

"                                                   \
number   : /-?[0-9]+/ ;                             \
operator : '+' | '-' | '*' | '/' | '%';             \
expr     : <number> | '(' <operator> <expr>+ ')' ;  \
lispy    : /^/ <operator> <expr>+ /$/ ;             \
"