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