   H{ } clone dup dup [ parser set swap (transform) main set ] bind ;
 
 M: ebnf (transform) ( ast -- parser )
-  ebnf-rules [ (transform) ] map peek ;
+  rules>> [ (transform) ] map peek ;
   
 M: ebnf-rule (transform) ( ast -- parser )
-  dup ebnf-rule-elements (transform) [
-    swap ebnf-rule-symbol set
+  dup elements>> (transform) [
+    swap symbol>> set
   ] keep ;
 
 M: ebnf-sequence (transform) ( ast -- parser )
-  ebnf-sequence-elements [ (transform) ] map seq ;
+  elements>> [ (transform) ] map seq ;
 
 M: ebnf-choice (transform) ( ast -- parser )
-  ebnf-choice-options [ (transform) ] map choice ;
+  options>> [ (transform) ] map choice ;
 
 M: ebnf-any-character (transform) ( ast -- parser )
   drop any-char ;
 
 M: ebnf-range (transform) ( ast -- parser )
-  ebnf-range-pattern range-pattern ;
+  pattern>> range-pattern ;
+
+: transform-group ( ast -- parser ) 
+  #! convert a ast node with groups to a parser for that group
+  group>> (transform) ;
 
 M: ebnf-ensure (transform) ( ast -- parser )
-  ebnf-ensure-group (transform) ensure ;
+  transform-group ensure ;
 
 M: ebnf-ensure-not (transform) ( ast -- parser )
-  ebnf-ensure-not-group (transform) ensure-not ;
+  transform-group ensure-not ;
 
 M: ebnf-repeat0 (transform) ( ast -- parser )
-  ebnf-repeat0-group (transform) repeat0 ;
+  transform-group repeat0 ;
 
 M: ebnf-repeat1 (transform) ( ast -- parser )
-  ebnf-repeat1-group (transform) repeat1 ;
+  transform-group repeat1 ;
 
 M: ebnf-optional (transform) ( ast -- parser )
-  ebnf-optional-elements (transform) optional ;
+  transform-group optional ;
 
 M: ebnf-action (transform) ( ast -- parser )
-  [ ebnf-action-parser (transform) ] keep
-  ebnf-action-code string-lines [ parse-lines ] with-compilation-unit action ;
+  [ parser>> (transform) ] keep
+  code>> string-lines [ parse-lines ] with-compilation-unit action ;
 
 M: ebnf-terminal (transform) ( ast -- parser )
-  ebnf-terminal-symbol token sp ;
+  symbol>> token sp ;
 
 M: ebnf-non-terminal (transform) ( ast -- parser )
-  ebnf-non-terminal-symbol  [
+  symbol>>  [
     , parser get , \ at ,  
   ] [ ] make delay sp ;
 

USING: kernel compiler.units parser words arrays strings math.parser sequences 
       quotations vectors namespaces math assocs continuations peg
       peg.parsers unicode.categories multiline combinators.lib 
       splitting ;
IN: peg.ebnf

TUPLE: ebnf-non-terminal symbol ;

 
: 'rule' ( -- parser )
  [
    'non-terminal' [ symbol>> ] action  ,
    "=" syntax  ,
    'choice'  ,
  ] seq* [ first2 <ebnf-rule> ] action ;
