fix bug in state-parser, add take-token

db4
Doug Coleman 2009-04-01 15:23:05 -05:00
parent 947bcc3d33
commit d64e07af8b
2 changed files with 7 additions and 1 deletions

View File

@ -79,3 +79,6 @@ IN: html.parser.state.tests
[ CHAR: \ CHAR: " take-quoted-string drop ]
[ "\"abc" take-sequence ] bi
] unit-test
[ "c" ]
[ "c" <state-parser> take-token ] unit-test

View File

@ -36,7 +36,7 @@ TUPLE: state-parser sequence n ;
state-parser quot call [ state-parser advance quot skip-until ] unless
] when ; inline recursive
: state-parse-end? ( state-parser -- ? ) peek-next not ;
: state-parse-end? ( state-parser -- ? ) current not ;
: take-until ( state-parser quot: ( obj -- ? ) -- sequence/f )
over state-parse-end? [
@ -96,3 +96,6 @@ TUPLE: state-parser sequence n ;
] [
start-n state-parser (>>n) f
] if ;
: take-token ( state-parser -- string )
skip-whitespace [ current { [ blank? ] [ f = ] } 1|| ] take-until ;