From: John Benediktsson Date: Sat, 6 Jan 2024 04:36:06 +0000 (-0800) Subject: peg.ebnf: reset ebnf words properly X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=306a8883ea77fe3c7325db218d99728f9cb4d000 peg.ebnf: reset ebnf words properly --- diff --git a/basis/peg/ebnf/ebnf.factor b/basis/peg/ebnf/ebnf.factor index eefa9a6006..ad5f75ad8b 100644 --- a/basis/peg/ebnf/ebnf.factor +++ b/basis/peg/ebnf/ebnf.factor @@ -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