BLD.grm

// FILE. . . . . /home/hak/ilt/src/ilog/rif/BLD.grm
// EDIT BY . . . Hassan Ait-Kaci
// ON MACHINE. . 4j4zn71
// STARTED ON. . Tue Apr 01 13:17:21 2008

// Last modified on Wed Oct 01 09:36:10 2008 by hak

//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//

%access public

// Declare the Java package for the parser generated from this grammar:
%package ilog.rif.bld;

// Include the javadoc documentation for this grammar:
%include BLD_doc.grm

// Include the BLD condition and rule languages' reserved keywords:
%include Keywords.grm
// Include java Code for setting params and showing xml serialization:
%include ParserCode.grm

// Declare the grammar start symbol to be 'RifDocument':
%start RifDocument

// Declare other parse %roots ...

// Declare the 'rif', 'xsi', and 'xs' XML namespaces:
%xmlns "rif" "http://www.w3.org/2007/rif#"
%xmlns "xsi" "http://www.w3.org/2001/XMLSchema-instance"
%xmlns "xs"  "http://www.w3.org/2001/XMLSchema#"


// Define the XML tree root element to be 'rif:document':
%xmlroot "Document"

// Terminals:



The terminal symbols are:

Token Value
STRING double-quoted string
VARIABLE max-length sequence of non-special chars starting with a '?'
IDENTIFIER max-length sequence of non-special chars
OR 'Or'
AND 'And'
FORALL 'Forall'
EXISTS 'Exists'
GROUP 'Group'
EXTERNAL 'External'
IF ':-'
ARROW '->'
LEXSPACE '^^'
EQUAL '='
MEMBER '#'
SUBCLASS '##'
COLON ':'
OPENPAR '('
CLOSEPAR ')'
OPENBRA '['
CLOSEBRA ']'

Important Notes:

  • VARIABLE is a token recognized thanks to its leading '?' but the token returned by the lexer suppresses this leading '?'. This means that '?' is not a separate punctuation mark as shown by the EBNF.

  • Using STRING dispenses from the spurious "..."^^ notation, making '^^' an infix operator. In other words, the initial and final double quotes are part of the token itself an need not appear at the grammar level.

  • IDENTIFIER is any maximal sequence of non-separator not-punctuation unicode characters that does not start with a '?'.

  • For now, a SymSpace is simply parsed as a pair of IDENTIFIERs separated by a colon (':'). This means that ':' is a separate punctuation mark unlike what is shown by the EBNF.



%token OPENPAR CLOSEPAR OPENBRA CLOSEBRA
%token GROUP EXTERNAL LEXSPACE COLON
%token OR AND FORALL EXISTS
%token IF ARROW EQUAL MEMBER SUBCLASS
%token VARIABLE STRING IDENTIFIER

// Define the XML serialization info for terminal symbol 'VARIABLE':
%xmlinfo VARIABLE   [ L:"Var"  C:($VALUE) ]

// Define the XML serialization info for terminal symbol 'IDENTIFIER':
%xmlinfo IDENTIFIER [ L:"Id"   C:($VALUE) ]

// Define the XML serialization info for terminal symbol 'STRING':
%xmlinfo STRING     [ L:"Str"  C:($VALUE) ]

%%  
////////////////////////////////////////////////////////////////////////
// Grammar Rules:
////////////////////////////////////////////////////////////////////////

// Including grammar for the BLD Rule Language:
%include BLR.grm
// Including grammar for the BLD Condition Language:
%include BLC.grm



Root grammar rule for Basic Logic Dialect (BLD):


RifDocument
  : OuterDocument
  { showXml(); }  // show the XML tree
  ;

OuterDocument
  : Group
  [ L:"payload" C:(1) ]
  ;

%%

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


This file was generated on Thu Feb 17 16:55:59 PST 2011 from file BLD.grm
by the ilog.language.tools.Hilite Java tool written by Hassan Aït-Kaci