Add hide combinator
parent
055276ca25
commit
5fb6af754b
|
@ -128,3 +128,13 @@ HELP: sp
|
|||
{ $description
|
||||
"Returns a parser that calls the original parser 'p1' after stripping any whitespace "
|
||||
" from the left of the input string." } ;
|
||||
|
||||
HELP: hide
|
||||
{ $values
|
||||
{ "p1" "a parser" }
|
||||
{ "parser" "a parser" }
|
||||
}
|
||||
{ $description
|
||||
"Returns a parser that succeeds if the original parser succeeds, but does not "
|
||||
"put any result in the AST. Useful for ignoring 'syntax' in the AST." }
|
||||
{ $example "\"[\" token hide number \"]\" token hide 3array seq" } ;
|
||||
|
|
|
@ -144,4 +144,21 @@ IN: temporary
|
|||
|
||||
{ CHAR: a } [
|
||||
"a" [ CHAR: a = ] satisfy parse parse-result-ast
|
||||
] unit-test
|
||||
] unit-test
|
||||
|
||||
{ "a" } [
|
||||
" a" "a" token sp parse parse-result-ast
|
||||
] unit-test
|
||||
|
||||
{ "a" } [
|
||||
"a" "a" token sp parse parse-result-ast
|
||||
] unit-test
|
||||
|
||||
{ V{ "a" } } [
|
||||
"[a]" "[" token hide "a" token "]" token hide 3array seq parse parse-result-ast
|
||||
] unit-test
|
||||
|
||||
{ f } [
|
||||
"a]" "[" token hide "a" token "]" token hide 3array seq parse
|
||||
] unit-test
|
||||
|
||||
|
|
|
@ -205,3 +205,6 @@ PRIVATE>
|
|||
|
||||
: sp ( parser -- parser )
|
||||
sp-parser construct-boa init-parser ;
|
||||
|
||||
: hide ( parser -- parser )
|
||||
[ drop ignore ] action ;
|
||||
|
|
Loading…
Reference in New Issue