 ! Copyright (C) 2007 Chris Double.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: kernel compiler.units parser words arrays strings math.parser sequences 
+USING: kernel compiler.units words arrays strings math.parser sequences 
        quotations vectors namespaces math assocs continuations peg
        peg.parsers unicode.categories multiline combinators combinators.lib 
        splitting accessors effects sequences.deep peg.search inference 
-       io.streams.string io prettyprint ;
+       io.streams.string io prettyprint parser ;
 IN: peg.ebnf
+
+: rule ( name word -- parser )
+  #! Given an EBNF word produced from EBNF: return the EBNF rule
+  "ebnf-parser" word-prop at ;
 
 TUPLE: ebnf-non-terminal symbol ;
 TUPLE: ebnf-terminal symbol ;
+TUPLE: ebnf-foreign word rule ;
 TUPLE: ebnf-any-character ;
 TUPLE: ebnf-range pattern ;
 TUPLE: ebnf-ensure group ;

    [ 
      'non-terminal' ,
      'terminal' ,
      'range-parser' ,
      'any-character' ,
    ] choice* ,

  ";EBNF" parse-multiline-string replace-escapes
  ebnf>quot swapd 1 1 <effect> define-declared "ebnf-parser" set-word-prop ; parsing

