public override void visit(uses_list _uses_list) { DefaultVisit(_uses_list); pre_do_visit(_uses_list); for (int i = 0; i < units.Count; i++) visit(uses_list.units[i]); post_do_visit(_uses_list); }
public virtual void post_do_visit(uses_list _uses_list) { }
public virtual void visit(uses_list _uses_list) { DefaultVisit(_uses_list); }
public virtual void visit(uses_list _uses_list) { }
public program_module NewProgramModule(program_name progName, Object optHeadCompDirs, uses_list mainUsesClose, syntax_tree_node progBlock, Object optPoint, LexLocation loc) { var progModule = new program_module(progName, mainUsesClose, progBlock as block, null, loc); progModule.Language = LanguageId.PascalABCNET; if (optPoint == null && progBlock != null) { var fp = progBlock.source_context.end_position; var err_stn = progBlock; if ((progBlock is block) && (progBlock as block).program_code != null && (progBlock as block).program_code.subnodes != null && (progBlock as block).program_code.subnodes.Count > 0) { err_stn = (progBlock as block).program_code.subnodes[(progBlock as block).program_code.subnodes.Count - 1]; } parsertools.errors.Add(new PABCNETUnexpectedToken(parsertools.CurrentFileName, StringResources.Get("TKPOINT"), new SourceContext(fp.line_num, fp.column_num + 1, fp.line_num, fp.column_num + 1, 0, 0), err_stn)); } return(progModule); }
public override void visit(uses_list _uses_list) { prepare_collection(_uses_list.units, "uses"); }
public override void visit(uses_list _uses_list) { get_count(_uses_list.units); }
public override void visit(uses_list _uses_list) { executer.visit(_uses_list); if (_uses_list.units != null) foreach (dynamic x in _uses_list.units) if(x != null) this.visit(x); }
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; } }