diff options
author | colin <colin@cicadas.surf> | 2023-07-29 08:42:30 -0700 |
---|---|---|
committer | colin <colin@cicadas.surf> | 2023-07-29 08:42:30 -0700 |
commit | fe89d62417be96f0c8d2b864423bc891f149e54f (patch) | |
tree | a20f8560d5f7d5c233bef8a7080a851969e790b7 /examples | |
parent | 803f04aee3860545b0743808fb53f05d2a42bc37 (diff) |
recursive parse in calc example
Diffstat (limited to 'examples')
-rw-r--r-- | examples/calc.lisp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/examples/calc.lisp b/examples/calc.lisp index 14b03e5..87993e8 100644 --- a/examples/calc.lisp +++ b/examples/calc.lisp @@ -7,11 +7,15 @@ (deflanguage calc (:documentation "A calculator language") (<calc> :-> (:or + (:seq <subexpr> (:eof)) (:seq <value> (:eof)) (:seq <unop> (:eof)) (:seq <binop> (:eof))) :=> car) - (<expr> :-> (:or <value> <unop> <binop>)) + (<expr> :-> (:or <subexpr> <value> <unop> <binop>)) + (<subexpr> :-> (:item) + :?? listp + :=> (argot:parse calc <subexpr> )) (<value> :-> (:item) :?? numberp) (<binop> :-> (:seq (:@ lhs <expr>) (:@ rhs (:+ (:seq (:or= + - / * ^ %) <expr>)))) |