From 3673a3e7c7c8da13012842b7952c54fce2c9fd67 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 5 Dec 2008 23:53:16 -0600 Subject: [PATCH] Use stack effect literals instead of in PEG, and don't use smart combinators --- basis/peg/peg.factor | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/basis/peg/peg.factor b/basis/peg/peg.factor index 1fb5909bcf..8a62365f53 100644 --- a/basis/peg/peg.factor +++ b/basis/peg/peg.factor @@ -4,8 +4,7 @@ USING: kernel sequences strings fry namespaces make math assocs debugger io vectors arrays math.parser math.order vectors combinators classes sets unicode.categories compiler.units parser words quotations effects memoize accessors -locals effects splitting combinators.short-circuit -combinators.short-circuit.smart generalizations ; +locals effects splitting combinators.short-circuit generalizations ; IN: peg USE: prettyprint @@ -278,7 +277,8 @@ GENERIC: (compile) ( peg -- quot ) : parser-body ( parser -- quot ) #! Return the body of the word that is the compiled version #! of the parser. - gensym 2dup swap peg>> (compile) 0 1 define-declared swap dupd id>> "peg-id" set-word-prop + gensym 2dup swap peg>> (compile) (( -- result )) define-declared + swap dupd id>> "peg-id" set-word-prop [ execute-parser ] curry ; : preset-parser-word ( parser -- parser word ) @@ -306,7 +306,7 @@ SYMBOL: delayed #! Work through all delayed parsers and recompile their #! words to have the correct bodies. delayed get [ - call compile-parser 1quotation 0 1 define-declared + call compile-parser 1quotation (( -- result )) define-declared ] assoc-each ; : compile ( parser -- word ) @@ -421,7 +421,7 @@ M: seq-parser (compile) ( peg -- quot ) [ parsers>> unclip compile-parser 1quotation [ parse-seq-element ] curry , [ compile-parser 1quotation [ merge-errors ] compose [ parse-seq-element ] curry , ] each - ] { } make , \ && , + ] { } make , \ 1&& , ] [ ] make ; TUPLE: choice-parser parsers ; @@ -431,7 +431,7 @@ M: choice-parser (compile) ( peg -- quot ) [ parsers>> [ compile-parser ] map unclip 1quotation , [ 1quotation [ merge-errors ] compose , ] each - ] { } make , \ || , + ] { } make , \ 0|| , ] [ ] make ; TUPLE: repeat0-parser p1 ;