rename
parent
e66b7acad1
commit
1f8e1520da
@ -0,0 +1,4 @@
|
|||||||
|
#lang br/quicklang
|
||||||
|
(module reader br/quicklang
|
||||||
|
(require (submod "jsonic-2/main.rkt" reader))
|
||||||
|
(provide (all-from-out (submod "jsonic-2/main.rkt" reader))))
|
@ -0,0 +1,21 @@
|
|||||||
|
#lang br/quicklang
|
||||||
|
(require json)
|
||||||
|
(define-macro (js-module-begin PARSE-TREE)
|
||||||
|
#'(#%module-begin
|
||||||
|
(define result-string PARSE-TREE)
|
||||||
|
(define validated-jsexpr (string->jsexpr result-string))
|
||||||
|
(display result-string)))
|
||||||
|
(provide (rename-out [js-module-begin #%module-begin]))
|
||||||
|
|
||||||
|
(define-macro (jsonic-program SEXP-OR-JSON-STR ...)
|
||||||
|
#'(string-trim (string-append SEXP-OR-JSON-STR ...)))
|
||||||
|
(provide jsonic-program)
|
||||||
|
|
||||||
|
(define-macro (json-char CHAR-STR)
|
||||||
|
#'CHAR-STR)
|
||||||
|
(provide json-char)
|
||||||
|
|
||||||
|
(define-macro (s-exp SEXP-STR)
|
||||||
|
(with-pattern ([SEXP-DATUM (format-datum '~a #'SEXP-STR)])
|
||||||
|
#'(jsexpr->string SEXP-DATUM)))
|
||||||
|
(provide s-exp)
|
@ -0,0 +1,11 @@
|
|||||||
|
#lang br/demo/jsonic-2
|
||||||
|
// a line comment
|
||||||
|
[
|
||||||
|
@$ 'null $@,
|
||||||
|
@$ (* 6 7) $@,
|
||||||
|
@$ (= 2 (+ 1 1)) $@,
|
||||||
|
@$ (list "array" "of" "strings") $@,
|
||||||
|
@$ (hash 'key-1 'null
|
||||||
|
'key-2 (even? 3)
|
||||||
|
'key-3 (hash 'subkey 21)) $@
|
||||||
|
]
|
@ -1,10 +1,7 @@
|
|||||||
#lang br/quicklang
|
#lang br/quicklang
|
||||||
(module reader br
|
(module reader br
|
||||||
(require br/demo/jsonic/reader)
|
(require "reader.rkt")
|
||||||
(provide (all-from-out br/demo/jsonic/reader)))
|
(provide read-syntax))
|
||||||
|
|
||||||
(require br/demo/jsonic/expander)
|
|
||||||
(provide (all-from-out br/demo/jsonic/expander))
|
|
||||||
|
|
||||||
#|
|
#|
|
||||||
Demonstrate:
|
Demonstrate:
|
@ -0,0 +1,4 @@
|
|||||||
|
#lang brag
|
||||||
|
jsonic-program: (s-exp | json-char)*
|
||||||
|
s-exp: SEXP-TOK
|
||||||
|
json-char: CHAR-TOK
|
@ -0,0 +1,8 @@
|
|||||||
|
#lang br/quicklang
|
||||||
|
(require "tokenizer.rkt" "parser.rkt")
|
||||||
|
(define (read-syntax path port)
|
||||||
|
(define parse-tree (parse path (tokenize port)))
|
||||||
|
(define module-datum `(module jsonic-module br/demo/jsonic/expander
|
||||||
|
,parse-tree))
|
||||||
|
(datum->syntax #f module-datum))
|
||||||
|
(provide read-syntax)
|
@ -0,0 +1,14 @@
|
|||||||
|
#lang br/quicklang
|
||||||
|
(require brag/support)
|
||||||
|
(define (tokenize port)
|
||||||
|
(define (next-token)
|
||||||
|
(define our-lexer
|
||||||
|
(lexer
|
||||||
|
[(eof) eof]
|
||||||
|
[(from/to "//" "\n") (next-token)]
|
||||||
|
[(from/to "@$" "$@")
|
||||||
|
(token 'SEXP-TOK (trim-ends "@$" lexeme "$@"))]
|
||||||
|
[any-char (token 'CHAR-TOK lexeme)]))
|
||||||
|
(our-lexer port))
|
||||||
|
next-token)
|
||||||
|
(provide tokenize)
|
@ -1,4 +0,0 @@
|
|||||||
#lang br/quicklang
|
|
||||||
(module reader br/quicklang
|
|
||||||
(require (submod "jsonic-pro/main.rkt" reader))
|
|
||||||
(provide (all-from-out (submod "jsonic-pro/main.rkt" reader))))
|
|
@ -1,13 +0,0 @@
|
|||||||
#lang br/demo/jsonic-pro
|
|
||||||
// a line comment
|
|
||||||
[
|
|
||||||
@$ 'null $@,
|
|
||||||
@$ #f $@,
|
|
||||||
@$ #t $@,
|
|
||||||
@$ (* 6 7) $@,
|
|
||||||
@$ "string" $@,
|
|
||||||
@$ (list "array" "of" "strings") $@,
|
|
||||||
@$ (hash 'key-1 42
|
|
||||||
'key-2 "value"
|
|
||||||
'key-3 (hash 'subkey 21)) $@
|
|
||||||
]
|
|
Loading…
Reference in New Issue