pull/2/head
Matthew Butterick 8 years ago
parent cd936ae09b
commit 2c6d8a781a

@ -1,3 +1,4 @@
#lang br/demo/jsonic
{"foo": @#(+ 4 2)#}
{"foo": @(+ 4 (+ 4 2)),
"bar" : ")"}

@ -14,6 +14,5 @@ number: NUMBER
kvpair: STRING /":" value
s-val: "@" ("[" STRING "]" | "{" STRING "}" | "#" STRING "#" )
s-val: S-EXP

@ -16,11 +16,11 @@
[(eof) eof]
[(or whitespace
(seq "//" (complement (seq any-string "\n" any-string)) "\n")) (next-token)]
[(char-set ",:[]{}@#") lexeme]
[(char-set ",:[]{}") lexeme]
[(seq "@" "(" any-string ")") (token 'S-EXP (string-trim lexeme "@"))]
[(seq (repetition 0 1 "-") (+ numeric) (repetition 0 1 (seq "." (* numeric))))
(token 'NUMBER lexeme)] ;; Q: what is grammar for a JS number?
[(seq "\"" (complement (seq any-string "\"" any-string)) "\"") (token 'STRING (string-trim lexeme "\""))]
[any-char lexeme]))
[(seq "\"" (complement (seq any-string "\"" any-string)) "\"") (token 'STRING (string-trim lexeme "\""))]))
(our-lexer port))
next-token)
@ -29,8 +29,3 @@
(define token-producer (tokenize ip))
(for/list ([token (in-producer token-producer eof)])
token))
(test-tokenize #<<HERE
{"foo": @#(+ 4 2)#}
HERE
)

Loading…
Cancel
Save