strings.parser: better string error messages.
parent
1f063155a9
commit
42c56a2de1
|
@ -1,8 +1,8 @@
|
||||||
! Copyright (C) 2008, 2009 Slava Pestov, Doug Coleman.
|
! Copyright (C) 2008, 2009 Slava Pestov, Doug Coleman.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors arrays assocs combinators kernel kernel.private
|
USING: accessors assocs combinators continuations kernel
|
||||||
lexer math math.parser namespaces sbufs sequences splitting
|
kernel.private lexer math math.parser namespaces sbufs sequences
|
||||||
strings ;
|
splitting strings ;
|
||||||
IN: strings.parser
|
IN: strings.parser
|
||||||
|
|
||||||
ERROR: bad-escape char ;
|
ERROR: bad-escape char ;
|
||||||
|
@ -151,12 +151,21 @@ DEFER: (parse-full-string)
|
||||||
(parse-full-string)
|
(parse-full-string)
|
||||||
] if*
|
] if*
|
||||||
] [
|
] [
|
||||||
throw-unexpected-eof
|
"Unterminated string" throw
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
|
: rewind-on-error ( quot -- )
|
||||||
|
lexer get [ line>> ] [ line-text>> ] [ column>> ] tri
|
||||||
|
[
|
||||||
|
lexer get [ column<< ] [ line-text<< ] [ line<< ] tri
|
||||||
|
rethrow
|
||||||
|
] 3curry recover ; inline
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
: parse-full-string ( -- str )
|
: parse-full-string ( -- str )
|
||||||
|
[
|
||||||
SBUF" " clone [
|
SBUF" " clone [
|
||||||
lexer get (parse-full-string)
|
lexer get (parse-full-string)
|
||||||
] keep unescape-string ;
|
] keep unescape-string
|
||||||
|
] rewind-on-error ;
|
||||||
|
|
Loading…
Reference in New Issue