 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 )
 

  [
    dup ebnf-rule-symbol , \ in , \ get , \ create , 
    ebnf-rule-elements ebnf-compile , \ define-compound , 
  ] [ ] make ;

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* ;