/*========================================================================
Copyright (C) 2006 by Geir-Tore Lindsve, Torbjørn Meistad
and Yngve Raudberget, hereby refered to as "the authors".
All rights reserved
Permission is hereby granted, without written agreement and without
license or royalty fees, to use, reproduce, prepare derivative
works, distribute, and display this software and its documentation
for NONCOMMERCIAL RESEARCH AND EDUCATIONAL PURPOSES, provided
that (1) the above copyright notice and the following two paragraphs
appear in all copies of the source code and (2) redistributions,
including without limitation binaries, reproduce these notices in
the supporting documentation.
IN NO EVENT SHALL THE AUTHORS, OR DISTRIBUTORS OF THIS SOFTWARE
BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL,
OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE
AND ITS DOCUMENTATION, EVEN IF THE AUTHORS OR ANY OF THE ABOVE
PARTIES HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE AUTHORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO
OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
MODIFICATIONS.
========================================================================*/
using System;
using System.IO;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Xml;
using com.calitha.goldparser.lalr;
using com.calitha.commons;
using CLab.Exceptions;
namespace com.calitha.goldparser
{
///
/// Internal exception class used by the parser engine
///
[Serializable()]
public class SymbolException : System.Exception
{
///
/// Initializes a new instance of the class.
///
/// The exception message which describes the reason for the exception.
public SymbolException(string message)
: base(message)
{
}
///
/// Initializes a new instance of the class.
///
/// The exception message which describes the reason for the exception.
/// The inner exception.
public SymbolException(string message,
Exception inner)
: base(message, inner)
{
}
///
/// Initializes a new instance of the class.
///
/// The that holds the serialized object data about the exception being thrown.
/// The that contains contextual information about the source or destination.
/// The class name is null or is zero (0).
/// The info parameter is null.
protected SymbolException(SerializationInfo info,
StreamingContext context)
: base(info, context)
{
}
}
///
/// Internal exception class used by the parser engine
///
[Serializable()]
public class RuleException : System.Exception
{
///
/// Initializes a new instance of the class.
///
/// The exception message which describes the reason for the exception.
public RuleException(string message)
: base(message)
{
}
///
/// Initializes a new instance of the class.
///
/// The exception message which describes the reason for the exception.
/// The inner exception.
public RuleException(string message,
Exception inner)
: base(message, inner)
{
}
///
/// Initializes a new instance of the class.
///
/// The that holds the serialized object data about the exception being thrown.
/// The that contains contextual information about the source or destination.
/// The class name is null or is zero (0).
/// The info parameter is null.
protected RuleException(SerializationInfo info,
StreamingContext context)
: base(info, context)
{
}
}
enum SymbolConstants : int
{
SYMBOL_EOF = 0, // (EOF)
SYMBOL_ERROR = 1, // (Error)
SYMBOL_WHITESPACE = 2, // (Whitespace)
SYMBOL_COMMENTEND = 3, // (Comment End)
SYMBOL_COMMENTLINE = 4, // (Comment Line)
SYMBOL_COMMENTSTART = 5, // (Comment Start)
SYMBOL_MINUS = 6, // '-'
SYMBOL_EXCLAM = 7, // '!'
SYMBOL_PERCENT = 8, // '%'
SYMBOL_LPARAN = 9, // '('
SYMBOL_RPARAN = 10, // ')'
SYMBOL_TIMES = 11, // '*'
SYMBOL_COMMA = 12, // ','
SYMBOL_DOT = 13, // '.'
SYMBOL_DIV = 14, // '/'
SYMBOL_SEMI = 15, // ';'
SYMBOL_LBRACKET = 16, // '['
SYMBOL_RBRACKET = 17, // ']'
SYMBOL_LBRACE = 18, // '{'
SYMBOL_RBRACE = 19, // '}'
SYMBOL_PLUS = 20, // '+'
SYMBOL_LT = 21, // '<'
SYMBOL_GT = 22, // '>'
SYMBOL_AND = 23, // AND
SYMBOL_BOOL = 24, // BOOL
SYMBOL_EQ = 25, // EQ
SYMBOL_GTE = 26, // GTE
SYMBOL_ID = 27, // ID
SYMBOL_IMPL = 28, // IMPL
SYMBOL_LTE = 29, // LTE
SYMBOL_NE = 30, // NE
SYMBOL_NUMBER = 31, // NUMBER
SYMBOL_OR = 32, // OR
SYMBOL_RULE = 33, // RULE
SYMBOL_STRING = 34, // STRING
SYMBOL_TYPE = 35, // TYPE
SYMBOL_VARIABLE = 36, // VARIABLE
SYMBOL_CP = 37, //
SYMBOL_EXP = 38, //
SYMBOL_EXP2 = 39, //
SYMBOL_EXP3 = 40, //
SYMBOL_EXP4 = 41, //
SYMBOL_EXP5 = 42, //
SYMBOL_EXP6 = 43, //
SYMBOL_EXP7 = 44, //
SYMBOL_EXP8 = 45, //
SYMBOL_EXP9 = 46, //
SYMBOL_ID2 = 47, //
SYMBOL_IDLST = 48, //
SYMBOL_INTEGER = 49, //
SYMBOL_NUMBER2 = 50, //
SYMBOL_RULEDECL = 51, //
SYMBOL_RULEDECLS = 52, //
SYMBOL_TYPEDECL = 53, //
SYMBOL_TYPEDECLS = 54, //
SYMBOL_VARDECL = 55, //
SYMBOL_VARDECLS = 56, //
SYMBOL_VARTYPE = 57 //
};
enum RuleConstants : int
{
RULE_CP_TYPE_VARIABLE_RULE = 0, // ::= TYPE VARIABLE RULE
RULE_CP_VARIABLE_RULE = 1, // ::= VARIABLE RULE
RULE_TYPEDECLS = 2, // ::=
RULE_TYPEDECLS2 = 3, // ::=
RULE_TYPEDECL_LBRACKET_DOT_DOT_RBRACKET_SEMI = 4, // ::= '[' '.' '.' ']' ';'
RULE_TYPEDECL_LBRACE_RBRACE_SEMI = 5, // ::= '{' '}' ';'
RULE_VARDECLS = 6, // ::=
RULE_VARDECLS2 = 7, // ::=
RULE_VARDECL_SEMI = 8, // ::= ';'
RULE_VARTYPE_BOOL = 9, // ::= BOOL
RULE_VARTYPE = 10, // ::=
RULE_IDLST = 11, // ::=
RULE_IDLST_COMMA = 12, // ::= ','
RULE_RULEDECLS = 13, // ::=
RULE_RULEDECLS2 = 14, // ::=
RULE_RULEDECL_SEMI = 15, // ::= ';'
RULE_EXP_OR = 16, // ::= OR
RULE_EXP = 17, // ::=
RULE_EXP2_AND = 18, // ::= AND
RULE_EXP2 = 19, // ::=
RULE_EXP3_NE = 20, // ::= NE
RULE_EXP3_EQ = 21, // ::= EQ
RULE_EXP3 = 22, // ::=
RULE_EXP4_LTE = 23, // ::= LTE
RULE_EXP4_GTE = 24, // ::= GTE
RULE_EXP4_LT = 25, // ::= '<'
RULE_EXP4_GT = 26, // ::= '>'
RULE_EXP4 = 27, // ::=
RULE_EXP5_IMPL = 28, // ::= IMPL
RULE_EXP5 = 29, // ::=
RULE_EXP6_MINUS = 30, // ::= '-'
RULE_EXP6_PLUS = 31, // ::= '+'
RULE_EXP6 = 32, // ::=
RULE_EXP7_PERCENT = 33, // ::= '%'
RULE_EXP7_DIV = 34, // ::= '/'
RULE_EXP7_TIMES = 35, // ::= '*'
RULE_EXP7 = 36, // ::=
RULE_EXP8_MINUS = 37, // ::= '-'
RULE_EXP8_EXCLAM = 38, // ::= '!'
RULE_EXP8 = 39, // ::=
RULE_EXP9 = 40, // ::=
RULE_EXP92 = 41, // ::=
RULE_EXP9_LPARAN_RPARAN = 42, // ::= '(' ')'
RULE_ID_ID = 43, // ::= ID
RULE_ID_STRING = 44, // ::= STRING
RULE_INTEGER = 45, // ::=
RULE_INTEGER_MINUS = 46, // ::= '-'
RULE_NUMBER_NUMBER = 47 // ::= NUMBER
};
///
/// Token based parser using the GOLD Parsing system.
/// Grammar tables for parsing are compiled from the parser grammar located in the doc folder.
/// The compiled grammar is located in the Auxiliary folder and is integrated in the compiled binaries.
///
///
/// This source file was initially generated by the GOLD Parsing system, based on grammar definition.
/// Not all placeholder code has been replaced/removed to facilitate further use.
///
/// GOLD Parsing system
public class TokenParser
{
private LALRParser parser;
private List