 TUPLE: ebnf-sequence elements ;
 TUPLE: ebnf-repeat0 group ;
 TUPLE: ebnf-rule symbol elements ;
+TUPLE: ebnf-action quot ;
 TUPLE: ebnf rules ;
 
 C: <ebnf-non-terminal> ebnf-non-terminal

C: <ebnf-sequence> ebnf-sequence
C: <ebnf-repeat0> ebnf-repeat0
C: <ebnf-rule> ebnf-rule
C: <ebnf> ebnf

GENERIC: ebnf-compile ( ast -- quot )

  "}" token sp hide 
  3array seq [ first <ebnf-repeat0> ] action ;

: 'action' ( -- parser )
  "=>" token hide
  "[" token sp hide
  "]." token ensure-not [ drop t ] satisfy 2array seq [ first ] action repeat1 [ >string ] action
  "]" token "." token ensure 2array seq sp hide
  4array seq [ "[ " swap first append " ]" append eval <ebnf-action> ] action ;

: 'rhs' ( -- parser )
  'repeat0'
  'sequence'
  'choice'
  'element'
  4array choice 'action' sp optional 2array seq ;
 
: 'rule' ( -- parser )
  'non-terminal' [ ebnf-non-terminal-symbol ] action 
  "=" token sp hide 
