Refactor choice peg parser
parent
102178f787
commit
226d211342
|
@ -343,21 +343,16 @@ M: seq-parser (compile) ( parser -- quot )
|
|||
|
||||
TUPLE: choice-parser parsers ;
|
||||
|
||||
MATCH-VARS: ?quot ;
|
||||
|
||||
: choice-pattern ( -- quot )
|
||||
[
|
||||
[ ?quot ] unless*
|
||||
] ;
|
||||
|
||||
M: choice-parser (compile) ( parser -- quot )
|
||||
[
|
||||
f ,
|
||||
parsers>> [ compiled-parser \ ?quot choice-pattern match-replace % ] each
|
||||
parsers>> [ compiled-parser 1quotation , \ unless* , ] each
|
||||
] [ ] make ;
|
||||
|
||||
TUPLE: repeat0-parser p1 ;
|
||||
|
||||
MATCH-VARS: ?quot ;
|
||||
|
||||
: (repeat0) ( quot result -- result )
|
||||
over call [
|
||||
[ remaining>> swap (>>remaining) ] 2keep
|
||||
|
|
Loading…
Reference in New Issue