diff --git a/extra/peg/peg.factor b/extra/peg/peg.factor index 1707193e70..ae5ed2f8b2 100755 --- a/extra/peg/peg.factor +++ b/extra/peg/peg.factor @@ -43,17 +43,16 @@ TUPLE: token-parser symbol ; MATCH-VARS: ?token ; -: token-pattern ( -- quot ) - [ - ?token 2dup head? [ - dup >r length tail-slice r> - ] [ - 2drop f - ] if - ] ; - +: parse-token ( input string -- result ) + #! Parse the string, returning a parse result + 2dup head? [ + dup >r length tail-slice r> + ] [ + 2drop f + ] 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 ;