Tuple parsing didn't handle line breaks properly; if scan returns f, must throw unexpected-eof

db4
Slava Pestov 2008-11-03 21:01:50 -06:00
parent 3e75e0f8b5
commit b4d3473d5e
2 changed files with 41 additions and 3 deletions

View File

@ -109,3 +109,36 @@ TUPLE: parsing-corner-case x ;
"}"
} "\n" join eval
] unit-test
[ T{ parsing-corner-case f 3 } ] [
{
"USE: classes.tuple.parser.tests"
"T{ parsing-corner-case"
" { x 3 }"
"}"
} "\n" join eval
] unit-test
[ T{ parsing-corner-case f 3 } ] [
{
"USE: classes.tuple.parser.tests"
"T{ parsing-corner-case {"
" x 3 }"
"}"
} "\n" join eval
] unit-test
[
{
"USE: classes.tuple.parser.tests T{ parsing-corner-case"
" { x 3 }"
} "\n" join eval
] [ error>> unexpected-eof? ] must-fail-with
[
{
"USE: classes.tuple.parser.tests T{ parsing-corner-case {"
" x 3 }"
} "\n" join eval
] [ error>> unexpected-eof? ] must-fail-with

View File

@ -60,14 +60,19 @@ ERROR: invalid-slot-name name ;
dup check-duplicate-slots
3dup check-slot-shadowing ;
: parse-slot-value ( -- )
scan scan-object 2array , scan "}" assert= ;
ERROR: bad-literal-tuple ;
: parse-slot-value ( -- )
scan scan-object 2array , scan {
{ f [ unexpected-eof ] }
{ "}" [ ] }
[ bad-literal-tuple ]
} case ;
: (parse-slot-values) ( -- )
parse-slot-value
scan {
{ f [ unexpected-eof ] }
{ "{" [ (parse-slot-values) ] }
{ "}" [ ] }
[ bad-literal-tuple ]