Refactor action peg parser
							parent
							
								
									247bf2137b
								
							
						
					
					
						commit
						d93c7958fd
					
				| 
						 | 
					@ -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
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue