Skip to content

Commit

Permalink
sequences.parser: simplify duplicate defition.
Browse files Browse the repository at this point in the history
currently, keep possibly poor "next" naming, since it was used in a few
more places than "get+increment". both are kinda bad names i guess.
  • Loading branch information
mrjbq7 committed Jan 12, 2024
1 parent e832efa commit 557313d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
7 changes: 1 addition & 6 deletions basis/sequences/parser/parser.factor
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,7 @@ TUPLE: sequence-parser sequence n ;
: advance ( sequence-parser -- sequence-parser )
[ 1 + ] change-n ; inline

: advance* ( sequence-parser -- )
advance drop ; inline

: next ( sequence-parser -- obj ) [ current ] [ advance* ] bi ;

: get+increment ( sequence-parser -- char/f )
: next ( sequence-parser -- char/f )
[ current ] [ advance drop ] bi ; inline

:: skip-until ( ... sequence-parser quot: ( ... obj -- ... ? ) -- ... )
Expand Down
2 changes: 1 addition & 1 deletion extra/c/lexer/lexer.factor
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ IN: c.lexer
} 1||
] take-while :> string
sequence-parser current quote-char = [
sequence-parser advance* string
sequence-parser advance drop string
] [
start-n sequence-parser n<< f
] if ;
Expand Down
2 changes: 1 addition & 1 deletion extra/html/parser/parser.factor
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ SYMBOL: tagstack
CHAR: \" (read-quote) ;

: read-quote ( sequence-parser -- string )
dup get+increment CHAR: ' =
dup next CHAR: ' =
[ read-single-quote ] [ read-double-quote ] if ;

: read-key ( sequence-parser -- string )
Expand Down

0 comments on commit 557313d

Please sign in to comment.