diff --git a/beautiful-racket/br/demo/basic/expander.rkt b/beautiful-racket/br/demo/basic/expander.rkt index 26a6f22..ce6c759 100644 --- a/beautiful-racket/br/demo/basic/expander.rkt +++ b/beautiful-racket/br/demo/basic/expander.rkt @@ -90,7 +90,7 @@ _TRUE-RESULT _FALSE-RESULT)] [#'(_ _COND "THEN" _TRUE-RESULT) - #'(when (true? COND) + #'(when (true? _COND) _TRUE-RESULT)]) (define-cases #'value @@ -131,7 +131,7 @@ (match args [(list) (displayln "")] [(list print-list-item ... ";" pl) (begin (for-each display print-list-item) - (print pl))] + (basic:PRINT pl))] [(list print-list-item ... ";") (for-each display print-list-item)] [(list print-list-item ...) (for-each displayln print-list-item)])) diff --git a/beautiful-racket/br/demo/basic/next-fix.bas b/beautiful-racket/br/demo/basic/next-fix.bas new file mode 100644 index 0000000..953acab --- /dev/null +++ b/beautiful-racket/br/demo/basic/next-fix.bas @@ -0,0 +1,5 @@ +#lang br/demo/basic + + +300 B=INT(RND(3*2)) +400 PRINT B \ No newline at end of file diff --git a/beautiful-racket/br/demo/basic/parser.rkt b/beautiful-racket/br/demo/basic/parser.rkt index 421dcad..0cddd8f 100644 --- a/beautiful-racket/br/demo/basic/parser.rkt +++ b/beautiful-racket/br/demo/basic/parser.rkt @@ -26,8 +26,8 @@ sum : product [("+" | "-") sum] product : value [("*" | "/") product] -value : "(" expr ")" -| ID ["(" expr* ")"] +value : ID ["(" expr* ")"] +| "(" expr ")" | STRING | NUMBER diff --git a/beautiful-racket/br/demo/basic/tokenizer.rkt b/beautiful-racket/br/demo/basic/tokenizer.rkt index ab0a086..deb218b 100644 --- a/beautiful-racket/br/demo/basic/tokenizer.rkt +++ b/beautiful-racket/br/demo/basic/tokenizer.rkt @@ -1,15 +1,14 @@ #lang br -(require parser-tools/lex - (prefix-in : parser-tools/lex-sre) +(require parser-tools/lex parser-tools/lex-sre ragg/support racket/string) (provide tokenize) (define-lex-abbrevs (natural (repetition 1 +inf.0 numeric)) - (integer (:seq (:? "-") natural)) - (number (:seq integer (:? (:seq "." natural)))) - (quoted-string (:seq "\"" (repetition 0 +inf.0 (char-complement "\"")) "\""))) + (number (union (seq (? "-") natural) + (seq (? "-") (? natural) (seq "." natural)))) + (quoted-string (seq "\"" (repetition 0 +inf.0 (char-complement "\"")) "\""))) (define (tokenize input-port) (define (next-token) @@ -17,17 +16,17 @@ (lexer [(eof) eof] [(union #\tab #\space - (:seq number " REM" (repetition 1 +inf.0 (char-complement #\newline)) #\newline)) (get-token input-port)] - [(:seq #\newline (repetition 0 +inf.0 whitespace)) (token 'CR "cr")] + (seq number " REM" (repetition 1 +inf.0 (char-complement #\newline)) #\newline)) (get-token input-port)] + [(seq #\newline (repetition 0 +inf.0 whitespace)) (token 'CR "cr")] [(union "PRINT" "FOR" "TO" "STEP" "IF" "GOTO" "INPUT" "LET" "NEXT" "RETURN" "CLEAR" "LIST" "RUN" "END" "THEN" "ELSE" "GOSUB" "AND" "OR" ";" "=" "(" ")" "+" "-" "*" "/" - "<=" ">=" "<>" "><" "<" ">" "=" ":") lexeme] + "<=" ">=" "<>" "<" ">" "=" ":") lexeme] [(union ",") (get-token input-port)] [number (token 'NUMBER (string->number lexeme))] - [(:seq (repetition 1 +inf.0 upper-case) (:? "$")) (token 'ID (string->symbol lexeme))] + [(seq (repetition 1 +inf.0 upper-case) (? "$")) (token 'ID (string->symbol lexeme))] [upper-case (token 'UPPERCASE (string->symbol lexeme))] [quoted-string (token 'STRING (string-trim lexeme "\""))])) (get-token input-port))