1 2 | #lang brag top : ("x" | FOO)+ |
1 | (token 'FOO 42) |
1 | (parse-to-datum (list "x" (token 'FOO 42))) |
1 | '(top "x" 42) |
1 2 3 4 5 6 | #lang algebra fun f(x,y) = x + y # fun f(x,y) = x * y fun g(zz) = f(zz,zz) g(10) g(23) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #lang br/quicklang (require brag/support "grammar.rkt") (provide top fun expr app) (module+ reader (provide read-syntax)) (define-lex-abbrev reserved-toks (:or #;···)) (define tokenize-1 (lexer [whitespace #;···] [(from/stop-before "#" "\n") #;···] [reserved-toks #;···] [(:+ alphabetic) #;···] [(:+ (char-set "0123456789")) #;···])) (define-macro top #;···) (define-macro-cases fun #;···) (define-macro-cases expr #;···) (define-macro app #;···) (define (read-syntax src ip) (define parse-tree (parse src (λ () (tokenize-1 ip)))) (strip-bindings (with-syntax ([PT parse-tree]) #'(module algebra-mod algebra PT)))) |
1 2 3 4 5 6 | #lang brag top : # ··· fun : # ··· expr : # ··· app : # ··· |