682 lines
30 KiB
C#
682 lines
30 KiB
C#
using System.IO;
|
|||
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
public class MyParser
|
||
|
|
{
|
||
|
|
private GOLD.Parser parser = new GOLD.Parser();
|
||
|
|
|
||
|
|
private enum SymbolIndex
|
||
|
|
{
|
||
|
|
@Eof = 0, // (EOF)
|
||
|
|
@Error = 1, // (Error)
|
||
|
|
@Whitespace = 2, // Whitespace
|
||
|
|
@Minus = 3, // '-'
|
||
|
|
@Minusminus = 4, // '--'
|
||
|
|
@Exclam = 5, // '!'
|
||
|
|
@Exclameq = 6, // '!='
|
||
|
|
@Quote = 7, // '"'
|
||
|
|
@Percent = 8, // '%'
|
||
|
|
@Percenteq = 9, // '%='
|
||
|
|
@Amp = 10, // '&'
|
||
|
|
@Ampamp = 11, // '&&'
|
||
|
|
@Ampeq = 12, // '&='
|
||
|
|
@Lparen = 13, // '('
|
||
|
|
@Rparen = 14, // ')'
|
||
|
|
@Times = 15, // '*'
|
||
|
|
@Timeseq = 16, // '*='
|
||
|
|
@Comma = 17, // ','
|
||
|
|
@Div = 18, // '/'
|
||
|
|
@Diveq = 19, // '/='
|
||
|
|
@Colon = 20, // ':'
|
||
|
|
@Question = 21, // '?'
|
||
|
|
@Backslash = 22, // '\'
|
||
|
|
@Caret = 23, // '^'
|
||
|
|
@Careteq = 24, // '^='
|
||
|
|
@Pipe = 25, // '|'
|
||
|
|
@Pipepipe = 26, // '||'
|
||
|
|
@Pipeeq = 27, // '|='
|
||
|
|
@Tilde = 28, // '~'
|
||
|
|
@Plus = 29, // '+'
|
||
|
|
@Plusplus = 30, // '++'
|
||
|
|
@Pluseq = 31, // '+='
|
||
|
|
@Lt = 32, // '<'
|
||
|
|
@Ltlt = 33, // '<<'
|
||
|
|
@Ltlteq = 34, // '<<='
|
||
|
|
@Lteq = 35, // '<='
|
||
|
|
@Eq = 36, // '='
|
||
|
|
@Minuseq = 37, // '-='
|
||
|
|
@Eqeq = 38, // '=='
|
||
|
|
@Gt = 39, // '>'
|
||
|
|
@Minusgt = 40, // '->'
|
||
|
|
@Gteq = 41, // '>='
|
||
|
|
@Gtgt = 42, // '>>'
|
||
|
|
@Gtgteq = 43, // '>>='
|
||
|
|
@A = 44, // A
|
||
|
|
@Charliteral = 45, // CharLiteral
|
||
|
|
@Decliteral = 46, // DecLiteral
|
||
|
|
@F = 47, // F
|
||
|
|
@False = 48, // false
|
||
|
|
@Hexliteral = 49, // HexLiteral
|
||
|
|
@Identifier = 50, // Identifier
|
||
|
|
@Realliteral = 51, // RealLiteral
|
||
|
|
@Stringliteral = 52, // StringLiteral
|
||
|
|
@True = 53, // true
|
||
|
|
@Addexp = 54, // <Add Exp>
|
||
|
|
@Andexp = 55, // <And Exp>
|
||
|
|
@Args = 56, // <Args>
|
||
|
|
@Assignop = 57, // <AssignOp>
|
||
|
|
@Compareexp = 58, // <Compare Exp>
|
||
|
|
@Conditionalexp = 59, // <Conditional Exp>
|
||
|
|
@Equalityexp = 60, // <Equality Exp>
|
||
|
|
@Expression = 61, // <Expression>
|
||
|
|
@Expressionlist = 62, // <Expression List>
|
||
|
|
@Formalparams = 63, // <FormalParams>
|
||
|
|
@Formalparamslist = 64, // <FormalParamsList>
|
||
|
|
@Literal = 65, // <Literal>
|
||
|
|
@Logicalandexp = 66, // <Logical And Exp>
|
||
|
|
@Logicalorexp = 67, // <Logical Or Exp>
|
||
|
|
@Logicalxorexp = 68, // <Logical Xor Exp>
|
||
|
|
@Match = 69, // <Match>
|
||
|
|
@Matchleftcontext = 70, // <MatchLeftContext>
|
||
|
|
@Matchprime = 71, // <MatchPrime>
|
||
|
|
@Matchrightcontext = 72, // <MatchRightContext>
|
||
|
|
@Multexp = 73, // <Mult Exp>
|
||
|
|
@Opname = 74, // <OpName>
|
||
|
|
@Opsleft = 75, // <OpsLeft>
|
||
|
|
@Opsleftlist = 76, // <OpsLeftList>
|
||
|
|
@Opsright = 77, // <OpsRight>
|
||
|
|
@Opsrightlist = 78, // <OpsRightList>
|
||
|
|
@Orexp = 79, // <Or Exp>
|
||
|
|
@Primary = 80, // <Primary>
|
||
|
|
@Primaryexp = 81, // <Primary Exp>
|
||
|
|
@Replace = 82, // <Replace>
|
||
|
|
@Rule = 83, // <Rule>
|
||
|
|
@Shiftexp = 84, // <Shift Exp>
|
||
|
|
@Unaryexp = 85 // <Unary Exp>
|
||
|
|
}
|
||
|
|
|
||
|
|
private enum ProductionIndex
|
||
|
|
{
|
||
|
|
@Assignop_Eq = 0, // <AssignOp> ::= '='
|
||
|
|
@Assignop_Minusgt = 1, // <AssignOp> ::= '->'
|
||
|
|
@Literal_True = 2, // <Literal> ::= true
|
||
|
|
@Literal_False = 3, // <Literal> ::= false
|
||
|
|
@Literal_Decliteral = 4, // <Literal> ::= DecLiteral
|
||
|
|
@Literal_Hexliteral = 5, // <Literal> ::= HexLiteral
|
||
|
|
@Literal_Realliteral = 6, // <Literal> ::= RealLiteral
|
||
|
|
@Literal_Charliteral = 7, // <Literal> ::= CharLiteral
|
||
|
|
@Literal_Stringliteral = 8, // <Literal> ::= StringLiteral
|
||
|
|
@Opname_Plus = 9, // <OpName> ::= '+'
|
||
|
|
@Opname_Minus = 10, // <OpName> ::= '-'
|
||
|
|
@Opname_Amp = 11, // <OpName> ::= '&'
|
||
|
|
@Opname_Caret = 12, // <OpName> ::= '^'
|
||
|
|
@Opname_Backslash = 13, // <OpName> ::= '\'
|
||
|
|
@Opname_Div = 14, // <OpName> ::= '/'
|
||
|
|
@Opname_Pipe = 15, // <OpName> ::= '|'
|
||
|
|
@Opname_Exclam = 16, // <OpName> ::= '!'
|
||
|
|
@Opname_Quote = 17, // <OpName> ::= '"'
|
||
|
|
@Opname_A = 18, // <OpName> ::= A
|
||
|
|
@Opname_F = 19, // <OpName> ::= F
|
||
|
|
@Opsrightlist = 20, // <OpsRightList> ::= <OpsRight>
|
||
|
|
@Opsrightlist2 = 21, // <OpsRightList> ::= <OpsRightList> <OpsRight>
|
||
|
|
@Opsright = 22, // <OpsRight> ::= <OpName>
|
||
|
|
@Opsright2 = 23, // <OpsRight> ::= <OpName> <Args>
|
||
|
|
@Expressionlist = 24, // <Expression List> ::= <Expression>
|
||
|
|
@Expressionlist_Comma = 25, // <Expression List> ::= <Expression> ',' <Expression List>
|
||
|
|
@Expression_Eq = 26, // <Expression> ::= <Conditional Exp> '=' <Expression>
|
||
|
|
@Expression_Pluseq = 27, // <Expression> ::= <Conditional Exp> '+=' <Expression>
|
||
|
|
@Expression_Minuseq = 28, // <Expression> ::= <Conditional Exp> '-=' <Expression>
|
||
|
|
@Expression_Timeseq = 29, // <Expression> ::= <Conditional Exp> '*=' <Expression>
|
||
|
|
@Expression_Diveq = 30, // <Expression> ::= <Conditional Exp> '/=' <Expression>
|
||
|
|
@Expression_Careteq = 31, // <Expression> ::= <Conditional Exp> '^=' <Expression>
|
||
|
|
@Expression_Ampeq = 32, // <Expression> ::= <Conditional Exp> '&=' <Expression>
|
||
|
|
@Expression_Pipeeq = 33, // <Expression> ::= <Conditional Exp> '|=' <Expression>
|
||
|
|
@Expression_Percenteq = 34, // <Expression> ::= <Conditional Exp> '%=' <Expression>
|
||
|
|
@Expression_Ltlteq = 35, // <Expression> ::= <Conditional Exp> '<<=' <Expression>
|
||
|
|
@Expression_Gtgteq = 36, // <Expression> ::= <Conditional Exp> '>>=' <Expression>
|
||
|
|
@Expression = 37, // <Expression> ::= <Conditional Exp>
|
||
|
|
@Conditionalexp_Question_Colon = 38, // <Conditional Exp> ::= <Or Exp> '?' <Or Exp> ':' <Conditional Exp>
|
||
|
|
@Conditionalexp = 39, // <Conditional Exp> ::= <Or Exp>
|
||
|
|
@Orexp_Pipepipe = 40, // <Or Exp> ::= <Or Exp> '||' <And Exp>
|
||
|
|
@Orexp = 41, // <Or Exp> ::= <And Exp>
|
||
|
|
@Andexp_Ampamp = 42, // <And Exp> ::= <And Exp> '&&' <Logical Or Exp>
|
||
|
|
@Andexp = 43, // <And Exp> ::= <Logical Or Exp>
|
||
|
|
@Logicalorexp_Pipe = 44, // <Logical Or Exp> ::= <Logical Or Exp> '|' <Logical Xor Exp>
|
||
|
|
@Logicalorexp = 45, // <Logical Or Exp> ::= <Logical Xor Exp>
|
||
|
|
@Logicalxorexp_Caret = 46, // <Logical Xor Exp> ::= <Logical Xor Exp> '^' <Logical And Exp>
|
||
|
|
@Logicalxorexp = 47, // <Logical Xor Exp> ::= <Logical And Exp>
|
||
|
|
@Logicalandexp_Amp = 48, // <Logical And Exp> ::= <Logical And Exp> '&' <Equality Exp>
|
||
|
|
@Logicalandexp = 49, // <Logical And Exp> ::= <Equality Exp>
|
||
|
|
@Equalityexp_Eqeq = 50, // <Equality Exp> ::= <Equality Exp> '==' <Compare Exp>
|
||
|
|
@Equalityexp_Exclameq = 51, // <Equality Exp> ::= <Equality Exp> '!=' <Compare Exp>
|
||
|
|
@Equalityexp = 52, // <Equality Exp> ::= <Compare Exp>
|
||
|
|
@Compareexp_Lt = 53, // <Compare Exp> ::= <Compare Exp> '<' <Shift Exp>
|
||
|
|
@Compareexp_Gt = 54, // <Compare Exp> ::= <Compare Exp> '>' <Shift Exp>
|
||
|
|
@Compareexp_Lteq = 55, // <Compare Exp> ::= <Compare Exp> '<=' <Shift Exp>
|
||
|
|
@Compareexp_Gteq = 56, // <Compare Exp> ::= <Compare Exp> '>=' <Shift Exp>
|
||
|
|
@Compareexp = 57, // <Compare Exp> ::= <Shift Exp>
|
||
|
|
@Shiftexp_Ltlt = 58, // <Shift Exp> ::= <Shift Exp> '<<' <Add Exp>
|
||
|
|
@Shiftexp_Gtgt = 59, // <Shift Exp> ::= <Shift Exp> '>>' <Add Exp>
|
||
|
|
@Shiftexp = 60, // <Shift Exp> ::= <Add Exp>
|
||
|
|
@Addexp_Plus = 61, // <Add Exp> ::= <Add Exp> '+' <Mult Exp>
|
||
|
|
@Addexp_Minus = 62, // <Add Exp> ::= <Add Exp> '-' <Mult Exp>
|
||
|
|
@Addexp = 63, // <Add Exp> ::= <Mult Exp>
|
||
|
|
@Multexp_Times = 64, // <Mult Exp> ::= <Mult Exp> '*' <Unary Exp>
|
||
|
|
@Multexp_Div = 65, // <Mult Exp> ::= <Mult Exp> '/' <Unary Exp>
|
||
|
|
@Multexp_Percent = 66, // <Mult Exp> ::= <Mult Exp> '%' <Unary Exp>
|
||
|
|
@Multexp = 67, // <Mult Exp> ::= <Unary Exp>
|
||
|
|
@Unaryexp_Exclam = 68, // <Unary Exp> ::= '!' <Unary Exp>
|
||
|
|
@Unaryexp_Tilde = 69, // <Unary Exp> ::= '~' <Unary Exp>
|
||
|
|
@Unaryexp_Minus = 70, // <Unary Exp> ::= '-' <Unary Exp>
|
||
|
|
@Unaryexp_Plusplus = 71, // <Unary Exp> ::= '++' <Unary Exp>
|
||
|
|
@Unaryexp_Minusminus = 72, // <Unary Exp> ::= '--' <Unary Exp>
|
||
|
|
@Unaryexp = 73, // <Unary Exp> ::= <Primary Exp>
|
||
|
|
@Primaryexp = 74, // <Primary Exp> ::= <Primary>
|
||
|
|
@Primaryexp_Lparen_Rparen = 75, // <Primary Exp> ::= '(' <Expression> ')'
|
||
|
|
@Primary = 76, // <Primary> ::= <Literal>
|
||
|
|
@Primary_Identifier = 77, // <Primary> ::= Identifier
|
||
|
|
@Args_Lparen_Rparen = 78, // <Args> ::= '(' <Expression List> ')'
|
||
|
|
@Formalparamslist_Comma_Identifier = 79, // <FormalParamsList> ::= <FormalParamsList> ',' Identifier
|
||
|
|
@Formalparamslist_Identifier = 80, // <FormalParamsList> ::= Identifier
|
||
|
|
@Formalparams_Lparen_Rparen = 81, // <FormalParams> ::= '(' <FormalParamsList> ')'
|
||
|
|
@Opsleft = 82, // <OpsLeft> ::= <OpName>
|
||
|
|
@Opsleft2 = 83, // <OpsLeft> ::= <OpName> <FormalParams>
|
||
|
|
@Opsleftlist = 84, // <OpsLeftList> ::= <OpsLeft>
|
||
|
|
@Opsleftlist2 = 85, // <OpsLeftList> ::= <OpsLeftList> <OpsLeft>
|
||
|
|
@Matchleftcontext_Lt = 86, // <MatchLeftContext> ::= <OpsLeftList> '<'
|
||
|
|
@Matchprime = 87, // <MatchPrime> ::= <OpsLeftList>
|
||
|
|
@Matchrightcontext_Gt = 88, // <MatchRightContext> ::= '>' <OpsLeftList>
|
||
|
|
@Match = 89, // <Match> ::= <MatchPrime>
|
||
|
|
@Match2 = 90, // <Match> ::= <MatchLeftContext> <MatchPrime>
|
||
|
|
@Match3 = 91, // <Match> ::= <MatchPrime> <MatchRightContext>
|
||
|
|
@Match4 = 92, // <Match> ::= <MatchLeftContext> <MatchPrime> <MatchRightContext>
|
||
|
|
@Replace = 93, // <Replace> ::= <OpsRightList>
|
||
|
|
@Rule = 94 // <Rule> ::= <Match> <AssignOp> <Replace>
|
||
|
|
}
|
||
|
|
|
||
|
|
public GOLD.Reduction program; //You might derive a specific object
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
public void Setup()
|
||
|
|
{
|
||
|
|
//This procedure can be called to load the parse tables. The class can
|
||
|
|
//read tables using a BinaryReader.
|
||
|
|
|
||
|
|
parser.LoadTables(@"C:\Users\l-pro\Desktop\lsystem.egt");
|
||
|
|
// parser.LoadTables(Path.Combine(Application.StartupPath, "grammar.egt"));
|
||
|
|
}
|
||
|
|
|
||
|
|
public bool Parse(TextReader reader)
|
||
|
|
{
|
||
|
|
//This procedure starts the GOLD Parser Engine and handles each of the
|
||
|
|
//messages it returns. Each time a reduction is made, you can create new
|
||
|
|
//custom object and reassign the .CurrentReduction property. Otherwise,
|
||
|
|
//the system will use the Reduction object that was returned.
|
||
|
|
//
|
||
|
|
//The resulting tree will be a pure representation of the language
|
||
|
|
//and will be ready to implement.
|
||
|
|
|
||
|
|
GOLD.ParseMessage response;
|
||
|
|
bool done; //Controls when we leave the loop
|
||
|
|
bool accepted = false; //Was the parse successful?
|
||
|
|
|
||
|
|
parser.Open(reader);
|
||
|
|
parser.TrimReductions = false; //Please read about this feature before enabling
|
||
|
|
|
||
|
|
done = false;
|
||
|
|
while (!done)
|
||
|
|
{
|
||
|
|
response = parser.Parse();
|
||
|
|
|
||
|
|
switch (response)
|
||
|
|
{
|
||
|
|
case GOLD.ParseMessage.LexicalError:
|
||
|
|
Debug.Log("LexicalError");
|
||
|
|
//Cannot recognize token
|
||
|
|
done = true;
|
||
|
|
break;
|
||
|
|
|
||
|
|
case GOLD.ParseMessage.SyntaxError:
|
||
|
|
Debug.Log("SyntaxError");
|
||
|
|
//Expecting a different token
|
||
|
|
done = true;
|
||
|
|
break;
|
||
|
|
|
||
|
|
case GOLD.ParseMessage.Reduction:
|
||
|
|
//Create a customized object to store the reduction
|
||
|
|
Debug.Log("Reduction");
|
||
|
|
//parser.CurrentReduction = CreateNewObject(parser.CurrentReduction as GOLD.Reduction);
|
||
|
|
break;
|
||
|
|
|
||
|
|
case GOLD.ParseMessage.Accept:
|
||
|
|
Debug.Log("Accept");
|
||
|
|
//Accepted!
|
||
|
|
program = (GOLD.Reduction) parser.CurrentReduction; //The root node!
|
||
|
|
done = true;
|
||
|
|
accepted = true;
|
||
|
|
break;
|
||
|
|
|
||
|
|
case GOLD.ParseMessage.TokenRead:
|
||
|
|
Debug.Log("TokenRead");
|
||
|
|
//You don't have to do anything here.
|
||
|
|
break;
|
||
|
|
|
||
|
|
case GOLD.ParseMessage.InternalError:
|
||
|
|
Debug.Log("InternalError");
|
||
|
|
//INTERNAL ERROR! Something is horribly wrong.
|
||
|
|
done = true;
|
||
|
|
break;
|
||
|
|
|
||
|
|
case GOLD.ParseMessage.NotLoadedError:
|
||
|
|
Debug.Log("NotLoadedError");
|
||
|
|
//This error occurs if the CGT was not loaded.
|
||
|
|
done = true;
|
||
|
|
break;
|
||
|
|
|
||
|
|
case GOLD.ParseMessage.GroupError:
|
||
|
|
Debug.Log("GroupError");
|
||
|
|
//GROUP ERROR! Unexpected end of file
|
||
|
|
done = true;
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
} //while
|
||
|
|
|
||
|
|
return accepted;
|
||
|
|
}
|
||
|
|
|
||
|
|
private object CreateNewObject(GOLD.Reduction r)
|
||
|
|
{
|
||
|
|
object result = null;
|
||
|
|
|
||
|
|
switch( (ProductionIndex) r.Parent.TableIndex())
|
||
|
|
{
|
||
|
|
case ProductionIndex.Assignop_Eq:
|
||
|
|
Debug.Log("<AssignOp> ::= '='");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Assignop_Minusgt:
|
||
|
|
Debug.Log("<AssignOp> ::= '->'");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Literal_True:
|
||
|
|
Debug.Log("<Literal> ::= true");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Literal_False:
|
||
|
|
Debug.Log("<Literal> ::= false");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Literal_Decliteral:
|
||
|
|
|
||
|
|
Debug.Log("<Literal> ::= DecLiteral: " + r.get_Data(0));
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Literal_Hexliteral:
|
||
|
|
Debug.Log("<Literal> ::= HexLiteral");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Literal_Realliteral:
|
||
|
|
Debug.Log("<Literal> ::= RealLiteral");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Literal_Charliteral:
|
||
|
|
Debug.Log("<Literal> ::= CharLiteral");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Literal_Stringliteral:
|
||
|
|
Debug.Log("<Literal> ::= StringLiteral");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Opname_Plus:
|
||
|
|
Debug.Log("<OpName> ::= '+'");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Opname_Minus:
|
||
|
|
Debug.Log("<OpName> ::= '-'");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Opname_Amp:
|
||
|
|
Debug.Log("<OpName> ::= '&'");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Opname_Caret:
|
||
|
|
Debug.Log("<OpName> ::= '^'");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Opname_Backslash:
|
||
|
|
Debug.Log("<OpName> ::= '\'");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Opname_Div:
|
||
|
|
Debug.Log("<OpName> ::= '/'");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Opname_Pipe:
|
||
|
|
Debug.Log("<OpName> ::= '|'");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Opname_Exclam:
|
||
|
|
Debug.Log("<OpName> ::= '!'");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Opname_Quote:
|
||
|
|
Debug.Log("<OpName> ::= \"");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Opname_A:
|
||
|
|
Debug.Log("<OpName> ::= A");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Opname_F:
|
||
|
|
Debug.Log("<OpName> ::= F");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Opsrightlist:
|
||
|
|
Debug.Log("<OpsRightList> ::= <OpsRight>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Opsrightlist2:
|
||
|
|
Debug.Log("<OpsRightList> ::= <OpsRightList> <OpsRight>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Opsright:
|
||
|
|
Debug.Log("<OpsRight> ::= <OpName>:" + r.get_Data(0));
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Opsright2:
|
||
|
|
Debug.Log("<OpsRight> ::= <OpName> <Args>:" +r.get_Data(0));
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Expressionlist:
|
||
|
|
Debug.Log("<Expression List> ::= <Expression>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Expressionlist_Comma:
|
||
|
|
Debug.Log("<Expression List> ::= <Expression> ',' <Expression List>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Expression_Eq:
|
||
|
|
Debug.Log("<Expression> ::= <Conditional Exp> '=' <Expression>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Expression_Pluseq:
|
||
|
|
Debug.Log("<Expression> ::= <Conditional Exp> '+=' <Expression>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Expression_Minuseq:
|
||
|
|
Debug.Log("<Expression> ::= <Conditional Exp> '-=' <Expression>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Expression_Timeseq:
|
||
|
|
Debug.Log("<Expression> ::= <Conditional Exp> '*=' <Expression>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Expression_Diveq:
|
||
|
|
Debug.Log("<Expression> ::= <Conditional Exp> '/=' <Expression>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Expression_Careteq:
|
||
|
|
Debug.Log("<Expression> ::= <Conditional Exp> '^=' <Expression>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Expression_Ampeq:
|
||
|
|
Debug.Log("<Expression> ::= <Conditional Exp> '&=' <Expression>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Expression_Pipeeq:
|
||
|
|
Debug.Log("<Expression> ::= <Conditional Exp> '|=' <Expression>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Expression_Percenteq:
|
||
|
|
Debug.Log("<Expression> ::= <Conditional Exp> '%=' <Expression>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Expression_Ltlteq:
|
||
|
|
Debug.Log("<Expression> ::= <Conditional Exp> '<<=' <Expression>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Expression_Gtgteq:
|
||
|
|
Debug.Log("<Expression> ::= <Conditional Exp> '>>=' <Expression>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Expression:
|
||
|
|
Debug.Log("<Expression> ::= <Conditional Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Conditionalexp_Question_Colon:
|
||
|
|
Debug.Log("<Conditional Exp> ::= <Or Exp> '?' <Or Exp> ':' <Conditional Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Conditionalexp:
|
||
|
|
Debug.Log("<Conditional Exp> ::= <Or Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Orexp_Pipepipe:
|
||
|
|
Debug.Log("<Or Exp> ::= <Or Exp> '||' <And Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Orexp:
|
||
|
|
Debug.Log("<Or Exp> ::= <And Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Andexp_Ampamp:
|
||
|
|
Debug.Log("<And Exp> ::= <And Exp> '&&' <Logical Or Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Andexp:
|
||
|
|
Debug.Log("<And Exp> ::= <Logical Or Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Logicalorexp_Pipe:
|
||
|
|
Debug.Log("<Logical Or Exp> ::= <Logical Or Exp> '|' <Logical Xor Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Logicalorexp:
|
||
|
|
Debug.Log("<Logical Or Exp> ::= <Logical Xor Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Logicalxorexp_Caret:
|
||
|
|
Debug.Log("<Logical Xor Exp> ::= <Logical Xor Exp> '^' <Logical And Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Logicalxorexp:
|
||
|
|
Debug.Log("<Logical Xor Exp> ::= <Logical And Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Logicalandexp_Amp:
|
||
|
|
Debug.Log("<Logical And Exp> ::= <Logical And Exp> '&' <Equality Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Logicalandexp:
|
||
|
|
Debug.Log("<Logical And Exp> ::= <Equality Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Equalityexp_Eqeq:
|
||
|
|
Debug.Log("<Equality Exp> ::= <Equality Exp> '==' <Compare Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Equalityexp_Exclameq:
|
||
|
|
Debug.Log("<Equality Exp> ::= <Equality Exp> '!=' <Compare Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Equalityexp:
|
||
|
|
Debug.Log("<Equality Exp> ::= <Compare Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Compareexp_Lt:
|
||
|
|
Debug.Log("<Compare Exp> ::= <Compare Exp> '<' <Shift Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Compareexp_Gt:
|
||
|
|
Debug.Log("<Compare Exp> ::= <Compare Exp> '>' <Shift Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Compareexp_Lteq:
|
||
|
|
Debug.Log("<Compare Exp> ::= <Compare Exp> '<=' <Shift Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Compareexp_Gteq:
|
||
|
|
Debug.Log("<Compare Exp> ::= <Compare Exp> '>=' <Shift Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Compareexp:
|
||
|
|
Debug.Log("<Compare Exp> ::= <Shift Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Shiftexp_Ltlt:
|
||
|
|
Debug.Log("<Shift Exp> ::= <Shift Exp> '<<' <Add Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Shiftexp_Gtgt:
|
||
|
|
Debug.Log("<Shift Exp> ::= <Shift Exp> '>>' <Add Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Shiftexp:
|
||
|
|
Debug.Log("<Shift Exp> ::= <Add Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Addexp_Plus:
|
||
|
|
Debug.Log("<Add Exp> ::= <Add Exp> '+' <Mult Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Addexp_Minus:
|
||
|
|
Debug.Log("<Add Exp> ::= <Add Exp> '-' <Mult Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Addexp:
|
||
|
|
Debug.Log("<Add Exp> ::= <Mult Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Multexp_Times:
|
||
|
|
Debug.Log("<Mult Exp> ::= <Mult Exp> '*' <Unary Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Multexp_Div:
|
||
|
|
Debug.Log("<Mult Exp> ::= <Mult Exp> '/' <Unary Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Multexp_Percent:
|
||
|
|
Debug.Log("<Mult Exp> ::= <Mult Exp> '%' <Unary Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Multexp:
|
||
|
|
Debug.Log("<Mult Exp> ::= <Unary Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Unaryexp_Exclam:
|
||
|
|
Debug.Log("<Unary Exp> ::= '!' <Unary Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Unaryexp_Tilde:
|
||
|
|
Debug.Log("<Unary Exp> ::= '~' <Unary Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Unaryexp_Minus:
|
||
|
|
Debug.Log("<Unary Exp> ::= '-' <Unary Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Unaryexp_Plusplus:
|
||
|
|
Debug.Log("<Unary Exp> ::= '++' <Unary Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Unaryexp_Minusminus:
|
||
|
|
Debug.Log(" <Unary Exp> ::= '--' <Unary Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Unaryexp:
|
||
|
|
Debug.Log("<Unary Exp> ::= <Primary Exp>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Primaryexp:
|
||
|
|
Debug.Log("<Primary Exp> ::= <Primary>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Primaryexp_Lparen_Rparen:
|
||
|
|
Debug.Log("<Primary Exp> ::= '(' <Expression> ')'");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Primary:
|
||
|
|
Debug.Log("<Primary> ::= <Literal>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Primary_Identifier:
|
||
|
|
Debug.Log("<Primary> ::= Identifier: " + r.get_Data(0));
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Args_Lparen_Rparen:
|
||
|
|
Debug.Log("<Args> ::= '(' <Expression List> ')'");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Formalparamslist_Comma_Identifier:
|
||
|
|
Debug.Log("<FormalParamsList> ::= <FormalParamsList> ',' Identifier");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Formalparamslist_Identifier:
|
||
|
|
Debug.Log("< FormalParamsList> ::= Identifier: " + r.get_Data(0));
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Formalparams_Lparen_Rparen:
|
||
|
|
Debug.Log("< FormalParams> ::= '(' <FormalParamsList> ')'");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Opsleft:
|
||
|
|
Debug.Log("<OpsLeft> ::= <OpName>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Opsleft2:
|
||
|
|
Debug.Log("<OpsLeft> ::= <OpName> <FormalParams>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Opsleftlist:
|
||
|
|
Debug.Log("<OpsLeftList> ::= <OpsLeft>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Opsleftlist2:
|
||
|
|
Debug.Log("<OpsLeftList> ::= <OpsLeftList> <OpsLeft>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Matchleftcontext_Lt:
|
||
|
|
Debug.Log("<MatchLeftContext> ::= <OpsLeftList> '<'");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Matchprime:
|
||
|
|
Debug.Log("<MatchPrime> ::= <OpsLeftList>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Matchrightcontext_Gt:
|
||
|
|
Debug.Log("<MatchRightContext> ::= '>' <OpsLeftList>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Match:
|
||
|
|
Debug.Log("<Match> ::= <MatchPrime>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Match2:
|
||
|
|
Debug.Log("<Match> ::= <MatchLeftContext> <MatchPrime>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Match3:
|
||
|
|
Debug.Log("<Match> ::= <MatchPrime> <MatchRightContext>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Match4:
|
||
|
|
Debug.Log("<Match> ::= <MatchLeftContext> <MatchPrime> <MatchRightContext>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Replace:
|
||
|
|
Debug.Log("<Replace> ::= <OpsRightList>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
case ProductionIndex.Rule:
|
||
|
|
Debug.Log("<Rule> ::= <Match> <AssignOp> <Replace>");
|
||
|
|
break;
|
||
|
|
|
||
|
|
} //switch
|
||
|
|
|
||
|
|
return result;
|
||
|
|
}
|
||
|
|
|
||
|
|
}; //MyParser
|