From 16a0cc9eb1943469799a58ba9e0fc406d85a010c Mon Sep 17 00:00:00 2001
From: Chris Double <chris.double@double.co.nz>
Date: Wed, 28 Nov 2007 11:25:34 +1300
Subject: [PATCH] add ebnf>quot

---
 extra/peg/ebnf/ebnf.factor | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/extra/peg/ebnf/ebnf.factor b/extra/peg/ebnf/ebnf.factor
index bb0e85c45a..a402a0fd73 100644
--- a/extra/peg/ebnf/ebnf.factor
+++ b/extra/peg/ebnf/ebnf.factor
@@ -8,12 +8,14 @@ TUPLE: ebnf-terminal symbol ;
 TUPLE: ebnf-choice options ;
 TUPLE: ebnf-sequence elements ;
 TUPLE: ebnf-rule symbol elements ;
+TUPLE: ebnf rules ;
 
 C: <ebnf-non-terminal> ebnf-non-terminal
 C: <ebnf-terminal> ebnf-terminal
 C: <ebnf-choice> ebnf-choice
 C: <ebnf-sequence> ebnf-sequence
 C: <ebnf-rule> ebnf-rule
+C: <ebnf> ebnf
 
 GENERIC: ebnf-compile ( ast -- quot )
 
@@ -24,7 +26,7 @@ M: ebnf-terminal ebnf-compile ( ast -- quot )
 
 M: ebnf-non-terminal ebnf-compile ( ast -- quot )
   [
-    ebnf-non-terminal-symbol in get lookup ,
+    ebnf-non-terminal-symbol , \ in , \ get , \ lookup , \ execute ,
   ] [ ] make ;
 
 M: ebnf-choice ebnf-compile ( ast -- quot )
@@ -53,6 +55,13 @@ M: ebnf-rule ebnf-compile ( ast -- quot )
     ebnf-rule-elements ebnf-compile , \ define-compound , 
   ] [ ] make ;
 
+M: ebnf ebnf-compile ( ast -- quot )
+  [
+    ebnf-rules [
+      ebnf-compile %
+    ] each 
+  ] [ ] make ;
+
 DEFER: 'rhs'
 
 : 'non-terminal' ( -- parser )
@@ -90,3 +99,13 @@ DEFER: 'rhs'
   "=" token sp hide 
   'rhs' 
   3array seq [ first2 <ebnf-rule> ] action ;
+
+: 'ebnf' ( -- parser )
+  'rule' sp ";" token sp hide list-of [ <ebnf> ] action ;
+
+: ebnf>quot ( string -- quot )
+  'ebnf' parse [
+     parse-result-ast ebnf-compile  
+   ] [
+    f
+   ] if* ;
\ No newline at end of file