コード例 #1
0
        public expression ParseExpression(string Text, int line, int col)
        {
            PT parsertools = new PT(); // контекст сканера и парсера

            parsertools.errors          = new List <Error>();
            parsertools.warnings        = new List <CompilerWarning>();
            parsertools.CurrentFileName = System.IO.Path.GetFullPath(this.parsertools.CurrentFileName);
            parsertools.build_tree_for_format_strings = true;
            Scanner scanner = new Scanner();

            scanner.SetSource("<<expression>>" + Text, 0);
            scanner.parsertools = parsertools;// передали parsertools в объект сканера
            GPPGParser parser = new GPPGParser(scanner);

            parsertools.build_tree_for_formatter = false;
            parser.lambdaHelper = this.lambdaHelper;
            parser.parsertools  = parsertools;
            if (!parser.Parse())
            {
                if (parsertools.errors.Count == 0)
                {
                    parsertools.AddError("Неопознанная синтаксическая ошибка!", null);
                }
            }
            foreach (Error err in parsertools.errors)
            {
                this.parsertools.errors.Add(err);
            }
            return(parser.root as expression);
        }
コード例 #2
0
        public bool Parse(string Text)
        {
            compilerDirectives = new List <compiler_directive>();

            PT parsertools = new PT(); // контекст сканера и парсера

            parsertools.errors          = Errs;
            parsertools.CurrentFileName = Path.GetFullPath(FileName);

            var scanner = new PreprocessorScanner();

            scanner.SetSource(Text, 0);
            //scanner.parsertools = parsertools;// передали parsertools в объект сканера

            var parser = new PreprocessorParser(scanner);

            parser.compilerDirectives = compilerDirectives;
            //parser.parsertools = parsertools; // передали parsertools в объект парсера

            if (!parser.Parse())
            {
                parsertools.AddError("Неопознанная синтаксическая ошибка препроцессора!", null);
                return(false);
            }
            return(true);
        }
コード例 #3
0
ファイル: Parser.cs プロジェクト: spectatorBH/pascalabcnet
        public syntax_tree_node Parse(string Text, List <compiler_directive> compilerDirectives = null)
        {
#if DEBUG
#if _ERR
            FileInfo f  = new FileInfo(FileName);
            var      sv = Path.ChangeExtension(FileName, ".grmtrack1");
            var      sw = new StreamWriter(sv);
            Console.SetError(sw);
#endif
#endif
            PT parsertools = new PT(); // контекст сканера и парсера
            parsertools.errors             = Errs;
            parsertools.warnings           = Warnings;
            parsertools.compilerDirectives = compilerDirectives;
            parsertools.CurrentFileName    = Path.GetFullPath(FileName);


            Scanner scanner = new Scanner();
            scanner.SetSource(Text, 0);
            scanner.parsertools = parsertools;// передали parsertools в объект сканера
            if (DefinesList != null)
            {
                scanner.Defines.AddRange(DefinesList);
            }
            GPPGParser parser = new GPPGParser(scanner);
            parsertools.build_tree_for_formatter = build_tree_for_formatter;
            parser.parsertools = parsertools; // передали parsertools в объект парсера

            if (!parser.Parse())
            {
                if (Errs.Count == 0)
                {
                    parsertools.AddError("Неопознанная синтаксическая ошибка!", null);
                }
            }
#if DEBUG
#if _ERR
            sw.Close();
#endif
#endif
            return(parser.root);
        }
