dev-srcloc
Matthew Butterick 8 years ago
parent 83c83dd350
commit 8e32cf31f7

@ -4,14 +4,15 @@
#'(#%module-begin
(define result-string PARSE-TREE)
(define validated-jsexpr (string->jsexpr result-string))
(display (jsexpr->string validated-jsexpr))))
(display result-string)))
(provide (rename-out [js-module-begin #%module-begin]))
(define-macro (jsonic-program S-EXP-OR-JSON-CHAR ...)
#'(string-append S-EXP-OR-JSON-CHAR ...))
(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)
(define-macro (json-char CHAR-STR)
#'CHAR-STR)
(provide json-char)
(define-macro (s-exp SEXP-STR)

@ -5,8 +5,8 @@
(define our-lexer
(lexer
[(eof) eof]
[(between "//" "\n") (next-token)]
[(between "@$" "$@")
[(from/to "//" "\n") (next-token)]
[(from/to "@$" "$@")
(token 'SEXP-TOK (trim-ends "@$" lexeme "$@"))]
[any-char (token 'CHAR-TOK lexeme)]))
(our-lexer port))

@ -987,7 +987,7 @@ Repeatedly apply @racket[tokenizer] to @racket[source-string], gathering the res
[str string?]
[right-str string?])
string?]{
Remove @racket[left-str] from the left side of @racket[str], and @racket[right-str] from its right side. Intended as a helper function for @racket[between].
Remove @racket[left-str] from the left side of @racket[str], and @racket[right-str] from its right side. Intended as a helper function for @racket[from/to].
}
@ -1050,7 +1050,7 @@ one character.}
Character ranges, matching characters between successive pairs of
characters.}
@defform[(between open close)]{
@defform[(from/to open close)]{
A string that is bounded by @racket[open] and @racket[close]. Matching is non-greedy (meaning, it stops at the first occurence of @racket[close]). The resulting lexeme includes @racket[open] and @racket[close]. To remove them, see @racket[trim-ends].}

@ -10,7 +10,7 @@
[struct-out exn:fail:parsing]
apply-tokenizer
trim-ends
between)
from/to)
(struct token-struct (type val offset line column span skip?)
@ -53,7 +53,7 @@
(define (trim-ends left lexeme right)
(string-trim (string-trim lexeme left #:right? #f) right #:left? #f))
(define-lex-trans between
(define-lex-trans from/to
(λ(stx)
(syntax-case stx ()
[(_ OPEN CLOSE)

Loading…
Cancel
Save