adjust scribble lexer so that it uses the new 'text' category

instead of just using string

this is especially important for doing a good job with indentation
This commit is contained in:
Robby Findler 2013-10-25 22:19:53 -05:00
parent a940a47aaf
commit 5a2332609c
2 changed files with 45 additions and 42 deletions

View File

@ -214,8 +214,8 @@
;; Read string up to @, }, or newline
(regexp-match? (text-string-rx l) in)
(let-values ([(end-line end-col end-pos) (port-next-location in)])
(values 'string
'string
(values 'text
'text
#f
pos
end-pos

View File

@ -35,30 +35,33 @@
(pretty-print val (current-error-port))
(eprintf "\n"))))
(define-syntax-rule (test str len-val)
(test* str len-val (syntax-line #'str)))
(define-syntax (test stx)
(syntax-case stx ()
[(_ str len-val)
(with-syntax ([line (syntax-line stx)])
#'(test* str len-val line))]))
(test "x" '((1 string)))
(test "x{}" '((3 string)))
(test "x" '((1 text)))
(test "x{}" '((3 text)))
(test "@x" '((1 parenthesis)
(1 symbol)))
(test "@x str" '((1 parenthesis)
(1 symbol)
(4 string)))
(4 text)))
(test "@x[] str" '((1 parenthesis)
(1 symbol)
(1 parenthesis)
(1 parenthesis)
(4 string)))
(4 text)))
(test "@x[z] str" '((1 parenthesis)
(1 symbol)
(1 parenthesis)
(1 symbol)
(1 parenthesis)
(4 string)))
(4 text)))
(test "@x[z +1.5] str" '((1 parenthesis)
(1 symbol)
@ -67,7 +70,7 @@
(1 white-space)
(4 constant)
(1 parenthesis)
(4 string)))
(4 text)))
(test "@x[z @w{10}] str" '((1 parenthesis)
(1 symbol) ; x
@ -77,10 +80,10 @@
(1 parenthesis)
(1 symbol) ; w
(1 parenthesis)
(2 string)
(2 text)
(1 parenthesis)
(1 parenthesis)
(4 string)))
(4 text)))
(test "@x[a@b]{a}{b}" '((1 parenthesis)
(1 symbol)
@ -88,9 +91,9 @@
(3 symbol)
(1 parenthesis)
(1 parenthesis)
(1 string)
(1 text)
(1 parenthesis)
(3 string)))
(3 text)))
(test "@x{{}}" '((1 parenthesis)
(1 symbol)
(1 parenthesis)
@ -101,31 +104,31 @@
(test "@|x|str" '((2 parenthesis)
(1 symbol 2)
(1 parenthesis 3)
(3 string)))
(3 text)))
(test "@|x #|ok|#|str" '((2 parenthesis)
(1 symbol 2)
(1 white-space 3)
(6 comment)
(1 parenthesis)
(3 string)))
(3 text)))
(test "@| x ; c\n| str" '((2 parenthesis)
(1 white-space 2)
(1 symbol)
(1 white-space)
(3 comment)
(2 parenthesis)
(4 string)))
(4 text)))
(test "@|(a|b|)|str" '((2 parenthesis)
(1 parenthesis 2)
(4 symbol 3)
(1 parenthesis 7)
(1 parenthesis 8)
(3 string)))
(3 text)))
(test "@#|bad|#x str" '((1 parenthesis)
(7 error)
(1 symbol)
(4 string)))
(4 text)))
(test "@@x" '((1 parenthesis)
(1 parenthesis)
(1 symbol)))
@ -133,7 +136,7 @@
(1 parenthesis 2)
(1 symbol)
(1 parenthesis)
(1 string)))
(1 text)))
(test "@@x[1 2][3]" '((1 parenthesis)
(1 parenthesis)
(1 symbol)
@ -147,15 +150,15 @@
(1 parenthesis)))
(test "@{1 2}" '((2 parenthesis)
(3 string)
(3 text)
(1 parenthesis)))
(test "@|=={1 2}==|" '((5 parenthesis)
(3 string)
(3 text)
(4 parenthesis)))
(test "@'{1 2}" '((1 parenthesis)
(1 constant)
(1 parenthesis)
(3 string)
(3 text)
(1 parenthesis)))
(test "@',#,#`|>>{1 2}<<|" '((1 parenthesis)
(1 constant) ; ,
@ -163,33 +166,33 @@
(2 other) ; #,
(2 constant) ; #`
(4 parenthesis)
(3 string)
(3 text)
(4 parenthesis)))
(test "@x|{10}|" '((1 parenthesis)
(1 symbol)
(2 parenthesis)
(2 string)
(2 text)
(2 parenthesis)))
(test "@x|{@q}|" '((1 parenthesis)
(1 symbol)
(2 parenthesis)
(2 string)
(2 text)
(2 parenthesis)))
(test "@x|!!{@q}!!|" '((1 parenthesis)
(1 symbol)
(4 parenthesis)
(2 string)
(2 text)
(4 parenthesis)))
(test "@x|(({@q}))|" '((1 parenthesis)
(1 symbol)
(4 parenthesis)
(2 string)
(2 text)
(4 parenthesis)))
(test "@x|<<{a|<<@a[10]}>>|" '((1 parenthesis)
(1 symbol)
(4 parenthesis)
(1 string)
(1 text)
(4 parenthesis)
(1 symbol)
(1 parenthesis)
@ -199,9 +202,9 @@
(test "@x|{ |{ } }|}|" '((1 parenthesis)
(1 symbol)
(2 parenthesis)
(1 string)
(1 text)
(2 parenthesis) ; |{
(3 string)
(3 text)
(2 parenthesis) ; }|
(2 parenthesis)))
@ -211,37 +214,37 @@
(2 other) ; ,@
(3 symbol)
(1 parenthesis)
(4 string)
(4 text)
(1 parenthesis)))
(test "@; 1" '((4 comment)))
(test "@; 1\nv" '((4 comment)
(1 white-space)
(1 string)))
(1 text)))
(test "@;{1}v" '((2 comment)
(1 parenthesis)
(1 string)
(1 text)
(1 parenthesis)
(1 string)))
(1 text)))
(test "@;|{1 }} }|v" '((2 comment)
(2 parenthesis)
(5 string)
(5 text)
(2 parenthesis)
(1 string)))
(1 text)))
(test "a\n b" '((1 string)
(test "a\n b" '((1 text)
(3 white-space)
(1 string)))
(1 text)))
(test "@item{A\nB}" '((1 parenthesis)
(4 symbol)
(1 parenthesis)
(1 string)
(1 text)
(1 white-space)
(1 string)
(1 text)
(1 parenthesis)))
(test "@|()|})|" '((2 parenthesis)
(1 parenthesis 2)
(1 parenthesis 3)
(1 parenthesis 4)
(3 string)))
(3 text)))