コード例 #4
0
        protected override void DoAction(int action)
        {
            switch (action)
            {
            case 2: // module -> MODULE, ident, SEMICOLUMN, mainblock, ident, COMMA
            {
                if (ValueStack[ValueStack.Depth - 5].id.name != ValueStack[ValueStack.Depth - 2].id.name)
                {
                    PT.AddError("Имя " + ValueStack[ValueStack.Depth - 2].id.name + " должно совпадать с именем модуля " + ValueStack[ValueStack.Depth - 5].id.name, LocationStack[LocationStack.Depth - 2]);
                }

                // Подключение стандартного модуля Oberon00System, написанного на PascalABC.NET
                var ul = new uses_list("Oberon00System");

                // Формирование модуля основной программы (используется фабричный метод вместо конструктора)
                root = program_module.create(ValueStack[ValueStack.Depth - 5].id, ul, ValueStack[ValueStack.Depth - 3].bl, CurrentLocationSpan);
            }
            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: // mainblock -> Declarations, BEGIN, StatementSequence, END
            {
                CurrentSemanticValue.bl = new block(ValueStack[ValueStack.Depth - 4].decl, ValueStack[ValueStack.Depth - 2].sl, CurrentLocationSpan);
            }
            break;

            case 6: // SetConstant -> LBRACE, SetElemList, RBRACE
            {
                CurrentSemanticValue.sc = ValueStack[ValueStack.Depth - 2].sc;
            }
            break;

            case 7: // SetElemList -> SetElem
            {
                CurrentSemanticValue.sc = new pascal_set_constant();
                CurrentSemanticValue.sc.Add(ValueStack[ValueStack.Depth - 1].ex);
            }
            break;

            case 8: // SetElemList -> SetElemList, COLUMN, SetElem
            {
                CurrentSemanticValue.sc = ValueStack[ValueStack.Depth - 3].sc;
                CurrentSemanticValue.sc.Add(ValueStack[ValueStack.Depth - 1].ex);
            }
            break;

            case 9: // SetElemList -> /* empty */
            {
                CurrentSemanticValue.sc = new pascal_set_constant();
            }
            break;

            case 11: // SetElem -> expr, DOUBLEPOINT, expr
            {
                CurrentSemanticValue.ex = new diapason_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex);
            }
            break;

            case 12: // expr -> ident
            {
                CurrentSemanticValue.ex = ValueStack[ValueStack.Depth - 1].id;
            }
            break;

            case 13: // expr -> INTNUM
            {
                CurrentSemanticValue.ex = new int32_const(ValueStack[ValueStack.Depth - 1].iVal, CurrentLocationSpan);
            }
            break;

            case 14: // expr -> LONGINTNUM
            {
                CurrentSemanticValue.ex = new int64_const(ValueStack[ValueStack.Depth - 1].lVal, CurrentLocationSpan);
            }
            break;

            case 15: // expr -> REALNUM
            {
                CurrentSemanticValue.ex = new double_const(ValueStack[ValueStack.Depth - 1].rVal, CurrentLocationSpan);
            }
            break;

            case 16: // expr -> TRUE
            {
                CurrentSemanticValue.ex = new bool_const(true, CurrentLocationSpan);
            }
            break;

            case 17: // expr -> FALSE
            {
                CurrentSemanticValue.ex = new bool_const(false, CurrentLocationSpan);
            }
            break;

            case 18: // expr -> CHAR_CONST
            {
                CurrentSemanticValue.ex = new char_const(ValueStack[ValueStack.Depth - 1].cVal, CurrentLocationSpan);
            }
            break;

            case 19: // expr -> STRING_CONST
            {
                CurrentSemanticValue.ex = new string_const(ValueStack[ValueStack.Depth - 1].sVal, CurrentLocationSpan);
            }
            break;

            case 20: // expr -> MINUS, expr
            {
                CurrentSemanticValue.ex = new un_expr(ValueStack[ValueStack.Depth - 1].ex, Operators.Minus, CurrentLocationSpan);
            }
            break;

            case 21: // expr -> PLUS, expr
            {
                CurrentSemanticValue.ex = new un_expr(ValueStack[ValueStack.Depth - 1].ex, Operators.Plus, CurrentLocationSpan);
            }
            break;

            case 22: // expr -> LPAREN, expr, RPAREN
            { CurrentSemanticValue.ex = ValueStack[ValueStack.Depth - 2].ex; }
            break;

            case 23: // expr -> NOT, expr
            {
                CurrentSemanticValue.ex = new un_expr(ValueStack[ValueStack.Depth - 1].ex, Operators.LogicalNOT, CurrentLocationSpan);
            }
            break;

            case 24: // expr -> expr, PLUS, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.Plus, CurrentLocationSpan);
            }
            break;

            case 25: // expr -> expr, MINUS, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.Minus, CurrentLocationSpan);
            }
            break;

            case 26: // expr -> expr, MULT, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.Multiplication, CurrentLocationSpan);
            }
            break;

            case 27: // expr -> expr, DIVIDE, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.Division, CurrentLocationSpan);
            }
            break;

            case 28: // expr -> expr, DIV, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.IntegerDivision, CurrentLocationSpan);
            }
            break;

            case 29: // expr -> expr, MOD, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.ModulusRemainder, CurrentLocationSpan);
            }
            break;

            case 30: // expr -> expr, AND, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.LogicalAND, CurrentLocationSpan);
            }
            break;

            case 31: // expr -> expr, OR, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.LogicalOR, CurrentLocationSpan);
            }
            break;

            case 32: // expr -> expr, EQ, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.Equal, CurrentLocationSpan);
            }
            break;

            case 33: // expr -> expr, NE, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.NotEqual, CurrentLocationSpan);
            }
            break;

            case 34: // expr -> expr, LT, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.Less, CurrentLocationSpan);
            }
            break;

            case 35: // expr -> expr, LE, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.LessEqual, CurrentLocationSpan);
            }
            break;

            case 36: // expr -> expr, GT, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.Greater, CurrentLocationSpan);
            }
            break;

            case 37: // expr -> expr, GE, expr
            {
                CurrentSemanticValue.ex = new bin_expr(ValueStack[ValueStack.Depth - 3].ex, ValueStack[ValueStack.Depth - 1].ex, Operators.GreaterEqual, CurrentLocationSpan);
            }
            break;

            case 39: // Assignment -> ident, ASSIGN, expr
            {
                CurrentSemanticValue.st = new assign(ValueStack[ValueStack.Depth - 3].id, ValueStack[ValueStack.Depth - 1].ex, Operators.Assignment, CurrentLocationSpan);
            }
            break;

            case 40: // 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 41: // 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 42: // 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 43: // 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 44: // factparams -> expr
            {
                CurrentSemanticValue.el = new expression_list(ValueStack[ValueStack.Depth - 1].ex, CurrentLocationSpan);
            }
            break;

            case 45: // 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 46: // ProcCallStatement -> ident, LPAREN, factparams, RPAREN
            {
                CurrentSemanticValue.st = new method_call(ValueStack[ValueStack.Depth - 4].id, ValueStack[ValueStack.Depth - 2].el, CurrentLocationSpan);
            }
            break;

            case 47: // EmptyStatement -> /* empty */
            {
                CurrentSemanticValue.st = new empty_statement();
            }
            break;

            case 54: // StatementSequence -> Statement
            {
                CurrentSemanticValue.sl = new statement_list(ValueStack[ValueStack.Depth - 1].st, CurrentLocationSpan);
            }
            break;

            case 55: // 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 56: // type -> ID
            {
                CurrentSemanticValue.ntr = new named_type_reference(PT.InternalTypeName(ValueStack[ValueStack.Depth - 1].sVal), CurrentLocationSpan);
            }
            break;

            case 57: // IDList -> ident
            {
                CurrentSemanticValue.il = new ident_list(ValueStack[ValueStack.Depth - 1].id, CurrentLocationSpan);
            }
            break;

            case 58: // 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 59: // 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 60: // VarDeclarations -> VarDecl
            {
                CurrentSemanticValue.vdss = new variable_definitions(ValueStack[ValueStack.Depth - 1].vds, CurrentLocationSpan);
            }
            break;

            case 61: // VarDeclarations -> VarDeclarations, VarDecl
            {
                ValueStack[ValueStack.Depth - 2].vdss.Add(ValueStack[ValueStack.Depth - 1].vds, CurrentLocationSpan);
                CurrentSemanticValue.vdss = ValueStack[ValueStack.Depth - 2].vdss;
            }
            break;

            case 62: // ConstDecl -> ident, EQ, ConstExpr, SEMICOLUMN
            {
                CurrentSemanticValue.scd = new simple_const_definition(ValueStack[ValueStack.Depth - 4].id, ValueStack[ValueStack.Depth - 2].ex, CurrentLocationSpan);
            }
            break;

            case 64: // ConstDeclarations -> ConstDecl
            {
                CurrentSemanticValue.cdl = new consts_definitions_list(ValueStack[ValueStack.Depth - 1].scd, CurrentLocationSpan);
            }
            break;

            case 65: // ConstDeclarations -> ConstDeclarations, ConstDecl
            {
                ValueStack[ValueStack.Depth - 2].cdl.Add(ValueStack[ValueStack.Depth - 1].scd, CurrentLocationSpan);
                CurrentSemanticValue.cdl = ValueStack[ValueStack.Depth - 2].cdl;
            }
            break;

            case 66: // ConstDeclarationsSect -> CONST, ConstDeclarations
            {
                CurrentSemanticValue.cdl = ValueStack[ValueStack.Depth - 1].cdl;
                CurrentSemanticValue.cdl.source_context = CurrentLocationSpan;
            }
            break;

            case 67: // VarDeclarationsSect -> VAR, VarDeclarations
            {
                CurrentSemanticValue.vdss = ValueStack[ValueStack.Depth - 1].vdss;
                CurrentSemanticValue.vdss.source_context = CurrentLocationSpan;
            }
            break;

            case 68: // DeclarationsSect -> VarDeclarationsSect
            {
                CurrentSemanticValue.decsec = ValueStack[ValueStack.Depth - 1].vdss;
            }
            break;

            case 69: // DeclarationsSect -> ConstDeclarationsSect
            {
                CurrentSemanticValue.decsec = ValueStack[ValueStack.Depth - 1].cdl;
            }
            break;

            case 70: // DeclarationsSect -> ProcedureDeclarationSect
            {
                CurrentSemanticValue.decsec = ValueStack[ValueStack.Depth - 1].pd;
            }
            break;

            case 71: // Declarations -> /* empty */
            {
                CurrentSemanticValue.decl = new declarations();
            }
            break;

            case 72: // Declarations -> Declarations, DeclarationsSect
            {
                if (ValueStack[ValueStack.Depth - 1].decsec != null)
                {
                    ValueStack[ValueStack.Depth - 2].decl.Add(ValueStack[ValueStack.Depth - 1].decsec);
                }
                CurrentSemanticValue.decl = ValueStack[ValueStack.Depth - 2].decl;
                CurrentSemanticValue.decl.source_context = CurrentLocationSpan;                 // Необходимо показать место в программе, т.к. невно это не сделано
                // (например, в конструкторе)
            }
            break;

            case 73: // ProcedureDeclarationSect -> PROCEDURE, ident, maybeformalparams, maybereturn,
                     //                             SEMICOLUMN, mainblock, ident, SEMICOLUMN
            {
            }
            break;

            case 74: // maybeformalparams -> /* empty */
            {
                //$$ = null;
            }
            break;

            case 75: // maybeformalparams -> LPAREN, FPList, RPAREN
            {
                //$$ = $2;
            }
            break;

            case 76: // maybereturn -> /* empty */
            {
            }
            break;

            case 77: // maybereturn -> COLUMN, type
            {
            }
            break;

            case 78: // FPList -> FPSect
            {
            }
            break;

            case 79: // FPList -> FPList, SEMICOLUMN, FPSect
            {
            }
            break;

            case 80: // FPSect -> maybevar, IDList, COLON, type
            {
            }
            break;

            case 81: // maybevar -> /* empty */
            {
                CurrentSemanticValue.bVal = false;
            }
            break;

            case 82: // maybevar -> VAR
            {
                CurrentSemanticValue.bVal = true;
            }
            break;
            }
        }
コード例 #5
0
        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;
            }
        }