531 lines
24 KiB
C#
531 lines
24 KiB
C#
// This code was generated by the Gardens Point Parser Generator
|
||
// Copyright (c) Wayne Kelly, QUT 2005-2010
|
||
// (see accompanying GPPGcopyright.rtf)
|
||
|
||
// GPPG version 1.3.6
|
||
// Machine: MIKS
|
||
// DateTime: 14.06.2010 23:57:49
|
||
// UserName: Stanislav
|
||
// Input file <oberon00.y>
|
||
|
||
// options: no-lines gplex
|
||
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Globalization;
|
||
using System.Text;
|
||
using QUT.Gppg;
|
||
using PascalABCCompiler.SyntaxTree;
|
||
using PascalABCCompiler.Errors;
|
||
using PascalABCCompiler.Oberon00Parser;
|
||
|
||
namespace GPPGParserScanner
|
||
{
|
||
public enum Tokens {
|
||
error=1,EOF=2,ID=3,INTNUM=4,TRUE=5,FALSE=6,
|
||
PLUS=7,MINUS=8,MULT=9,DIVIDE=10,AND=11,OR=12,
|
||
LT=13,GT=14,LE=15,GE=16,EQ=17,NE=18,
|
||
NOT=19,ASSIGN=20,SEMICOLUMN=21,LPAREN=22,RPAREN=23,COLUMN=24,
|
||
COMMA=25,COLON=26,EXCLAMATION=27,ODD=28,BOOLEAN=29,INTEGER=30,
|
||
IF=31,THEN=32,ELSE=33,BEGIN=34,END=35,WHILE=36,
|
||
DO=37,MODULE=38,CONST=39,VAR=40,INVISIBLE=41,UMINUS=42};
|
||
|
||
public struct ValueType
|
||
{
|
||
public bool bVal;
|
||
public string sVal;
|
||
public int iVal;
|
||
public named_type_reference ntr;
|
||
public ident_list il;
|
||
public var_def_statement vds;
|
||
public variable_definitions vdss;
|
||
public expression ex;
|
||
public expression_list el;
|
||
public ident id;
|
||
public statement st;
|
||
public statement_list sl;
|
||
public declarations decl;
|
||
public Operators op;
|
||
public simple_const_definition scd;
|
||
public consts_definitions_list cdl;
|
||
}
|
||
// Abstract base class for GPLEX scanners
|
||
public abstract class ScanBase : AbstractScanner<ValueType,LexLocation> {
|
||
private LexLocation __yylloc = new LexLocation();
|
||
public override LexLocation yylloc { get { return __yylloc; } set { __yylloc = value; } }
|
||
protected virtual bool yywrap() { return true; }
|
||
}
|
||
|
||
public class GPPGParser: ShiftReduceParser<ValueType, LexLocation>
|
||
{
|
||
// Verbatim content from oberon00.y
|
||
public syntax_tree_node root; // Корневой узел синтаксического дерева
|
||
public GPPGParser(AbstractScanner<ValueType, LexLocation> scanner) : base(scanner) { }
|
||
// End verbatim content from oberon00.y
|
||
|
||
#pragma warning disable 649
|
||
private static Dictionary<int, string> aliasses;
|
||
#pragma warning restore 649
|
||
private static Rule[] rules = new Rule[56];
|
||
private static State[] states = new State[108];
|
||
private static string[] nonTerms = new string[] {
|
||
"module", "ident", "type", "expr", "ConstExpr", "Assignment", "IfStatement",
|
||
"WhileStatement", "WriteStatement", "Statement", "EmptyStatement", "ProcCallStatement",
|
||
"StatementSequence", "Declarations", "factparams", "IDList", "VarDecl",
|
||
"VarDeclarations", "VarDeclarationsSect", "ConstDecl", "ConstDeclarations",
|
||
"ConstDeclarationsSect", "$accept", };
|
||
|
||
static GPPGParser() {
|
||
states[0] = new State(new int[]{38,3,41,106},new int[]{-1,1});
|
||
states[1] = new State(new int[]{2,2});
|
||
states[2] = new State(-1);
|
||
states[3] = new State(new int[]{3,12},new int[]{-2,4});
|
||
states[4] = new State(new int[]{21,5});
|
||
states[5] = new State(new int[]{40,82,39,97},new int[]{-14,6,-19,81,-22,95});
|
||
states[6] = new State(new int[]{34,7});
|
||
states[7] = new State(new int[]{3,12,31,61,36,71,27,77,35,-32,21,-32},new int[]{-13,8,-10,69,-6,15,-2,16,-7,60,-8,70,-9,76,-12,79,-11,80});
|
||
states[8] = new State(new int[]{35,9,21,13});
|
||
states[9] = new State(new int[]{3,12},new int[]{-2,10});
|
||
states[10] = new State(new int[]{25,11});
|
||
states[11] = new State(-2);
|
||
states[12] = new State(-4);
|
||
states[13] = new State(new int[]{3,12,31,61,36,71,27,77,35,-32,21,-32,33,-32},new int[]{-10,14,-6,15,-2,16,-7,60,-8,70,-9,76,-12,79,-11,80});
|
||
states[14] = new State(-40);
|
||
states[15] = new State(-33);
|
||
states[16] = new State(new int[]{20,17,22,54});
|
||
states[17] = new State(new int[]{3,12,4,44,5,45,6,46,8,47,22,49,19,52},new int[]{-4,18,-2,43});
|
||
states[18] = new State(new int[]{7,19,8,21,9,23,10,25,11,27,12,29,17,31,18,33,13,35,15,37,14,39,16,41,35,-24,21,-24,33,-24});
|
||
states[19] = new State(new int[]{3,12,4,44,5,45,6,46,8,47,22,49,19,52},new int[]{-4,20,-2,43});
|
||
states[20] = new State(new int[]{7,-12,8,-12,9,23,10,25,11,27,12,-12,17,-12,18,-12,13,-12,15,-12,14,-12,16,-12,35,-12,21,-12,33,-12,23,-12,24,-12,32,-12,37,-12,2,-12});
|
||
states[21] = new State(new int[]{3,12,4,44,5,45,6,46,8,47,22,49,19,52},new int[]{-4,22,-2,43});
|
||
states[22] = new State(new int[]{7,-13,8,-13,9,23,10,25,11,27,12,-13,17,-13,18,-13,13,-13,15,-13,14,-13,16,-13,35,-13,21,-13,33,-13,23,-13,24,-13,32,-13,37,-13,2,-13});
|
||
states[23] = new State(new int[]{3,12,4,44,5,45,6,46,8,47,22,49,19,52},new int[]{-4,24,-2,43});
|
||
states[24] = new State(-14);
|
||
states[25] = new State(new int[]{3,12,4,44,5,45,6,46,8,47,22,49,19,52},new int[]{-4,26,-2,43});
|
||
states[26] = new State(-15);
|
||
states[27] = new State(new int[]{3,12,4,44,5,45,6,46,8,47,22,49,19,52},new int[]{-4,28,-2,43});
|
||
states[28] = new State(-16);
|
||
states[29] = new State(new int[]{3,12,4,44,5,45,6,46,8,47,22,49,19,52},new int[]{-4,30,-2,43});
|
||
states[30] = new State(new int[]{7,-17,8,-17,9,23,10,25,11,27,12,-17,17,-17,18,-17,13,-17,15,-17,14,-17,16,-17,35,-17,21,-17,33,-17,23,-17,24,-17,32,-17,37,-17,2,-17});
|
||
states[31] = new State(new int[]{3,12,4,44,5,45,6,46,8,47,22,49,19,52},new int[]{-4,32,-2,43});
|
||
states[32] = new State(new int[]{7,19,8,21,9,23,10,25,11,27,12,29,17,-18,18,-18,13,-18,15,-18,14,-18,16,-18,35,-18,21,-18,33,-18,23,-18,24,-18,32,-18,37,-18,2,-18});
|
||
states[33] = new State(new int[]{3,12,4,44,5,45,6,46,8,47,22,49,19,52},new int[]{-4,34,-2,43});
|
||
states[34] = new State(new int[]{7,19,8,21,9,23,10,25,11,27,12,29,17,-19,18,-19,13,-19,15,-19,14,-19,16,-19,35,-19,21,-19,33,-19,23,-19,24,-19,32,-19,37,-19,2,-19});
|
||
states[35] = new State(new int[]{3,12,4,44,5,45,6,46,8,47,22,49,19,52},new int[]{-4,36,-2,43});
|
||
states[36] = new State(new int[]{7,19,8,21,9,23,10,25,11,27,12,29,17,-20,18,-20,13,-20,15,-20,14,-20,16,-20,35,-20,21,-20,33,-20,23,-20,24,-20,32,-20,37,-20,2,-20});
|
||
states[37] = new State(new int[]{3,12,4,44,5,45,6,46,8,47,22,49,19,52},new int[]{-4,38,-2,43});
|
||
states[38] = new State(new int[]{7,19,8,21,9,23,10,25,11,27,12,29,17,-21,18,-21,13,-21,15,-21,14,-21,16,-21,35,-21,21,-21,33,-21,23,-21,24,-21,32,-21,37,-21,2,-21});
|
||
states[39] = new State(new int[]{3,12,4,44,5,45,6,46,8,47,22,49,19,52},new int[]{-4,40,-2,43});
|
||
states[40] = new State(new int[]{7,19,8,21,9,23,10,25,11,27,12,29,17,-22,18,-22,13,-22,15,-22,14,-22,16,-22,35,-22,21,-22,33,-22,23,-22,24,-22,32,-22,37,-22,2,-22});
|
||
states[41] = new State(new int[]{3,12,4,44,5,45,6,46,8,47,22,49,19,52},new int[]{-4,42,-2,43});
|
||
states[42] = new State(new int[]{7,19,8,21,9,23,10,25,11,27,12,29,17,-23,18,-23,13,-23,15,-23,14,-23,16,-23,35,-23,21,-23,33,-23,23,-23,24,-23,32,-23,37,-23,2,-23});
|
||
states[43] = new State(-5);
|
||
states[44] = new State(-6);
|
||
states[45] = new State(-7);
|
||
states[46] = new State(-8);
|
||
states[47] = new State(new int[]{3,12,4,44,5,45,6,46,8,47,22,49,19,52},new int[]{-4,48,-2,43});
|
||
states[48] = new State(-9);
|
||
states[49] = new State(new int[]{3,12,4,44,5,45,6,46,8,47,22,49,19,52},new int[]{-4,50,-2,43});
|
||
states[50] = new State(new int[]{23,51,7,19,8,21,9,23,10,25,11,27,12,29,17,31,18,33,13,35,15,37,14,39,16,41});
|
||
states[51] = new State(-10);
|
||
states[52] = new State(new int[]{3,12,4,44,5,45,6,46,8,47,22,49,19,52},new int[]{-4,53,-2,43});
|
||
states[53] = new State(-11);
|
||
states[54] = new State(new int[]{3,12,4,44,5,45,6,46,8,47,22,49,19,52},new int[]{-15,55,-4,59,-2,43});
|
||
states[55] = new State(new int[]{23,56,24,57});
|
||
states[56] = new State(-31);
|
||
states[57] = new State(new int[]{3,12,4,44,5,45,6,46,8,47,22,49,19,52},new int[]{-4,58,-2,43});
|
||
states[58] = new State(new int[]{7,19,8,21,9,23,10,25,11,27,12,29,17,31,18,33,13,35,15,37,14,39,16,41,23,-30,24,-30});
|
||
states[59] = new State(new int[]{7,19,8,21,9,23,10,25,11,27,12,29,17,31,18,33,13,35,15,37,14,39,16,41,23,-29,24,-29});
|
||
states[60] = new State(-34);
|
||
states[61] = new State(new int[]{3,12,4,44,5,45,6,46,8,47,22,49,19,52},new int[]{-4,62,-2,43});
|
||
states[62] = new State(new int[]{32,63,7,19,8,21,9,23,10,25,11,27,12,29,17,31,18,33,13,35,15,37,14,39,16,41});
|
||
states[63] = new State(new int[]{3,12,31,61,36,71,27,77,35,-32,33,-32,21,-32},new int[]{-13,64,-10,69,-6,15,-2,16,-7,60,-8,70,-9,76,-12,79,-11,80});
|
||
states[64] = new State(new int[]{35,65,33,66,21,13});
|
||
states[65] = new State(-25);
|
||
states[66] = new State(new int[]{3,12,31,61,36,71,27,77,35,-32,21,-32},new int[]{-13,67,-10,69,-6,15,-2,16,-7,60,-8,70,-9,76,-12,79,-11,80});
|
||
states[67] = new State(new int[]{35,68,21,13});
|
||
states[68] = new State(-26);
|
||
states[69] = new State(-39);
|
||
states[70] = new State(-35);
|
||
states[71] = new State(new int[]{3,12,4,44,5,45,6,46,8,47,22,49,19,52},new int[]{-4,72,-2,43});
|
||
states[72] = new State(new int[]{37,73,7,19,8,21,9,23,10,25,11,27,12,29,17,31,18,33,13,35,15,37,14,39,16,41});
|
||
states[73] = new State(new int[]{3,12,31,61,36,71,27,77,35,-32,21,-32},new int[]{-13,74,-10,69,-6,15,-2,16,-7,60,-8,70,-9,76,-12,79,-11,80});
|
||
states[74] = new State(new int[]{35,75,21,13});
|
||
states[75] = new State(-27);
|
||
states[76] = new State(-36);
|
||
states[77] = new State(new int[]{3,12,4,44,5,45,6,46,8,47,22,49,19,52},new int[]{-4,78,-2,43});
|
||
states[78] = new State(new int[]{7,19,8,21,9,23,10,25,11,27,12,29,17,31,18,33,13,35,15,37,14,39,16,41,35,-28,21,-28,33,-28});
|
||
states[79] = new State(-37);
|
||
states[80] = new State(-38);
|
||
states[81] = new State(-54);
|
||
states[82] = new State(new int[]{3,12},new int[]{-18,83,-17,94,-16,85,-2,93});
|
||
states[83] = new State(new int[]{3,12,34,-53},new int[]{-17,84,-16,85,-2,93});
|
||
states[84] = new State(-47);
|
||
states[85] = new State(new int[]{26,86,24,91});
|
||
states[86] = new State(new int[]{29,89,30,90},new int[]{-3,87});
|
||
states[87] = new State(new int[]{21,88});
|
||
states[88] = new State(-45);
|
||
states[89] = new State(-41);
|
||
states[90] = new State(-42);
|
||
states[91] = new State(new int[]{3,12},new int[]{-2,92});
|
||
states[92] = new State(-44);
|
||
states[93] = new State(-43);
|
||
states[94] = new State(-46);
|
||
states[95] = new State(new int[]{40,82},new int[]{-19,96});
|
||
states[96] = new State(-55);
|
||
states[97] = new State(new int[]{3,12},new int[]{-21,98,-20,105,-2,100});
|
||
states[98] = new State(new int[]{3,12,40,-52},new int[]{-20,99,-2,100});
|
||
states[99] = new State(-51);
|
||
states[100] = new State(new int[]{17,101});
|
||
states[101] = new State(new int[]{3,12,4,44,5,45,6,46,8,47,22,49,19,52},new int[]{-5,102,-4,104,-2,43});
|
||
states[102] = new State(new int[]{21,103});
|
||
states[103] = new State(-48);
|
||
states[104] = new State(new int[]{7,19,8,21,9,23,10,25,11,27,12,29,17,31,18,33,13,35,15,37,14,39,16,41,21,-49});
|
||
states[105] = new State(-50);
|
||
states[106] = new State(new int[]{3,12,4,44,5,45,6,46,8,47,22,49,19,52},new int[]{-4,107,-2,43});
|
||
states[107] = new State(new int[]{7,19,8,21,9,23,10,25,11,27,12,29,17,31,18,33,13,35,15,37,14,39,16,41,2,-3});
|
||
|
||
rules[1] = new Rule(-23, new int[]{-1,2});
|
||
rules[2] = new Rule(-1, new int[]{38,-2,21,-14,34,-13,35,-2,25});
|
||
rules[3] = new Rule(-1, new int[]{41,-4});
|
||
rules[4] = new Rule(-2, new int[]{3});
|
||
rules[5] = new Rule(-4, new int[]{-2});
|
||
rules[6] = new Rule(-4, new int[]{4});
|
||
rules[7] = new Rule(-4, new int[]{5});
|
||
rules[8] = new Rule(-4, new int[]{6});
|
||
rules[9] = new Rule(-4, new int[]{8,-4});
|
||
rules[10] = new Rule(-4, new int[]{22,-4,23});
|
||
rules[11] = new Rule(-4, new int[]{19,-4});
|
||
rules[12] = new Rule(-4, new int[]{-4,7,-4});
|
||
rules[13] = new Rule(-4, new int[]{-4,8,-4});
|
||
rules[14] = new Rule(-4, new int[]{-4,9,-4});
|
||
rules[15] = new Rule(-4, new int[]{-4,10,-4});
|
||
rules[16] = new Rule(-4, new int[]{-4,11,-4});
|
||
rules[17] = new Rule(-4, new int[]{-4,12,-4});
|
||
rules[18] = new Rule(-4, new int[]{-4,17,-4});
|
||
rules[19] = new Rule(-4, new int[]{-4,18,-4});
|
||
rules[20] = new Rule(-4, new int[]{-4,13,-4});
|
||
rules[21] = new Rule(-4, new int[]{-4,15,-4});
|
||
rules[22] = new Rule(-4, new int[]{-4,14,-4});
|
||
rules[23] = new Rule(-4, new int[]{-4,16,-4});
|
||
rules[24] = new Rule(-6, new int[]{-2,20,-4});
|
||
rules[25] = new Rule(-7, new int[]{31,-4,32,-13,35});
|
||
rules[26] = new Rule(-7, new int[]{31,-4,32,-13,33,-13,35});
|
||
rules[27] = new Rule(-8, new int[]{36,-4,37,-13,35});
|
||
rules[28] = new Rule(-9, new int[]{27,-4});
|
||
rules[29] = new Rule(-15, new int[]{-4});
|
||
rules[30] = new Rule(-15, new int[]{-15,24,-4});
|
||
rules[31] = new Rule(-12, new int[]{-2,22,-15,23});
|
||
rules[32] = new Rule(-11, new int[]{});
|
||
rules[33] = new Rule(-10, new int[]{-6});
|
||
rules[34] = new Rule(-10, new int[]{-7});
|
||
rules[35] = new Rule(-10, new int[]{-8});
|
||
rules[36] = new Rule(-10, new int[]{-9});
|
||
rules[37] = new Rule(-10, new int[]{-12});
|
||
rules[38] = new Rule(-10, new int[]{-11});
|
||
rules[39] = new Rule(-13, new int[]{-10});
|
||
rules[40] = new Rule(-13, new int[]{-13,21,-10});
|
||
rules[41] = new Rule(-3, new int[]{29});
|
||
rules[42] = new Rule(-3, new int[]{30});
|
||
rules[43] = new Rule(-16, new int[]{-2});
|
||
rules[44] = new Rule(-16, new int[]{-16,24,-2});
|
||
rules[45] = new Rule(-17, new int[]{-16,26,-3,21});
|
||
rules[46] = new Rule(-18, new int[]{-17});
|
||
rules[47] = new Rule(-18, new int[]{-18,-17});
|
||
rules[48] = new Rule(-20, new int[]{-2,17,-5,21});
|
||
rules[49] = new Rule(-5, new int[]{-4});
|
||
rules[50] = new Rule(-21, new int[]{-20});
|
||
rules[51] = new Rule(-21, new int[]{-21,-20});
|
||
rules[52] = new Rule(-22, new int[]{39,-21});
|
||
rules[53] = new Rule(-19, new int[]{40,-18});
|
||
rules[54] = new Rule(-14, new int[]{-19});
|
||
rules[55] = new Rule(-14, new int[]{-22,-19});
|
||
}
|
||
|
||
protected override void Initialize() {
|
||
this.InitSpecialTokens((int)Tokens.error, (int)Tokens.EOF);
|
||
this.InitStates(states);
|
||
this.InitRules(rules);
|
||
this.InitNonTerminals(nonTerms);
|
||
}
|
||
|
||
protected override void DoAction(int action)
|
||
{
|
||
switch (action)
|
||
{
|
||
case 2: // module -> MODULE, ident, SEMICOLUMN, Declarations, BEGIN, StatementSequence,
|
||
// END, ident, COMMA
|
||
{
|
||
if (ValueStack[ValueStack.Depth-8].id.name != ValueStack[ValueStack.Depth-2].id.name)
|
||
PT.AddError("Имя "+ValueStack[ValueStack.Depth-2].id.name+" должно совпадать с именем модуля "+ValueStack[ValueStack.Depth-8].id.name,LocationStack[LocationStack.Depth-2]);
|
||
|
||
// Подключение стандартной библиотеки
|
||
ident_list il = new ident_list();
|
||
il.Add(new ident("Oberon00System"));
|
||
unit_or_namespace un = new unit_or_namespace(il);
|
||
uses_list ul = new uses_list();
|
||
ul.units.Insert(0, un);
|
||
|
||
// Формирование главного модуля
|
||
var b = new block(ValueStack[ValueStack.Depth-6].decl, ValueStack[ValueStack.Depth-4].sl, LocationStack[LocationStack.Depth-6].Merge(LocationStack[LocationStack.Depth-2]));
|
||
var r = new program_module(null, ul, b, null,CurrentLocationSpan);
|
||
r.Language = LanguageId.Oberon00;
|
||
root = r;
|
||
}
|
||
break;
|
||
case 3: // module -> INVISIBLE, expr
|
||
{ // Для Intellisense
|
||
root = ValueStack[ValueStack.Depth-1].ex;
|
||
}
|
||
break;
|
||
case 4: // ident -> ID
|
||
{
|
||
CurrentSemanticValue.id = new ident(ValueStack[ValueStack.Depth-1].sVal,CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 5: // expr -> ident
|
||
{
|
||
CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-1].id;
|
||
}
|
||
break;
|
||
case 6: // expr -> INTNUM
|
||
{
|
||
CurrentSemanticValue.ex = new int32_const(ValueStack[ValueStack.Depth-1].iVal,CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 7: // expr -> TRUE
|
||
{
|
||
CurrentSemanticValue.ex = new bool_const(true,CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 8: // expr -> FALSE
|
||
{
|
||
CurrentSemanticValue.ex = new bool_const(false,CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 9: // expr -> MINUS, expr
|
||
{
|
||
CurrentSemanticValue.ex = new un_expr(ValueStack[ValueStack.Depth-1].ex,Operators.Minus,CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 10: // expr -> LPAREN, expr, RPAREN
|
||
{CurrentSemanticValue.ex = ValueStack[ValueStack.Depth-2].ex;}
|
||
break;
|
||
case 11: // expr -> NOT, expr
|
||
{
|
||
CurrentSemanticValue.ex = new un_expr(ValueStack[ValueStack.Depth-1].ex,Operators.LogicalNOT,CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 12: // expr -> expr, PLUS, expr
|
||
{
|
||
CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth-3].ex,ValueStack[ValueStack.Depth-1].ex,Operators.Plus,CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 13: // expr -> expr, MINUS, expr
|
||
{
|
||
CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth-3].ex,ValueStack[ValueStack.Depth-1].ex,Operators.Minus,CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 14: // expr -> expr, MULT, expr
|
||
{
|
||
CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth-3].ex,ValueStack[ValueStack.Depth-1].ex,Operators.Multiplication,CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 15: // expr -> expr, DIVIDE, expr
|
||
{
|
||
CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth-3].ex,ValueStack[ValueStack.Depth-1].ex,Operators.IntegerDivision,CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 16: // expr -> expr, AND, expr
|
||
{
|
||
CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth-3].ex,ValueStack[ValueStack.Depth-1].ex,Operators.LogicalAND,CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 17: // expr -> expr, OR, expr
|
||
{
|
||
CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth-3].ex,ValueStack[ValueStack.Depth-1].ex,Operators.LogicalOR,CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 18: // expr -> expr, EQ, expr
|
||
{
|
||
CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth-3].ex,ValueStack[ValueStack.Depth-1].ex,Operators.Equal,CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 19: // expr -> expr, NE, expr
|
||
{
|
||
CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth-3].ex,ValueStack[ValueStack.Depth-1].ex,Operators.NotEqual,CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 20: // expr -> expr, LT, expr
|
||
{
|
||
CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth-3].ex,ValueStack[ValueStack.Depth-1].ex,Operators.Less,CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 21: // expr -> expr, LE, expr
|
||
{
|
||
CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth-3].ex,ValueStack[ValueStack.Depth-1].ex,Operators.LessEqual,CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 22: // expr -> expr, GT, expr
|
||
{
|
||
CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth-3].ex,ValueStack[ValueStack.Depth-1].ex,Operators.Greater,CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 23: // expr -> expr, GE, expr
|
||
{
|
||
CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth-3].ex,ValueStack[ValueStack.Depth-1].ex,Operators.GreaterEqual,CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 24: // Assignment -> ident, ASSIGN, expr
|
||
{
|
||
CurrentSemanticValue.st = new assign(ValueStack[ValueStack.Depth-3].id, ValueStack[ValueStack.Depth-1].ex, Operators.Assignment,CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 25: // IfStatement -> IF, expr, THEN, StatementSequence, END
|
||
{
|
||
CurrentSemanticValue.st = new if_node(ValueStack[ValueStack.Depth-4].ex, ValueStack[ValueStack.Depth-2].sl, null, CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 26: // IfStatement -> IF, expr, THEN, StatementSequence, ELSE, StatementSequence, END
|
||
{
|
||
CurrentSemanticValue.st = new if_node(ValueStack[ValueStack.Depth-6].ex, ValueStack[ValueStack.Depth-4].sl, ValueStack[ValueStack.Depth-2].sl, CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 27: // WhileStatement -> WHILE, expr, DO, StatementSequence, END
|
||
{
|
||
CurrentSemanticValue.st = new while_node(ValueStack[ValueStack.Depth-4].ex, ValueStack[ValueStack.Depth-2].sl, WhileCycleType.While, CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 28: // WriteStatement -> EXCLAMATION, expr
|
||
{
|
||
expression_list el = new expression_list(ValueStack[ValueStack.Depth-1].ex);
|
||
method_call mc = new method_call(el);
|
||
mc.dereferencing_value = new ident("print");
|
||
CurrentSemanticValue.st = mc;
|
||
}
|
||
break;
|
||
case 29: // factparams -> expr
|
||
{
|
||
CurrentSemanticValue.el = new expression_list(ValueStack[ValueStack.Depth-1].ex,CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 30: // factparams -> factparams, COLUMN, expr
|
||
{
|
||
ValueStack[ValueStack.Depth-3].el.Add(ValueStack[ValueStack.Depth-1].ex,CurrentLocationSpan);
|
||
CurrentSemanticValue.el = ValueStack[ValueStack.Depth-3].el;
|
||
}
|
||
break;
|
||
case 31: // ProcCallStatement -> ident, LPAREN, factparams, RPAREN
|
||
{
|
||
CurrentSemanticValue.st = new method_call(ValueStack[ValueStack.Depth-4].id,ValueStack[ValueStack.Depth-2].el,CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 32: // EmptyStatement -> /* empty */
|
||
{
|
||
CurrentSemanticValue.st = new empty_statement();
|
||
}
|
||
break;
|
||
case 39: // StatementSequence -> Statement
|
||
{
|
||
CurrentSemanticValue.sl = new statement_list(ValueStack[ValueStack.Depth-1].st,CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 40: // StatementSequence -> StatementSequence, SEMICOLUMN, Statement
|
||
{
|
||
ValueStack[ValueStack.Depth-3].sl.Add(ValueStack[ValueStack.Depth-1].st,CurrentLocationSpan);
|
||
CurrentSemanticValue.sl = ValueStack[ValueStack.Depth-3].sl;
|
||
}
|
||
break;
|
||
case 41: // type -> BOOLEAN
|
||
{
|
||
CurrentSemanticValue.ntr = new named_type_reference("boolean",CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 42: // type -> INTEGER
|
||
{
|
||
CurrentSemanticValue.ntr = new named_type_reference("integer",CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 43: // IDList -> ident
|
||
{
|
||
CurrentSemanticValue.il=new ident_list(ValueStack[ValueStack.Depth-1].id,CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 44: // IDList -> IDList, COLUMN, ident
|
||
{
|
||
ValueStack[ValueStack.Depth-3].il.Add(ValueStack[ValueStack.Depth-1].id,CurrentLocationSpan);
|
||
CurrentSemanticValue.il = ValueStack[ValueStack.Depth-3].il;
|
||
}
|
||
break;
|
||
case 45: // VarDecl -> IDList, COLON, type, SEMICOLUMN
|
||
{
|
||
CurrentSemanticValue.vds = new var_def_statement(ValueStack[ValueStack.Depth-4].il,ValueStack[ValueStack.Depth-2].ntr,null,definition_attribute.None,false,CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 46: // VarDeclarations -> VarDecl
|
||
{
|
||
CurrentSemanticValue.vdss = new variable_definitions(ValueStack[ValueStack.Depth-1].vds,CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 47: // VarDeclarations -> VarDeclarations, VarDecl
|
||
{
|
||
ValueStack[ValueStack.Depth-2].vdss.Add(ValueStack[ValueStack.Depth-1].vds,CurrentLocationSpan);
|
||
CurrentSemanticValue.vdss = ValueStack[ValueStack.Depth-2].vdss;
|
||
}
|
||
break;
|
||
case 48: // ConstDecl -> ident, EQ, ConstExpr, SEMICOLUMN
|
||
{
|
||
CurrentSemanticValue.scd = new simple_const_definition(ValueStack[ValueStack.Depth-4].id,ValueStack[ValueStack.Depth-2].ex,CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 50: // ConstDeclarations -> ConstDecl
|
||
{
|
||
CurrentSemanticValue.cdl = new consts_definitions_list(ValueStack[ValueStack.Depth-1].scd,CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 51: // ConstDeclarations -> ConstDeclarations, ConstDecl
|
||
{
|
||
ValueStack[ValueStack.Depth-2].cdl.Add(ValueStack[ValueStack.Depth-1].scd,CurrentLocationSpan);
|
||
CurrentSemanticValue.cdl = ValueStack[ValueStack.Depth-2].cdl;
|
||
}
|
||
break;
|
||
case 52: // ConstDeclarationsSect -> CONST, ConstDeclarations
|
||
{
|
||
CurrentSemanticValue.cdl = ValueStack[ValueStack.Depth-1].cdl;
|
||
CurrentSemanticValue.cdl.source_context = CurrentLocationSpan;
|
||
}
|
||
break;
|
||
case 53: // VarDeclarationsSect -> VAR, VarDeclarations
|
||
{
|
||
CurrentSemanticValue.vdss = ValueStack[ValueStack.Depth-1].vdss;
|
||
CurrentSemanticValue.vdss.source_context = CurrentLocationSpan;
|
||
}
|
||
break;
|
||
case 54: // Declarations -> VarDeclarationsSect
|
||
{
|
||
CurrentSemanticValue.decl = new declarations(ValueStack[ValueStack.Depth-1].vdss,CurrentLocationSpan);
|
||
}
|
||
break;
|
||
case 55: // Declarations -> ConstDeclarationsSect, VarDeclarationsSect
|
||
{
|
||
CurrentSemanticValue.decl = new declarations(ValueStack[ValueStack.Depth-1].vdss,CurrentLocationSpan);
|
||
CurrentSemanticValue.decl.Add(ValueStack[ValueStack.Depth-1].vdss);
|
||
// $$.source_context = @$;
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
|
||
protected override string TerminalToString(int terminal)
|
||
{
|
||
if (aliasses != null && aliasses.ContainsKey(terminal))
|
||
return aliasses[terminal];
|
||
else if (((Tokens)terminal).ToString() != terminal.ToString(CultureInfo.InvariantCulture))
|
||
return ((Tokens)terminal).ToString();
|
||
else
|
||
return CharToString((char)terminal);
|
||
}
|
||
|
||
}
|
||
}
|