]> gitweb.factorcode.org Git - factor.git/commitdiff
peg: need to compile at top level to prevent races on parallel-map
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 6 Jun 2023 02:43:26 +0000 (19:43 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 6 Jun 2023 02:43:46 +0000 (19:43 -0700)
basis/peg/peg.factor

index 1ccd3ffda5053bee76e2e861cb581f74381cb717..6617b1749febca06a933615aa16eaf8eeb0876e2 100644 (file)
@@ -591,14 +591,22 @@ PRIVATE>
     ! to fix boxes so this isn't needed...
     box-parser boa f next-id parser boa [ ] action ;
 
-ERROR: parse-failed input word ;
-
 SYNTAX: PARTIAL-PEG:
-    (:) [ ( -- parser ) memoize-quot '[ @ parse ] ] dip
-    define-declared ;
+    (:) '[
+        [
+            _ _ call( -- parser ) compile
+            [ compiled-parse ast>> ] curry
+            _ define-declared
+        ] with-compilation-unit
+    ] append! ;
 
 SYNTAX: PEG:
-    (:) [ ( -- parser ) memoize-quot '[ @ parse-fully ] ] dip
-    define-declared ;
+    (:) '[
+        [
+            _ _ call( -- parser ) compile
+            [ compiled-parse check-parse-result ast>> ] curry
+            _ define-declared
+        ] with-compilation-unit
+    ] append! ;
 
 { "debugger" "peg" } "peg.debugger" require-when