diff --git a/beautiful-racket-demo/basic-demo/expander.rkt b/beautiful-racket-demo/basic-demo/expander.rkt index 724cdeb..de03e0b 100644 --- a/beautiful-racket-demo/basic-demo/expander.rkt +++ b/beautiful-racket-demo/basic-demo/expander.rkt @@ -28,7 +28,7 @@ (define b-rem void) (define (b-print [val ""]) (displayln val)) (define (b-sum . nums) (apply + nums)) -(define (b-expr expr) +(define (b-num-expr expr) (if (integer? expr) (inexact->exact expr) expr)) (struct $program-end-signal ()) diff --git a/beautiful-racket-demo/basic-demo/parser.rkt b/beautiful-racket-demo/basic-demo/parser.rkt index 0dced96..072a7e2 100644 --- a/beautiful-racket-demo/basic-demo/parser.rkt +++ b/beautiful-racket-demo/basic-demo/parser.rkt @@ -1,15 +1,12 @@ #lang brag -b-program : [b-line] (/NEWLINE+ [b-line])* +b-program : [b-line] (/NEWLINE [b-line])* b-line : @b-line-number [b-statement] (/":" [b-statement])* b-line-number : INTEGER -@b-statement : b-rem - | b-print - | b-goto - | b-end +@b-statement : b-rem | b-end | b-print | b-goto b-rem : REM -b-print : /"print" (STRING | b-expr)* -b-goto : /"goto" b-expr -b-expr : b-sum +b-end : /"end" +b-print : /"print" [STRING | b-num-expr] +b-goto : /"goto" b-num-expr +b-num-expr : b-sum b-sum : (b-number /"+")* b-number -@b-number : INTEGER | DECIMAL -b-end : /"end" \ No newline at end of file +@b-number : INTEGER | DECIMAL \ No newline at end of file