rename next to advance
parent
28dae46b7d
commit
09e4d34ff2
|
@ -38,7 +38,7 @@ SYMBOL: tagstack
|
||||||
swap >>text ; inline
|
swap >>text ; inline
|
||||||
|
|
||||||
: (read-quote) ( state-parser ch -- string )
|
: (read-quote) ( state-parser ch -- string )
|
||||||
'[ [ current _ = ] take-until ] [ next drop ] bi ;
|
'[ [ current _ = ] take-until ] [ advance drop ] bi ;
|
||||||
|
|
||||||
: read-single-quote ( state-parser -- string )
|
: read-single-quote ( state-parser -- string )
|
||||||
CHAR: ' (read-quote) ;
|
CHAR: ' (read-quote) ;
|
||||||
|
@ -69,12 +69,12 @@ SYMBOL: tagstack
|
||||||
">" take-until-sequence dtd new-tag push-tag ;
|
">" take-until-sequence dtd new-tag push-tag ;
|
||||||
|
|
||||||
: read-bang ( state-parser -- )
|
: read-bang ( state-parser -- )
|
||||||
next dup { [ current CHAR: - = ] [ peek-next CHAR: - = ] } 1&&
|
advance dup { [ current CHAR: - = ] [ peek-next CHAR: - = ] } 1&&
|
||||||
[ next next read-comment ] [ read-dtd ] if ;
|
[ advance advance read-comment ] [ read-dtd ] if ;
|
||||||
|
|
||||||
: read-tag ( state-parser -- string )
|
: read-tag ( state-parser -- string )
|
||||||
[ [ current "><" member? ] take-until ]
|
[ [ current "><" member? ] take-until ]
|
||||||
[ dup current CHAR: < = [ next ] unless drop ] bi ;
|
[ dup current CHAR: < = [ advance ] unless drop ] bi ;
|
||||||
|
|
||||||
: read-until-< ( state-parser -- string )
|
: read-until-< ( state-parser -- string )
|
||||||
[ current CHAR: < = ] take-until ;
|
[ current CHAR: < = ] take-until ;
|
||||||
|
@ -104,7 +104,7 @@ SYMBOL: tagstack
|
||||||
] state-parse ;
|
] state-parse ;
|
||||||
|
|
||||||
: read-< ( state-parser -- string/f )
|
: read-< ( state-parser -- string/f )
|
||||||
next dup current [
|
advance dup current [
|
||||||
CHAR: ! = [ read-bang f ] [ read-tag ] if
|
CHAR: ! = [ read-bang f ] [ read-tag ] if
|
||||||
] [
|
] [
|
||||||
drop f
|
drop f
|
||||||
|
|
|
@ -24,15 +24,15 @@ TUPLE: state-parser sequence n ;
|
||||||
: peek-next ( state-parser -- char/f )
|
: peek-next ( state-parser -- char/f )
|
||||||
[ n>> 1 + ] keep state-parser-nth ; inline
|
[ n>> 1 + ] keep state-parser-nth ; inline
|
||||||
|
|
||||||
: next ( state-parser -- state-parser )
|
: advance ( state-parser -- state-parser )
|
||||||
[ 1 + ] change-n ; inline
|
[ 1 + ] change-n ; inline
|
||||||
|
|
||||||
: get+increment ( state-parser -- char/f )
|
: get+increment ( state-parser -- char/f )
|
||||||
[ current ] [ next drop ] bi ; inline
|
[ current ] [ advance drop ] bi ; inline
|
||||||
|
|
||||||
:: skip-until ( state-parser quot: ( obj -- ? ) -- )
|
:: skip-until ( state-parser quot: ( obj -- ? ) -- )
|
||||||
state-parser current [
|
state-parser current [
|
||||||
state-parser quot call [ state-parser next quot skip-until ] unless
|
state-parser quot call [ state-parser advance quot skip-until ] unless
|
||||||
] when ; inline recursive
|
] when ; inline recursive
|
||||||
|
|
||||||
: state-parse-end? ( state-parser -- ? ) peek-next not ;
|
: state-parse-end? ( state-parser -- ? ) peek-next not ;
|
||||||
|
@ -67,7 +67,7 @@ TUPLE: state-parser sequence n ;
|
||||||
] take-until :> found
|
] take-until :> found
|
||||||
found dup length
|
found dup length
|
||||||
growing length 1- - head
|
growing length 1- - head
|
||||||
state-parser next drop ;
|
state-parser advance drop ;
|
||||||
|
|
||||||
: skip-whitespace ( state-parser -- state-parser )
|
: skip-whitespace ( state-parser -- state-parser )
|
||||||
[ [ current blank? not ] take-until drop ] keep ;
|
[ [ current blank? not ] take-until drop ] keep ;
|
||||||
|
|
Loading…
Reference in New Issue