public void LoadSelectedBlock(ConditionalBlock block) { if (_conditionalSetIndex >= 0) { conditionalSetEditor.LoadBlock(block); } }
public void LoadBlock(ConditionalBlock block) { if ((_conditionalSet != null) && (_blockIndex >= 0)) { _conditionalSet.ConditionalBlocks[_blockIndex] = block; PopulateBlocks(_blockIndex); } }
private void AssertBlock(ConditionalBlock block, params SnapshotSpan[] spans) { Assert.Equal(spans.Length, block.Conditionals.Count); for (int i = 0; i < spans.Length; i++) { Assert.Equal(spans[i].Span, block.Conditionals[i].Span); } }
public void PasteCommandList(List <Command> commandList) { if ((_conditionalSet != null) && (_blockIndex >= 0)) { ConditionalBlock newBlock = new ConditionalBlock(_blockIndex, commandList); newBlock.FindName(_commandData.ParameterValueMaps, _ignoreParameterTypes); LoadBlock(newBlock); } }
public HtmlEngine(ViewCollection views) { this.views = views; RemoveComments = true; VariableNotFoundBehavior = VariableNotFoundBehavior.Source; conditionalBlock = new ConditionalBlock(this); eachBlock = new EachBlock(this); }
/// <summary> /// Parse une instruction if suivi de ses éventuels blocks else et elsif. /// </summary> public static Instruction ParseIfStatement(TokenList tokens, GlobalContext mainContext) { // Parse le if // On a a coup sûr : if + operand + block IfStatement statement = new IfStatement(); bool nextIsElse = false; int tokenId = 0; ConditionalBlock currentBlock = null; foreach (Token tok in tokens) { if (nextIsElse) { statement.ElseBlock = ParseBlock(((BlockGroupToken)tok).Tokens, mainContext);; } else { if (tokenId % 3 == 0) // if, else, elsif { currentBlock = new ConditionalBlock(); // Si le prochain jeton statement est un jeton else, alors on // prévient que c'est le cas pour la boucle suivante. if (((InfoToken)tok).Content == "else") { nextIsElse = true; } } else if (tokenId % 3 == 1) // operand { currentBlock.Condition = ParseExpression((OperandToken)tok, mainContext); } else if (tokenId % 3 == 2) // block { currentBlock.Block = ParseBlock(((BlockGroupToken)tok).Tokens, mainContext); statement.Blocks.Add(currentBlock); } } tokenId++; } return(statement); }
public void Visit(ConditionalBlock node) { VisitLuaFunction(node); }
public If ReadIf() { var location0 = Tokenizer.GetCurrentLocation(); if (!CurToken.IsPunctuation("if")) { ThrowExpect("if statement", CurToken); } Move(); var cond = ReadExpression(); if (!CurToken.IsPunctuation("then")) { ThrowExpect("'then' keyword", CurToken); } Move(); var location01 = Tokenizer.GetCurrentLocation(); var statements = new List <IStatement>(); while (!CurToken.IsPunctuation("else") && !CurToken.IsPunctuation("elseif") && !CurToken.IsPunctuation("end") && !CurToken.IsEOF()) { statements.Add(ReadStatement()); } var mainif_cond_block = new ConditionalBlock(location0) { Block = new Block(location01) { Statements = statements }, Condition = cond }; var elseifs = new List <ConditionalBlock>(); while (CurToken.IsPunctuation("elseif")) { var location02 = Tokenizer.GetCurrentLocation(); Move(); var elseif_cond = ReadExpression(); if (!CurToken.IsPunctuation("then")) { ThrowExpect("'then' keyword", CurToken); } Move(); var location03 = Tokenizer.GetCurrentLocation(); var elseif_statements = new List <IStatement>(); while (!CurToken.IsPunctuation("else") && !CurToken.IsPunctuation("elseif") && !CurToken.IsPunctuation("end") && !CurToken.IsEOF()) { elseif_statements.Add(ReadStatement()); } elseifs.Add(new ConditionalBlock(location02) { Block = new Block(location03) { Statements = elseif_statements }, Condition = elseif_cond }); } Block else_block = null; if (CurToken.IsPunctuation("else")) { Move(); var location1 = Tokenizer.GetCurrentLocation(); var else_statements = new List <IStatement>(); while (!CurToken.IsPunctuation("end") && !CurToken.IsEOF()) { else_statements.Add(ReadStatement()); } else_block = new Block(location1) { Statements = else_statements }; } if (!CurToken.IsPunctuation("end")) { ThrowExpect("'end' keyword", CurToken); } Move(); return(new If(location0) { MainIf = mainif_cond_block, ElseIfs = elseifs, Else = else_block }); }
private void AssertIf(ConditionalBlock conditionalBlock, int[] expected, int index) { if (conditionalBlock.IsEmpty) { Assert.True(index == expected.Length); } else { Assert.True(index < expected.Length); Assert.Equal(expected[index], conditionalBlock.LineCommands.Length); if (!conditionalBlock.IsUnconditional) { Assert.True(conditionalBlock.Next.IsSome()); AssertIf(conditionalBlock.Next.Value, expected, index + 1); } } }
public virtual void Visit(ConditionalBlock node) { }
private AbstractBlock ParseNode(XmlNode node) { String nodeType = ((XmlAttribute)node.Attributes.GetNamedItem("type")).Value; XmlAttribute a; switch (nodeType) { case "move_forward": return(new ActionBlock("move_forward")); case "move_backward": return(new ActionBlock("move_backward")); case "move_left": return(new ActionBlock("move_left")); case "move_right": return(new ActionBlock("move_right")); case "move_center": return(new ActionBlock("move_center")); case "move_closest_opponent": return(new ActionBlock("move_closest_opponent")); case "approach_ennemy": return(new ActionBlock("approach_ennemy")); case "flee_ennemy": return(new ActionBlock("flee_ennemy")); case "attack_closest_ennemy": return(new ActionBlock("attack_closest_ennemy")); case "attack_weakest_ennemy": return(new ActionBlock("attack_weakest_ennemy")); case "attack_strongest_ennemy": return(new ActionBlock("attack_strongest_ennemy")); case "wet_feet": return(new ActionBlock("wet_feet")); case "current_hitpoints": return(new ActionBlock("current_hitpoints")); case "ennemy_attack_range": return(new ActionBlock("ennemy_attack_range")); case "can_move_forward": return(new ActionBlock("can_move_forward")); case "can_move_backward": return(new ActionBlock("can_move_backward")); case "can_move_left": return(new ActionBlock("can_move_left")); case "can_move_right": return(new ActionBlock("can_move_right")); case "math_number": Field field = new Field() { Content = "", FieldName = "", FieldType = "" }; return(new FieldBlock("math_number", field)); } XmlNodeList children = node.ChildNodes; ConditionalBlock conditionalBlock = new ConditionalBlock { Value = new Value() { Name = "IF", Block = new LogicalBlock() { Type = "logic_compare", Field = new Field() { Content = "", FieldName = "", FieldType = "" }, LeftValue = new Value() { }, RightValue = new Value() { } } } }; return(conditionalBlock); }
private string EvaluateConditional(ConditionalBlock conditionalBlock) { return(EvaluateBlock(EvaluateLogical((LogicalBlock)conditionalBlock.Value.Block) ? conditionalBlock.OnSuccess : conditionalBlock.Default)); }