`BLD_doc.grm`

1. [See source files here.] This is a Jacc grammar for the so-called presentation syntax of the RIF Basic Logic Dialext (BLD) developed as a result of the activities of the RIF Working Group (Phase 1). #### Specific relevant sections in the RIF WG reference documents RIF Basic Logic Dialect (BLD): EBNF for the BLD Condition Language EBNF for the BLD Rule Language Translation rules for BLD XML Serialization This Jacc grammar specification given here is a literal transcription of the BNF rules given in the above references. There are two sets of grammar rules: the rules for the Basic Logic Condition (BLC) language; and, the rules for the Basic Logic Rule language (BLR). These two grammars expressed in Yacc form are: ### BLD Condition Language
         Formula
           : Atomic
           | AND OPENPAR Formulas_opt CLOSEPAR
           | OR OPENPAR Formulas_opt CLOSEPAR
           | EXISTS Vars OPENPAR Formula CLOSEPAR
           | EXTERNAL OPENPAR Atom CLOSEPAR
           ;

         Atomic
           : Atom
           | Equal
           | Member
           | Subclass
           | Frame
           ;

         Atom
           : UniTerm
           ;

         UniTerm
           : Const OPENPAR UniTermBody CLOSEPAR
           ;

         Equal
           : Term EQUAL Term
           ;

         Member
           : Term MEMBER Term
           ;

         Subclass
           : Term SUBCLASS Term
           ;

         Frame
           : Term OPENBRA FrameAttributes_opt CLOSEBRA
           ;

         Term
           : Const
           | Var
           | Expr
           | EXTERNAL OPENPAR Expr CLOSEPAR
           ;

         Expr
           : UniTerm
           ;

         Const
           : STRING LEXSPACE SymSpace
           ;

         Var
           : VARIABLE
           ;

         UniTermBody
           : Terms_opt
           | TermAttributes_opt
           ;

         TermAttributes_opt
           : // empty
           | TermAttributes
           ;

         TermAttributes
           : TermAttribute
           | TermAttributes TermAttribute
           ;

         TermAttribute
           : Const ARROW Term
           ;

         FrameAttributes_opt
           : // empty
           | FrameAttributes
           ;

         FrameAttributes
           : FrameAttribute
           | FrameAttributes FrameAttribute
           ;

         FrameAttribute
           : Term ARROW Term
           ;

         Formulas_opt
           : // empty
           | Formulas
           ;

         Formulas
           : Formula
           | Formulas Formulas
           ;

         Terms_opt
           : // empty
           | Terms_opt Term
           ;

         Vars
           : Var
           | Vars Var
           ;

         SymSpace
           : IDENTIFIER COLON IDENTIFIER
           ;
2. ### BLD Rule Language
         Group
           : GROUP Meta_opt OPENPAR RuleSet_opt CLOSEPAR
           ;

         Meta
           : Frame
           ;

         Rule
           : Clause
           | FORALL Vars_opt OPENPAR Clause CLOSEPAR
           ;

         Clause
           : Atomic
           | Implies
           ;

         Implies
           : Atomic IF Formula
           ;

         RuleSet_opt
           : // empty
           | RuleSet
           ;

         RuleSet
           : RuleOrGroup
           | RuleSet RuleOrGroup
           ;

         RuleOrGroup
           : Rule
           | Group
           ;

         Meta_opt
           : // empty
           | Meta
           ;

         Vars_opt
           : // empty
           | Vars
           ;
This version of the BLD grammar is annotated for simple XML serialization as per the scheme specified in the current BLD document. If and where we may diverge with what is the BLD document, it will be indicated in what mannner and why. This HTML file is the root of a hyperlinked documentation allowing one to explore the Jacc grammar for BLD 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 - i.e., without semantic actions. This documentation is generated by Jacc from the Jacc grammar specified in file `BLD.grm` (i.e., with the command "`jacc -doc BLD`"). Along with this Jacc grammar file, there are other supporting source files. Essentially, the format of a Jacc grammar is that of a Yacc grammar. As in Yacc, Jacc rules may be annotated with semantic actions in the form of Java 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 described by this Jacc grammar for a XML annotation language for a Jacc grammar! (Yes - it generates a a meta-metaparser.) For example, the annotated rule:
      QUANTIF
         : 'Exists' Var_plus '(' CONDIT ')'
         [
             nsprefix   : hrl
             localname  : quantifier
             attributes : {kind="existential"}
             children   : (2,4)
         ]
         ;
means that an AST node for this rule will be serialized thus:
       <hrl:quantifier kind="existential">
         (XML serialization of Var_plus)
         (XML serialization of CONDIT)
       </hrl:quantifier>
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). See `JaccXmlAnnotations.doc` for more details. For example, see the two test files `test1.bld` and `test2.bld`. Running the command `bld` on them produces the XML trees shown in `test1.xml` and `test2.xml`.

This file was generated on Tue Oct 07 11:25:20 CEST 2008 from file `BLD_doc.grm`
by the `ilog.language.tools.Hilite` Java tool written by Hassan Aït-Kaci