public void VisitBreak(BreakNode node) { int breakIndex = _functionBuilder.AddInstruction(OpCode.JUMP); _breaks.Push(breakIndex); _functionBuilder.AddDebugSymbol(breakIndex, node); }
private void AnalyzeBreak(BreakNode breakNode) { if (s_loopStack.Count == 0) { return; //TODO:报错 没有要中断或继续的封闭循环 } breakNode.Loop = s_loopStack.Peek(); }
public BreakBuilder(BreakNode breaknode) { node = breaknode; DotDefinition = new List <IDotElement>(); CreateNode(); CreateEdgeToNextSibling(); CreateSpecialEdge(); }
public override DynValue Visit(BreakNode breakNode) { if (!Environment.IsInsideLoop) { throw new RuntimeException("Unexpected 'break' outside a loop.", breakNode.Line); } Environment.LoopStackTop.Break(); return(DynValue.Zero); }
public override DynValue Visit(BreakNode breakNode) { if (LoopStack.Count <= 0) { throw new RuntimeException("Unexpected 'break' outside a loop.", breakNode.Line); } LoopStack.Peek().BreakLoop = true; return(DynValue.Zero); }
public void VisitBreak(BreakNode node) { // Don't insert unreachable code if (!_builder.InsertBlock.IsValid) { return; } SetCurrentDebugLocation(node); _builder.BuildBr(_breakContinueTop.BreakBlock); _builder.ClearInsertionPosition(); }
public void VisitBreak(BreakNode node) { UpdateLine(node); asm.Jump(loop.End); }
public virtual void VisitBreak(BreakNode node) { VisitDefaultStatement(node); }
public bool VisitBreakNode(BreakNode node, CompilationState state) { state.Write("break"); return(true); }
public void VisitBreak(BreakNode node) { _scopeManager.SetScope(node, _currentScope); }
public void VisitBreak(BreakNode node) { BreakVisitor?.Visit(node); }
public abstract DynValue Visit(BreakNode breakNode);
private RuntimeResult VisitBreakNode(BreakNode node, Context context) { context.Break = true; return(new RuntimeResult(new Values.NullValue().SetPositionAndContext(node.Position, context))); }
public void Accept(BreakNode node) { emit(node.SourceLocation, InstructionType.Jump, methodStack.Peek().BreakLabels.Pop()); }
// $ANTLR start "breakStatement" // JavaScript.g:156:1: breakStatement : 'break' ( ( Identifier )=> Identifier | ) statementEnd ; public JavaScriptParser.breakStatement_return breakStatement() // throws RecognitionException [1] { JavaScriptParser.breakStatement_return retval = new JavaScriptParser.breakStatement_return(); retval.Start = input.LT(1); object root_0 = null; IToken string_literal159 = null; IToken Identifier160 = null; JavaScriptParser.statementEnd_return statementEnd161 = default(JavaScriptParser.statementEnd_return); object string_literal159_tree=null; object Identifier160_tree=null; try { // JavaScript.g:157:2: ( 'break' ( ( Identifier )=> Identifier | ) statementEnd ) // JavaScript.g:157:4: 'break' ( ( Identifier )=> Identifier | ) statementEnd { root_0 = (object)adaptor.GetNilNode(); string_literal159=(IToken)Match(input,55,FOLLOW_55_in_breakStatement1264); if (state.failed) return retval; if ( state.backtracking == 0 ) {string_literal159_tree = new BreakNode(string_literal159) ; root_0 = (object)adaptor.BecomeRoot(string_literal159_tree, root_0); } // JavaScript.g:157:24: ( ( Identifier )=> Identifier | ) int alt83 = 2; int LA83_0 = input.LA(1); if ( (LA83_0 == Identifier) ) { int LA83_1 = input.LA(2); if ( (synpred11_JavaScript()) ) { alt83 = 1; } else if ( (true) ) { alt83 = 2; } else { if ( state.backtracking > 0 ) {state.failed = true; return retval;} NoViableAltException nvae_d83s1 = new NoViableAltException("", 83, 1, input); throw nvae_d83s1; } } else if ( (LA83_0 == EOF || LA83_0 == LT || (LA83_0 >= StringLiteral && LA83_0 <= RegexLiteral) || (LA83_0 >= 39 && LA83_0 <= 42) || LA83_0 == 45 || (LA83_0 >= 47 && LA83_0 <= 52) || (LA83_0 >= 54 && LA83_0 <= 57) || (LA83_0 >= 59 && LA83_0 <= 63) || (LA83_0 >= 66 && LA83_0 <= 67) || (LA83_0 >= 99 && LA83_0 <= 100) || (LA83_0 >= 104 && LA83_0 <= 114)) ) { alt83 = 2; } else { if ( state.backtracking > 0 ) {state.failed = true; return retval;} NoViableAltException nvae_d83s0 = new NoViableAltException("", 83, 0, input); throw nvae_d83s0; } switch (alt83) { case 1 : // JavaScript.g:157:25: ( Identifier )=> Identifier { Identifier160=(IToken)Match(input,Identifier,FOLLOW_Identifier_in_breakStatement1277); if (state.failed) return retval; if ( state.backtracking == 0 ) {Identifier160_tree = (object)adaptor.Create(Identifier160); adaptor.AddChild(root_0, Identifier160_tree); } } break; case 2 : // JavaScript.g:157:58: { } break; } PushFollow(FOLLOW_statementEnd_in_breakStatement1284); statementEnd161 = statementEnd(); state.followingStackPointer--; if (state.failed) return retval; } retval.Stop = input.LT(-1); if ( (state.backtracking==0) ) { retval.Tree = (object)adaptor.RulePostProcessing(root_0); adaptor.SetTokenBoundaries(retval.Tree, (IToken) retval.Start, (IToken) retval.Stop);} } catch (RecognitionException re) { ReportError(re); Recover(input,re); // Conversion of the second argument necessary, but harmless retval.Tree = (object)adaptor.ErrorNode(input, (IToken) retval.Start, input.LT(-1), re); } finally { } return retval; }
// throws RecognitionException [1] // $ANTLR end "expr_dm" // $ANTLR start "expr" // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:167:1: expr returns [TigerNode exp] : ( STR | INT | id1= ID ( ( COR_A expr_or COR_C OF )=> COR_A idexp1= expr_or COR_C OF idexp= expr_or | idp4= ptocor ida1= asig | LLAV_A fieldlist LLAV_C idp1= ptocor | PAR_A exprlist PAR_C idp3= ptocor ) | MENOS expr_or | BREAK | NIL | PAR_A exprseq PAR_C idp9= ptocor | IF idif= expr_or THEN idthen= expr_or ifthenelse | WHILE idexp3= expr_or DO iddo= expr_or | FOR id5= ID ASIG idasig= expr_or TO idto= expr_or DO iddo= expr_or | LET decllist IN exprseq END ); public TigerNode expr() { TigerNode exp = null; IToken id1 = null; IToken id5 = null; IToken STR14 = null; IToken INT15 = null; IToken MENOS19 = null; IToken BREAK20 = null; IToken NIL21 = null; IToken PAR_A23 = null; IToken IF25 = null; IToken WHILE26 = null; IToken FOR27 = null; IToken LET30 = null; TigerNode idexp1 = null; TigerNode idexp = null; List<Access> idp4 = null; AssingmentNode ida1 = null; List<Access> idp1 = null; List<Access> idp3 = null; List<Access> idp9 = null; TigerNode idif = null; TigerNode idthen = null; TigerNode idexp3 = null; TigerNode iddo = null; TigerNode idasig = null; TigerNode idto = null; tiger_grammarParser.fieldlist_return fieldlist16 = null; List<TigerNode> exprlist17 = null; TigerNode expr_or18 = null; List<TigerNode> exprseq22 = null; TigerNode ifthenelse24 = null; List<DeclarationNode> decllist28 = null; List<TigerNode> exprseq29 = null; try { // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:167:30: ( STR | INT | id1= ID ( ( COR_A expr_or COR_C OF )=> COR_A idexp1= expr_or COR_C OF idexp= expr_or | idp4= ptocor ida1= asig | LLAV_A fieldlist LLAV_C idp1= ptocor | PAR_A exprlist PAR_C idp3= ptocor ) | MENOS expr_or | BREAK | NIL | PAR_A exprseq PAR_C idp9= ptocor | IF idif= expr_or THEN idthen= expr_or ifthenelse | WHILE idexp3= expr_or DO iddo= expr_or | FOR id5= ID ASIG idasig= expr_or TO idto= expr_or DO iddo= expr_or | LET decllist IN exprseq END ) int alt8 = 11; switch ( input.LA(1) ) { case STR: { alt8 = 1; } break; case INT: { alt8 = 2; } break; case ID: { alt8 = 3; } break; case MENOS: { alt8 = 4; } break; case BREAK: { alt8 = 5; } break; case NIL: { alt8 = 6; } break; case PAR_A: { alt8 = 7; } break; case IF: { alt8 = 8; } break; case WHILE: { alt8 = 9; } break; case FOR: { alt8 = 10; } break; case LET: { alt8 = 11; } break; default: if ( state.backtracking > 0 ) {state.failed = true; return exp;} NoViableAltException nvae_d8s0 = new NoViableAltException("", 8, 0, input); throw nvae_d8s0; } switch (alt8) { case 1 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:168:13: STR { STR14=(IToken)Match(input,STR,FOLLOW_STR_in_expr1153); if (state.failed) return exp; if ( (state.backtracking==0) ) { string s = STR14.Text; string[] t = s.Split('"'); exp = new StringNode(t[1]); exp.Col=STR14.CharPositionInLine; exp.Row=STR14.Line; } } break; case 2 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:175:13: INT { INT15=(IToken)Match(input,INT,FOLLOW_INT_in_expr1172); if (state.failed) return exp; if ( (state.backtracking==0) ) { exp = new IntNode(int.Parse(INT15.Text)); exp.Col=INT15.CharPositionInLine; exp.Row=INT15.Line; } } break; case 3 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:180:13: id1= ID ( ( COR_A expr_or COR_C OF )=> COR_A idexp1= expr_or COR_C OF idexp= expr_or | idp4= ptocor ida1= asig | LLAV_A fieldlist LLAV_C idp1= ptocor | PAR_A exprlist PAR_C idp3= ptocor ) { id1=(IToken)Match(input,ID,FOLLOW_ID_in_expr1204); if (state.failed) return exp; // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:180:20: ( ( COR_A expr_or COR_C OF )=> COR_A idexp1= expr_or COR_C OF idexp= expr_or | idp4= ptocor ida1= asig | LLAV_A fieldlist LLAV_C idp1= ptocor | PAR_A exprlist PAR_C idp3= ptocor ) int alt7 = 4; alt7 = dfa7.Predict(input); switch (alt7) { case 1 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:181:24: ( COR_A expr_or COR_C OF )=> COR_A idexp1= expr_or COR_C OF idexp= expr_or { Match(input,COR_A,FOLLOW_COR_A_in_expr1245); if (state.failed) return exp; PushFollow(FOLLOW_expr_or_in_expr1249); idexp1 = expr_or(); state.followingStackPointer--; if (state.failed) return exp; Match(input,COR_C,FOLLOW_COR_C_in_expr1251); if (state.failed) return exp; Match(input,OF,FOLLOW_OF_in_expr1253); if (state.failed) return exp; PushFollow(FOLLOW_expr_or_in_expr1257); idexp = expr_or(); state.followingStackPointer--; if (state.failed) return exp; if ( (state.backtracking==0) ) { exp = new ArrayNode(id1.Text,idexp1,idexp); exp.Col=id1.CharPositionInLine; exp.Row=id1.Line; } } break; case 2 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:186:24: idp4= ptocor ida1= asig { PushFollow(FOLLOW_ptocor_in_expr1318); idp4 = ptocor(); state.followingStackPointer--; if (state.failed) return exp; PushFollow(FOLLOW_asig_in_expr1322); ida1 = asig(); state.followingStackPointer--; if (state.failed) return exp; if ( (state.backtracking==0) ) { if(idp4.Count > 0 && ida1 !=null) { exp = ida1; ((AssingmentNode)exp).LeftExpr = new ListLValueNode(new VariableNode(id1.Text),idp4); exp.Col=id1.CharPositionInLine; exp.Row=id1.Line; } else if(idp4.Count > 0) { exp = new ListLValueNode(new VariableNode(id1.Text),idp4); exp.Col=id1.CharPositionInLine; exp.Row=id1.Line; } else if(ida1 !=null) { exp = ida1; ((AssingmentNode)exp).LeftExpr = new VariableNode(id1.Text); exp.Col=id1.CharPositionInLine; exp.Row=id1.Line; } else { exp = new VariableNode(id1.Text); exp.Col=id1.CharPositionInLine; exp.Row=id1.Line; } } } break; case 3 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:211:23: LLAV_A fieldlist LLAV_C idp1= ptocor { Match(input,LLAV_A,FOLLOW_LLAV_A_in_expr1349); if (state.failed) return exp; PushFollow(FOLLOW_fieldlist_in_expr1351); fieldlist16 = fieldlist(); state.followingStackPointer--; if (state.failed) return exp; Match(input,LLAV_C,FOLLOW_LLAV_C_in_expr1353); if (state.failed) return exp; PushFollow(FOLLOW_ptocor_in_expr1357); idp1 = ptocor(); state.followingStackPointer--; if (state.failed) return exp; if ( (state.backtracking==0) ) { if(idp1.Count > 0) { exp = new ListLValueNode(new RecordNode(id1.Text, ((fieldlist16 != null) ? fieldlist16.listid : null), ((fieldlist16 != null) ? fieldlist16.listexp : null)),idp1); exp.Col=id1.CharPositionInLine; exp.Row=id1.Line; } else{ exp = new RecordNode(id1.Text, ((fieldlist16 != null) ? fieldlist16.listid : null), ((fieldlist16 != null) ? fieldlist16.listexp : null)); exp.Col=id1.CharPositionInLine; exp.Row=id1.Line; } } } break; case 4 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:221:22: PAR_A exprlist PAR_C idp3= ptocor { Match(input,PAR_A,FOLLOW_PAR_A_in_expr1382); if (state.failed) return exp; PushFollow(FOLLOW_exprlist_in_expr1384); exprlist17 = exprlist(); state.followingStackPointer--; if (state.failed) return exp; Match(input,PAR_C,FOLLOW_PAR_C_in_expr1386); if (state.failed) return exp; PushFollow(FOLLOW_ptocor_in_expr1390); idp3 = ptocor(); state.followingStackPointer--; if (state.failed) return exp; if ( (state.backtracking==0) ) { if(idp3.Count > 0) { exp = new ListLValueNode(new CallFunctionNode(id1.Text, exprlist17),idp3); exp.Col=id1.CharPositionInLine; exp.Row=id1.Line; } else{ exp = new CallFunctionNode(id1.Text, exprlist17); exp.Col=id1.CharPositionInLine; exp.Row=id1.Line; } } } break; } } break; case 4 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:233:13: MENOS expr_or { MENOS19=(IToken)Match(input,MENOS,FOLLOW_MENOS_in_expr1446); if (state.failed) return exp; PushFollow(FOLLOW_expr_or_in_expr1448); expr_or18 = expr_or(); state.followingStackPointer--; if (state.failed) return exp; if ( (state.backtracking==0) ) { exp = new MinusUnaryNode(expr_or18); exp.Col=MENOS19.CharPositionInLine; exp.Row = MENOS19.Line; } } break; case 5 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:239:13: BREAK { BREAK20=(IToken)Match(input,BREAK,FOLLOW_BREAK_in_expr1478); if (state.failed) return exp; if ( (state.backtracking==0) ) { exp = new BreakNode(); exp.Col=BREAK20.CharPositionInLine; exp.Row = BREAK20.Line; } } break; case 6 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:245:13: NIL { NIL21=(IToken)Match(input,NIL,FOLLOW_NIL_in_expr1508); if (state.failed) return exp; if ( (state.backtracking==0) ) { exp = new NilNode(); exp.Col=NIL21.CharPositionInLine; exp.Row = NIL21.Line; } } break; case 7 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:251:13: PAR_A exprseq PAR_C idp9= ptocor { PAR_A23=(IToken)Match(input,PAR_A,FOLLOW_PAR_A_in_expr1538); if (state.failed) return exp; PushFollow(FOLLOW_exprseq_in_expr1540); exprseq22 = exprseq(); state.followingStackPointer--; if (state.failed) return exp; Match(input,PAR_C,FOLLOW_PAR_C_in_expr1542); if (state.failed) return exp; PushFollow(FOLLOW_ptocor_in_expr1546); idp9 = ptocor(); state.followingStackPointer--; if (state.failed) return exp; if ( (state.backtracking==0) ) { if(idp9.Count > 0) { exp = new ListLValueNode(new ExprSeqNode(exprseq22),idp9); exp.Col=PAR_A23.CharPositionInLine; exp.Row = PAR_A23.Line; } else{ exp = new ExprSeqNode(exprseq22); exp.Col=PAR_A23.CharPositionInLine; exp.Row = PAR_A23.Line; } } } break; case 8 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:265:13: IF idif= expr_or THEN idthen= expr_or ifthenelse { IF25=(IToken)Match(input,IF,FOLLOW_IF_in_expr1577); if (state.failed) return exp; PushFollow(FOLLOW_expr_or_in_expr1581); idif = expr_or(); state.followingStackPointer--; if (state.failed) return exp; Match(input,THEN,FOLLOW_THEN_in_expr1583); if (state.failed) return exp; PushFollow(FOLLOW_expr_or_in_expr1587); idthen = expr_or(); state.followingStackPointer--; if (state.failed) return exp; PushFollow(FOLLOW_ifthenelse_in_expr1589); ifthenelse24 = ifthenelse(); state.followingStackPointer--; if (state.failed) return exp; if ( (state.backtracking==0) ) { if(ifthenelse24!=null) { exp = new IfThenElseNode(idif, idthen, ifthenelse24); } else{ exp = new IfThenNode(idif, idthen); } exp.Col = IF25.CharPositionInLine; exp.Row = IF25.Line; } } break; case 9 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:278:13: WHILE idexp3= expr_or DO iddo= expr_or { WHILE26=(IToken)Match(input,WHILE,FOLLOW_WHILE_in_expr1627); if (state.failed) return exp; PushFollow(FOLLOW_expr_or_in_expr1631); idexp3 = expr_or(); state.followingStackPointer--; if (state.failed) return exp; Match(input,DO,FOLLOW_DO_in_expr1633); if (state.failed) return exp; PushFollow(FOLLOW_expr_or_in_expr1637); iddo = expr_or(); state.followingStackPointer--; if (state.failed) return exp; if ( (state.backtracking==0) ) { exp = new WhileNode(idexp3,iddo); exp.Col = WHILE26.CharPositionInLine; exp.Row = WHILE26.Line; } } break; case 10 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:283:13: FOR id5= ID ASIG idasig= expr_or TO idto= expr_or DO iddo= expr_or { FOR27=(IToken)Match(input,FOR,FOLLOW_FOR_in_expr1665); if (state.failed) return exp; id5=(IToken)Match(input,ID,FOLLOW_ID_in_expr1669); if (state.failed) return exp; Match(input,ASIG,FOLLOW_ASIG_in_expr1671); if (state.failed) return exp; PushFollow(FOLLOW_expr_or_in_expr1675); idasig = expr_or(); state.followingStackPointer--; if (state.failed) return exp; Match(input,TO,FOLLOW_TO_in_expr1677); if (state.failed) return exp; PushFollow(FOLLOW_expr_or_in_expr1681); idto = expr_or(); state.followingStackPointer--; if (state.failed) return exp; Match(input,DO,FOLLOW_DO_in_expr1683); if (state.failed) return exp; PushFollow(FOLLOW_expr_or_in_expr1687); iddo = expr_or(); state.followingStackPointer--; if (state.failed) return exp; if ( (state.backtracking==0) ) { exp = new ForNode(id5.Text,idasig,idto,iddo); exp.Col = FOR27.CharPositionInLine; exp.Row = FOR27.Line; } } break; case 11 : // C:\\Users\\Danaice\\Desktop\\lastversion\\Dany_gramatica tiger ANTLR oficial\\tiger_grammar.g:289:13: LET decllist IN exprseq END { LET30=(IToken)Match(input,LET,FOLLOW_LET_in_expr1716); if (state.failed) return exp; PushFollow(FOLLOW_decllist_in_expr1718); decllist28 = decllist(); state.followingStackPointer--; if (state.failed) return exp; Match(input,IN,FOLLOW_IN_in_expr1720); if (state.failed) return exp; PushFollow(FOLLOW_exprseq_in_expr1722); exprseq29 = exprseq(); state.followingStackPointer--; if (state.failed) return exp; Match(input,END,FOLLOW_END_in_expr1725); if (state.failed) return exp; if ( (state.backtracking==0) ) { exp = new LetNode(decllist28,exprseq29); exp.Col= LET30.CharPositionInLine; exp.Row = LET30.Line; } } break; } } catch (RecognitionException re) { ReportError(re); Recover(input,re); } finally { } return exp; }
public BreakNodeTests() { subject = new BreakNode(SourcePosition.NIL); }
public void VisitBreak(BreakNode node) { _visitor.VisitStatement(node); }
public void VisitBreak(BreakNode node) { }
public BreakCompiler(BreakNode node) { this.node = node; }
public Word Visit(BreakNode breakNode) { return(new Breaker()); }
public virtual void VisitBreakNode(BreakNode node) { DefaultVisit(node); }
public virtual bool VisitBreakNode(BreakNode node) { return(DefaultVisit(node)); }
public void VisitBreak(BreakNode node) { Print("Break"); }
public void VisitBreak(BreakNode node) { VisitBreakHandler(node); }
public virtual XzaarExpression Visit(BreakNode breakNode) { return(null); }
public virtual BreakNode Visit(BreakNode node) { return(node); }