//  FILE. . . . . /home/hak/ilt/src/ilog/rcl/RCL.grm
//  EDIT BY . . . Hassan Ait-Kaci
//  ON MACHINE. . Latitude407.Ilog.Biz
//  STARTED ON. . Wed Apr 26 10:17:23 2006

//  Last modified on Mon Oct 23 10:20:51 2006 by hak

/**
 * This is a Jacc grammar for RIF Condition Language (RCL) defined as a
 * combination of partial grammars.
 * 
 * <p>
 * 
 * It has evolved out of the first-cut grammar for a minimal
 * "human-readable" syntax, which is described in the proposal submitted
 * to the W3C Working Group on the Rule Interchange Format (RIF) by
 * Harold Boley <i>et al.</i>, on April 23, 2006. It is meant to be able
 * to express the abstract syntax form taken by <i>conditions</i> of the
 * rules that appear to be common to a reasonably large variety of
 * families of rule languages. The proposal in question is available
 * from the public RIF WG mail archive: <a
 * href="http://lists.w3.org/Archives/Public/public-rif-wg/2006Apr/0068.html">
 * [RIF] Extensible Design</a>.  This Jacc grammar specification is a
 * literal transcription of the BNF rules given in the above reference.
 *
 * <p>
 *    
 * This version of the RCL grammar is annotated for simple XML serialization.
 *
 * <p>
 *
 * We give below the Jacc grammar rules for RCL. Note that the grammar
 * their combination defines is LALR(1).
 *
 * <p>
 *
 * This HTML file is the root of a hyperlinked documentation allowing one
 * to explore the grammar via navigation through its elements - rules,
 * terminal and non-terminal symbols. The comments accompanying some rules
 * come from the original documents.  It also contains the pure Yacc rules.
 * The documentation is generated by Jacc from the Jacc grammar specified
 * in file <a href="RCL.html"><tt>RCL.grm</tt></a>. Along with this Jacc
 * grammar file, there are other <a href="index.html">supporting source
 * files</a>.
 *
 * <p>
 *
 * Essentially, the rule format is that of Yacc. As in Yacc, Jacc rules may
 * be annotated with semantic actions, in the form of code involving the
 * rule's RHS constituents (denoted by <tt>&#36;1</tt>, <tt>&#36;2</tt>,
 * ..., <tt>&#36;n</tt> - the so-called pseudo-variables where the index
 * <tt>n</tt> in <tt>&#36;n</tt> refers to the order of RHS
 * constituents. Such actions appear between curly braces ('<tt>{</tt>' and
 * '<tt>}</tt>') wherever a symbol may appear in a rule's RHS.
 *
 * Jacc also allows an additional form of annotation in the RHS of a rule
 * to indicate the XML serialization pattern of the abstract syntactic
 * tree (AST) node corresponding to a derivation with this rule. This XML
 * serialization meta-annotation comes between square brackets
 * ('<tt>[</tt>' and '<tt>]</tt>') and is of the form:
 *
 * <pre>
 * [ XmlTag n_1 ... n_k ]
 * </pre>
 *
 * where <code>XmlTag</code> is an identifier to use as XML tag for this
 * node in the XML serialization of the AST, and the <code>n_k</code>'s
 * are a sequence of numbers denoting positions of symbols in the RHS of
 * the rule (as for pseudo-variables but without <tt>'&#36;'</tt>). The
 * number sequence indicates the order in which subnodes are to be
 * serialized. For example, the annotated rule:
 *
 * <pre>
 * QUANTIF
 *    : 'Exists' Var_plus '(' CONDIT ')'
 *      [ Exists 2 4 ]
 *    ;
 * </pre>
 *
 * means that an AST node for this rule will be serialized thus:
 *
 * <pre>
 *  &lt;Exists&gt;
 *    (Xml serialization of Var_plus)
 *    (Xml serialization of CONDIT)
 *  &lt;/Exists&gt;
 * </pre>
 *
 * Rules without XML serialization annotation follow a default behavior:
 * the serialization is the concatenation of those of its RHS's
 * constituents, eliminating punctuation tokens (<i>i.e.</i>, empty nodes
 * and literal tokens - namely, tokens that do not carry a value).
 *
 * <p>
 *
 * For example, see the two test files <a href="Test.rcl"><tt>Test.rcl</tt></a>
 * and <a href="Test2.rcl"><tt>Test2.rcl</tt></a>.  
 * Running the command <a href="rcl"><tt>rcl</tt></a> on them produces the
 * output shown in <a href="Test.run"><tt>Test.run</tt></a>.  
 */

////////////////////////////////////////////////////////////////////////

%package ilog.rif;

%include keywords.grm	// RCL language reserved keywords  
%include ParserCode.grm	// Code for setting params and showing xml serialization

%token Name Fun Rel Value Var // NB: Var is a token (i.e., the '?' is part of it)

%start RCL

%%  

RCL
  : CONDIT { showXml(); }
    /**
     * This rule is just a root for the non-terminal symbol denoting
     * having recognized an RCL construct. For now, it recognizes a RIF
     * condition (a $CONDIT$) as defined in <a
     * href="http://lists.w3.org/Archives/Public/public-rif-wg/2006Apr/0068.html">
     * [RIF] Extensible Design</a>. Its semantic action amounts to print
     * out the XML serialization of the parsed $CONDIT$ construct on the
     * standard output.
     */
  ;

%include RCL_basis.grm
%include RCL_valobj.grm // %include RCL_constant.grm
%include RCL_forall.grm
%include RCL_neg.grm
%include RCL_naf.grm
%include RCL_nafneg.grm

%%
