aboutsummaryrefslogtreecommitdiff
path: root/examples/calc.lisp
diff options
context:
space:
mode:
authorcolin <colin@cicadas.surf>2023-07-29 08:42:30 -0700
committercolin <colin@cicadas.surf>2023-07-29 08:42:30 -0700
commitfe89d62417be96f0c8d2b864423bc891f149e54f (patch)
treea20f8560d5f7d5c233bef8a7080a851969e790b7 /examples/calc.lisp
parent803f04aee3860545b0743808fb53f05d2a42bc37 (diff)
recursive parse in calc example
Diffstat (limited to 'examples/calc.lisp')
-rw-r--r--examples/calc.lisp6
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>))))