From 78633e03a0d9951407e33c01c8e33eac0205657e Mon Sep 17 00:00:00 2001 From: Chris Double Date: Sun, 30 Mar 2008 19:01:47 +1300 Subject: [PATCH] Allow var names in ebnf but ignore them for now --- extra/peg/ebnf/ebnf.factor | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/extra/peg/ebnf/ebnf.factor b/extra/peg/ebnf/ebnf.factor index af61c3aae0..0ae1430c8c 100644 --- a/extra/peg/ebnf/ebnf.factor +++ b/extra/peg/ebnf/ebnf.factor @@ -19,6 +19,7 @@ TUPLE: ebnf-repeat1 group ; TUPLE: ebnf-optional group ; TUPLE: ebnf-rule symbol elements ; TUPLE: ebnf-action parser code ; +TUPLE: ebnf-var parser name ; TUPLE: ebnf rules ; C: ebnf-non-terminal @@ -34,6 +35,7 @@ C: ebnf-repeat1 C: ebnf-optional C: ebnf-rule C: ebnf-action +C: ebnf-var C: ebnf : syntax ( string -- parser ) @@ -79,6 +81,7 @@ C: ebnf [ dup CHAR: * = ] [ dup CHAR: + = ] [ dup CHAR: ? = ] + [ dup CHAR: : = ] } || not nip ] satisfy repeat1 [ >string ] action ; @@ -200,6 +203,7 @@ DEFER: 'choice' : 'actioned-sequence' ( -- parser ) [ [ 'sequence' , "=>" syntax , 'action' , ] seq* [ first2 ] action , + [ 'sequence' , ":" syntax , "a-zA-Z" range-pattern repeat1 [ >string ] action , ] seq* [ first2 ] action , 'sequence' , ] choice* ; @@ -270,6 +274,9 @@ M: ebnf-action (transform) ( ast -- parser ) [ parser>> (transform) ] keep code>> string-lines [ parse-lines ] with-compilation-unit action ; +M: ebnf-var (transform) ( ast -- parser ) + parser>> (transform) ; + M: ebnf-terminal (transform) ( ast -- parser ) symbol>> token sp ;