Merge git://double.co.nz/git/factor
commit
0fa98ea10d
|
@ -48,3 +48,7 @@ IN: peg.parsers.tests
|
|||
|
||||
[ V{ } ]
|
||||
[ "" epsilon parse parse-result-ast ] unit-test
|
||||
|
||||
{ "a" } [
|
||||
"a" "a" token just parse parse-result-ast
|
||||
] unit-test
|
|
@ -3,14 +3,14 @@
|
|||
USING: kernel sequences strings namespaces math assocs shuffle
|
||||
vectors arrays combinators.lib math.parser match
|
||||
unicode.categories sequences.deep peg peg.private
|
||||
peg.search math.ranges ;
|
||||
peg.search math.ranges words ;
|
||||
IN: peg.parsers
|
||||
|
||||
TUPLE: just-parser p1 ;
|
||||
|
||||
: just-pattern
|
||||
[
|
||||
dup [
|
||||
execute dup [
|
||||
dup parse-result-remaining empty? [ drop f ] unless
|
||||
] when
|
||||
] ;
|
||||
|
|
|
@ -43,17 +43,16 @@ TUPLE: token-parser symbol ;
|
|||
|
||||
MATCH-VARS: ?token ;
|
||||
|
||||
: token-pattern ( -- quot )
|
||||
[
|
||||
?token 2dup head? [
|
||||
dup >r length tail-slice r> <parse-result>
|
||||
] [
|
||||
2drop f
|
||||
] if
|
||||
] ;
|
||||
|
||||
: 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 ;
|
||||
|
||||
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