diff --git a/beautiful-racket/br/demo/basic/expander.rkt b/beautiful-racket/br/demo/basic/expander.rkt index 85429f0..be0db79 100644 --- a/beautiful-racket/br/demo/basic/expander.rkt +++ b/beautiful-racket/br/demo/basic/expander.rkt @@ -3,14 +3,21 @@ (rename-out [basic-module-begin #%module-begin]) (rename-out [basic-top #%top]) (all-defined-out)) -(require (for-syntax racket/syntax racket/list)) +(require (for-syntax racket/syntax racket/list br/datum)) + +(define-for-syntax alphasyms (for/list ([i (in-string "ABCDEFGHIJKLMNOPQRSTUVWXYZ")]) + (string->symbol (format "~a" i)))) +(define-for-syntax stringsyms (map (λ(s) (format-datum "~a$" s)) alphasyms)) (define-syntax (basic-module-begin stx) (syntax-case stx () [(_ PARSE-TREE ...) - (with-syntax ([(VARNAME ...) (map (λ(c) (format-id stx "~a" (integer->char c))) (range 65 91))]) + (with-syntax ([(VARNAME ...) (datum->syntax stx alphasyms)] + [(STRINGVARNAME ...) (datum->syntax stx stringsyms)]) #'(#%module-begin (define VARNAME 0) ... + (define STRINGVARNAME "") ... + (provide VARNAME ... STRINGVARNAME ...) (println (quote PARSE-TREE ...)) PARSE-TREE ...))])) @@ -38,8 +45,7 @@ idx))) (add1 line-idx))))) -(define-cases #'cr-line - [#'(_ ARG ...) #'(begin ARG ...)]) +(define #'(cr-line ARG ...) #'(begin ARG ...)) (define #'(line NUMBER STATEMENT ...) #'(cons NUMBER (λ _ STATEMENT ...))) diff --git a/beautiful-racket/br/demo/basic/sinewave.bas b/beautiful-racket/br/demo/basic/sinewave.bas index 4ba83c7..9a1201e 100644 --- a/beautiful-racket/br/demo/basic/sinewave.bas +++ b/beautiful-racket/br/demo/basic/sinewave.bas @@ -1,8 +1,6 @@ #lang br/demo/basic - -10 PRINT 2 + 3 * 10 + 1 - -20 PRINT 6 * 7 / 8 - - +1 A = 2 +10 PRINT A < 2 +12 C$ = "string thing" +15 PRINT A;: PRINT C$ \ No newline at end of file diff --git a/beautiful-racket/br/demo/basic/tokenizer.rkt b/beautiful-racket/br/demo/basic/tokenizer.rkt index f22dc07..b8edee3 100644 --- a/beautiful-racket/br/demo/basic/tokenizer.rkt +++ b/beautiful-racket/br/demo/basic/tokenizer.rkt @@ -27,7 +27,7 @@ [(union ";" "=" "(" ")") lexeme] [(union "+" "-" "*" "/" "<=" ">=" "<>" "><" "<" ">" "=" ) (string->symbol 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))] [whitespace (token 'WHITESPACE lexeme #:skip? #t)] [(:seq "\"" (complement (:: any-string "\"" any-string)) "\"") (token 'STRING (string-trim lexeme "\""))]