]> gitweb.factorcode.org Git - factor.git/blobdiff - basis/peg/peg.factor
basis: use lint.vocabs tool to trim using lists
[factor.git] / basis / peg / peg.factor
index 44c04f0f2ef9805a162db801de2bc2d7d501b502..eb8dd16b33173ab609f98242748e945a7ed0e5fd 100644 (file)
@@ -3,9 +3,8 @@
 
 USING: accessors arrays assocs classes combinators
 combinators.short-circuit compiler.units effects.parser fry
-generalizations kernel locals make math math.order namespaces
-quotations sequences sets splitting unicode vectors
-vocabs.loader words ;
+kernel make math math.order namespaces quotations sequences
+sets splitting unicode vectors vocabs.loader words ;
 
 IN: peg
 
@@ -266,7 +265,7 @@ GENERIC: (compile) ( peg -- quot )
     pos get apply-rule process-parser-result ;
 
 : preset-parser-word ( parser -- word parser )
-    gensym swap over >>compiled ;
+    gensym tuck >>compiled ;
 
 : define-parser-word ( word parser -- )
     ! Return the body of the word that is the compiled version
@@ -306,19 +305,19 @@ SYMBOL: delayed
 : compile ( parser -- word )
     [
         H{ } clone delayed [
-            compile-parser-quot ( -- result ) define-temp fixup-delayed
+            compile-parser fixup-delayed
         ] with-variable
     ] with-compilation-unit ;
 
 : compiled-parse ( state word -- result )
     swap [
-        execute( -- result )
+        execute-parser
         [ error-stack get ?first [ throw ]
         [ pos get input get f <parse-error> throw ] if* ] unless*
     ] with-packrat ;
 
 : (parse) ( input parser -- result )
-    dup word? [ compile ] unless compiled-parse ;
+    compile compiled-parse ;
 
 : parse ( input parser -- ast )
     (parse) ast>> ;
@@ -461,7 +460,7 @@ M: ensure-not-parser (compile)
 TUPLE: action-parser parser quot ;
 
 : check-action ( result quot -- result )
-    dupd '[ _ change-ast ] when ; inline
+    dupd '[ [ _ call( ast -- ast ) ] change-ast ] when ;
 
 M: action-parser (compile)
     [ parser>> compile-parser-quot ] [ quot>> ] bi