Refactor action peg parser

db4
Chris Double 2008-04-05 18:33:50 +13:00
parent 247bf2137b
commit d93c7958fd
1 changed files with 8 additions and 9 deletions

View File

@ -423,17 +423,16 @@ TUPLE: action-parser p1 quot ;
MATCH-VARS: ?action ; MATCH-VARS: ?action ;
: action-pattern ( -- quot ) : check-action ( result quot -- result )
[ over [
?quot dup [ over ast>> swap call >>ast
dup ast>> ?action call ] [
>>ast drop
] when ] if ; inline
] ;
M: action-parser (compile) ( parser -- quot ) M: action-parser (compile) ( parser -- quot )
[ p1>> compiled-parser ] [ quot>> ] bi [ p1>> compiled-parser 1quotation ] [ quot>> ] bi '[
2array { ?quot ?action } action-pattern match-replace ; @ , check-action ] ;
: left-trim-slice ( string -- string ) : left-trim-slice ( string -- string )
#! Return a new string without any leading whitespace #! Return a new string without any leading whitespace