@ -12,8 +12,12 @@
[(_ VAL) #'VAL]
[(_ LEFT "*" RIGHT) #'(* LEFT RIGHT)]
[(_ LEFT "/" RIGHT) #'(/ LEFT RIGHT 1.0)]
[(_ LEFT "^" RIGHT) #'(expt LEFT RIGHT)]
[(_ LEFT "%" RIGHT) #'(modulo LEFT RIGHT)])
[(_ LEFT "mod" RIGHT) #'(modulo LEFT RIGHT)])
;; b-expt : [b-expt "^"] b-value
(define-macro-cases b-expt
[(_ LEFT "^" RIGHT) #'(expt LEFT RIGHT)])
(define (b-expr expr)
(if (integer? expr) (inexact->exact expr) expr))
@ -3,7 +3,7 @@
(define-lex-abbrev digits (:+ (char-set "0123456789")))
(define-lex-abbrev reserved-terms (:or "print" "goto" "end" "+" ":" "let" "=" "gosub" "return" "-" "for" "to" "step" "next" "if" "then" "else" "and" "or" "<" ">" "*" "/" "(" ")" "^" "!" "%" "input" ";" "def"))
(define-lex-abbrev reserved-terms (:or "print" "goto" "end" "+" ":" "let" "=" "gosub" "return" "-" "for" "to" "step" "next" "if" "then" "else" "and" "or" "<" ">" "*" "/" "(" ")" "^" "!" "mod" "input" ";" "def"))
(define basic-lexer
(lexer-srcloc
@ -25,7 +25,8 @@ b-expr : b-logic-expr
b-logic-expr : [b-logic-expr ("and" | "or")] b-comp-expr
b-comp-expr : [b-comp-expr ("=" | "<" | ">")] b-sum
b-sum : [b-sum ("+"|"-")] b-product
b-product : [b-product ("*"|"/"|"%"|"^")] b-value
b-product : [b-product ("*"|"/"|"mod")] b-expt
b-expt : [b-expt "^"] b-value
;; values
@b-value : b-id | b-number | /"(" b-expr /")" | b-not | b-func