tuneup jsonic
parent
e792346b96
commit
d6370a7f98
@ -1,4 +1,4 @@
|
|||||||
#lang br/quicklang
|
#lang br/quicklang
|
||||||
(module reader br/quicklang
|
(module reader br/quicklang
|
||||||
(require "jsonic/reader.rkt")
|
(require (submod "jsonic/main.rkt" reader))
|
||||||
(provide (all-from-out "jsonic/reader.rkt")))
|
(provide (all-from-out (submod "jsonic/main.rkt" reader))))
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#lang br/demo/jsonic
|
#lang br/demo/jsonic
|
||||||
|
{
|
||||||
{"number": @$(* 6 7)$@,
|
"number": @$(* 6 7)$@,
|
||||||
"string": @$(string-append "foo" "bar")$@,
|
"string": @$(string-append "foo" "bar")$@,
|
||||||
"array": @$(range 5)$@,
|
"array": @$(range 5)$@,
|
||||||
"object": @$(hash "k1" "valstring" "k2" 42)$@
|
"object": @$(hash "k1" "valstring" (format "~a" 42) (hash "k1" (range 10) "k2" 42))$@
|
||||||
// "bar" :
|
// "bar" :
|
||||||
}
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
#lang at-exp br/quicklang
|
||||||
|
(require "parser.rkt")
|
||||||
|
|
||||||
|
(module+ reader
|
||||||
|
(define (read-syntax path port)
|
||||||
|
(define parse-tree (parse path (tokenize port)))
|
||||||
|
(define module-datum `(module bf-mod br/demo/jsonic/expander
|
||||||
|
,parse-tree))
|
||||||
|
(datum->syntax #f module-datum))
|
||||||
|
(provide read-syntax))
|
||||||
|
|
||||||
|
(require parser-tools/lex parser-tools/lex-sre brag/support)
|
||||||
|
(define (tokenize port)
|
||||||
|
(define (next-token)
|
||||||
|
(define our-lexer
|
||||||
|
(lexer
|
||||||
|
[(eof) eof]
|
||||||
|
;; (char-complement "\n") means any char but "\n"
|
||||||
|
;; (complement "\n") means any whole string except "\n"
|
||||||
|
[(seq "//" (* (char-complement "\n"))) (next-token)]
|
||||||
|
["@$" (token 'OPEN lexeme)]
|
||||||
|
["$@" (token 'CLOSE lexeme)]
|
||||||
|
[any-char (token 'CHAR lexeme)]))
|
||||||
|
(our-lexer port))
|
||||||
|
next-token)
|
||||||
|
|
||||||
|
(define (test-tokenize str)
|
||||||
|
(define ip (open-input-string str))
|
||||||
|
(define token-producer (tokenize ip))
|
||||||
|
(for/list ([token (in-producer token-producer eof)])
|
||||||
|
token))
|
@ -1,28 +0,0 @@
|
|||||||
#lang at-exp br/quicklang
|
|
||||||
(require "parser.rkt")
|
|
||||||
|
|
||||||
(define (read-syntax path port)
|
|
||||||
(define parse-tree (parse path (tokenize port)))
|
|
||||||
(define module-datum `(module bf-mod br/demo/jsonic/expander
|
|
||||||
,parse-tree))
|
|
||||||
(datum->syntax #f module-datum))
|
|
||||||
(provide read-syntax)
|
|
||||||
|
|
||||||
(require parser-tools/lex parser-tools/lex-sre brag/support)
|
|
||||||
(define (tokenize port)
|
|
||||||
(define (next-token)
|
|
||||||
(define our-lexer
|
|
||||||
(lexer
|
|
||||||
[(eof) eof]
|
|
||||||
[(or (seq "//" (complement (seq any-string "\n" any-string)) "\n")) (next-token)]
|
|
||||||
[(seq "@$") (token 'OPEN lexeme)]
|
|
||||||
[(seq "$@") (token 'CLOSE lexeme)]
|
|
||||||
[any-char (token 'CHAR lexeme)]))
|
|
||||||
(our-lexer port))
|
|
||||||
next-token)
|
|
||||||
|
|
||||||
(define (test-tokenize str)
|
|
||||||
(define ip (open-input-string str))
|
|
||||||
(define token-producer (tokenize ip))
|
|
||||||
(for/list ([token (in-producer token-producer eof)])
|
|
||||||
token))
|
|
Loading…
Reference in New Issue