<PRIVATE
-: (parse-short-string) ( accum str -- accum m )
- { sbuf slice } declare
- dup [ "\"\\" member? ] find [
- [ cut-slice [ append! ] dip rest-slice ] dip
- CHAR: " = [
- from>>
- ] [
- next-escape [ suffix! ] dip (parse-short-string)
- ] if
- ] [
- "Unterminated string" throw
- ] if* ;
-
-PRIVATE>
-
-: parse-short-string ( -- str )
- SBUF" " clone lexer get [
- swap tail-slice (parse-short-string) [ "" like ] dip
- ] change-lexer-column ;
-
-<PRIVATE
-
: lexer-subseq ( i lexer -- before )
{ fixnum lexer } declare
[ [ column>> ] [ line-text>> ] bi swapd subseq ]
[ column>> ] [ line-text>> ] bi
[ "\"\\" member? ] find-from ;
-DEFER: (parse-full-string)
+DEFER: (parse-string)
: parse-found-token ( accum lexer i elt -- )
{ sbuf lexer fixnum fixnum } declare
dup dup [ next-char ] bi@
[ [ pick push ] bi@ ]
[ drop 2dup next-line% ] if*
- (parse-full-string)
+ (parse-string)
] [
advance-char drop
] if ;
-: (parse-full-string) ( accum lexer -- )
+: (parse-string) ( accum lexer -- )
{ sbuf lexer } declare
dup still-parsing? [
dup find-next-token [
] [
drop 2dup next-line%
CHAR: \n pick push
- (parse-full-string)
+ (parse-string)
] if*
] [
"Unterminated string" throw
] if ;
-: rewind-on-error ( quot -- )
+: rewind-lexer-on-error ( quot -- )
lexer get [ line>> ] [ line-text>> ] [ column>> ] tri
[
lexer get [ column<< ] [ line-text<< ] [ line<< ] tri
PRIVATE>
-: parse-full-string ( -- str )
+: parse-string ( -- str )
[
SBUF" " clone [
- lexer get (parse-full-string)
+ lexer get (parse-string)
] keep unescape-string
- ] rewind-on-error ;
+ ] rewind-lexer-on-error ;
} cond suffix!
] define-core-syntax
- "\"" [ parse-full-string suffix! ] define-core-syntax
+ "\"" [ parse-string suffix! ] define-core-syntax
"SBUF\"" [
- lexer get skip-blank parse-full-string >sbuf suffix!
+ lexer get skip-blank parse-string >sbuf suffix!
] define-core-syntax
"P\"" [
- lexer get skip-blank parse-short-string <pathname> suffix!
+ lexer get skip-blank parse-string <pathname> suffix!
] define-core-syntax
"[" [ parse-quotation suffix! ] define-core-syntax