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