Reduce amount of generated code for peg token parser
parent
9b7246555a
commit
b1561de0f6
|
@ -43,17 +43,16 @@ TUPLE: token-parser symbol ;
|
||||||
|
|
||||||
MATCH-VARS: ?token ;
|
MATCH-VARS: ?token ;
|
||||||
|
|
||||||
: token-pattern ( -- quot )
|
: parse-token ( input string -- result )
|
||||||
[
|
#! Parse the string, returning a parse result
|
||||||
?token 2dup head? [
|
2dup head? [
|
||||||
dup >r length tail-slice r> <parse-result>
|
dup >r length tail-slice r> <parse-result>
|
||||||
] [
|
] [
|
||||||
2drop f
|
2drop f
|
||||||
] if
|
] if ;
|
||||||
] ;
|
|
||||||
|
|
||||||
M: token-parser (compile) ( parser -- quot )
|
M: token-parser (compile) ( parser -- quot )
|
||||||
token-parser-symbol \ ?token token-pattern match-replace ;
|
token-parser-symbol [ parse-token ] curry ;
|
||||||
|
|
||||||
TUPLE: satisfy-parser quot ;
|
TUPLE: satisfy-parser quot ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue