]> gitweb.factorcode.org Git - factor.git/commitdiff
peg.ebnf: reset ebnf words properly
authorJohn Benediktsson <mrjbq7@gmail.com>
Sat, 6 Jan 2024 04:36:06 +0000 (20:36 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sat, 6 Jan 2024 04:36:06 +0000 (20:36 -0800)
basis/peg/ebnf/ebnf.factor

index eefa9a600651023d0d9f0ec6beb0402a62bb3ad5..ad5f75ad8b1fdfc2bedb5df8cab97ddd462dfb39 100644 (file)
@@ -1,11 +1,12 @@
 ! Copyright (C) 2007 Chris Double.
 ! See https://factorcode.org/license.txt for BSD license.
 
-USING: accessors assocs combinators combinators.short-circuit
-effects kernel make math.parser multiline namespaces parser peg
-peg.private peg.parsers peg.search quotations sequences
-sequences.deep splitting stack-checker strings strings.parser
-summary unicode vocabs.parser words ;
+USING: accessors arrays assocs combinators
+combinators.short-circuit definitions effects kernel make
+math.parser multiline namespaces parser peg peg.parsers
+peg.private peg.search quotations sequences sequences.deep
+splitting stack-checker strings strings.parser summary unicode
+vocabs.parser words ;
 
 IN: peg.ebnf
 
@@ -548,6 +549,16 @@ SYNTAX: PARTIAL-EBNF:
     [ ast>> ] compose
     ( input -- ast ) define-declared ;
 
+PREDICATE: ebnf-word < word "ebnf-quot" word-prop >boolean ;
+
+M: ebnf-word reset-word
+    [ call-next-method ]
+    [ "ebnf-quot" word-prop first first forget ]
+    [ "ebnf-quot" remove-word-prop ] tri ;
+
+M: ebnf-word forget*
+    [ call-next-method ] [ "ebnf-quot" word-prop first first forget ] bi ;
+
 : define-inline-ebnf ( ast string -- quot )
     reset-tokenizer
     ebnf>quot [ check-parse-result ast>> ] compose nip