Main Documentation for grammar RCL.grm


Description

This is a Jacc grammar for the RIF Condition Language (RCL), whose BNF grammar for a minimal "human-readable" syntax is described in the proposal submitted to the W3C Working Group on the Rule Interchange Format (RIF) by Harold Boley et al., on April 23, 2006. It is meant to be able to express the abstract syntax form taken by conditions 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: [RIF] Extensible Design. This Jacc grammar specification is a literal transcription of the BNF rules given in the above reference.

This version of the RCL grammar is annotated for XML seralization.

We give below the Jacc grammar rules for RCL. Note that the grammar they define is LALR(1).

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 [RIF] Extensible Design mail. It also contains the pure Yacc rules. The documentation is generated by Jacc from the Jacc grammar specified in file RCL.grm. Along with this Jacc grammar file, there are other supporting source files.

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 $1, $2, ..., $n - the so-called pseudo-variables where the index n in $n refers to the order of RHS constituents. Such actions appear between curly braces ('{' and '}') 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 ('[' and ']') and is of the form:

  [ XmlTag n_1 ... n_k ]
  
where XmlTag is an identifier to use as XML tag for this node in the XML serailization of the AST, and the n_k's are a sequence of numbers denoting positions of symbols in the RHS of the rule (as for pseudo-varsiables but without '$'). The number sequence indicates the order in which subnodes are to be serialized. For example, the annotated rule:
  QUANTIF
     : 'Exists' Var_plus '(' CONDIT ')'
       [ Exists 2 4 ]
     ;
  
means that an AST node for this rule will be serialized thus:
   <Exists>
     (Xml serialization of Var_plus)
     (Xml serialization of CONDIT)
   </Exists>
  
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.e., empty nodes and literal tokens - namely, tokens that do not carry a value). N.B.: The rules below (and supporting tokenizer) are of course a bare skeleton - yet it works! It parses correct RCL CONDIT constructs and produces their XML serializations. Incorrectly formed constructs are rejected and produce a fatal syntx error - no error recovery is attempted. Of course, error recovery should be supported for more informative description of cause and location - Jacc can easily accommodate such a scheme with its built-in error recovery mechanism. If this primeval RCL should evolve into more elaborate languages akin to this RCL, this should and would be done, of course.

For example, see the two test files Test.rcl and Test2.rcl. Running the command rcl on them produces the output shown in Test.run.


Copyright © 2006 ILOG, Inc.; All Rights Reserved.