public override void Visit(ElseNode node) { if (node.Descendants.Length == 0) { ReportLackOfElseReturnExpression(node); } }
public ElseNode Else(string value) { ElseNode elseNode = new ElseNode(); Match(TokenType.ELSE); return(elseNode); }
public void Visit(ElseNode node) { foreach (var subnode in node) { Visit((dynamic)subnode); } }
public object VisitElseNode(ElseNode node, Context parameter) { foreach (var child in node.Children) { child.Accept(this, parameter); } return(null); }
/// <summary> /// Visit Else node in BFS manner. /// </summary> /// <param name="node">Else node that will be visited.</param> public void Visit(ElseNode node) { while (_contextChangeTracker.Count > 0) { _contextChangeTracker.Pop(); _scope = _scope.OuterScope; } _scope = new ScopeContext(_scope, _functionScopeTable, "else"); }
protected void ParseElse() { INode parent = Peek(); if (!(parent is InternalIfNode)) { return; } InternalIfNode ifNode = (InternalIfNode)Pop(); ElseNode elseNode = new ElseNode(); ifNode.ElseNode = elseNode; Push(elseNode); _tokenizer.SkipWhitespace(); }
public Node Else() { var node = new ElseNode(); if (CurrentToken == TokenCategory.ELSE) { Expect(TokenCategory.ELSE); Expect(TokenCategory.LLAVE_OPEN); if (CurrentToken != TokenCategory.LLAVE_CLOSE) { node.Add(StmtList()); } Expect(TokenCategory.LLAVE_CLOSE); } return(node); }
public IfNode(LeafParser.IfContext ctx) { Line = ctx.Start.Line; Check = ValueNode.Create(ctx.value()); Scope = new ScopeNode(ctx.conditional_scope(0)); if (ctx.Else() != null) { if (ctx.conditional_scope(1) != null) { Else = new ElseNode(ctx.conditional_scope(1)); } else { ElseIf = new ElseIfNode(ctx.@if()); } } }
private void ParseElseBlockComment() { if (!IsInIfBlockNode()) { throw new SqlParseException(ExceptionMessageId.Esp2140, _sql, _tokenizer.LineNumber, _tokenizer.Position); } RemoveNodesTo <IfBlockNode>(); var ifBlockNode = (IfBlockNode)Peek(); if (ifBlockNode.IsElseNodeExists) { throw new SqlParseException(ExceptionMessageId.Esp2141, _sql, _tokenizer.LineNumber, _tokenizer.Position); } var node = new ElseNode(_token); ifBlockNode.ElseNode = node; _nodeStack.Push(node); }
public IfStatementNode(ExpressionNode conditional, EmbeddedStatementNode body, ElseNode elseBody) { this.conditional = conditional; this.body = body; this.elseBody = elseBody; }
public override void Visit(ElseNode node) { CSharpString.Append("else"); node.ElseBody.Accept(this); }
public override void Visit(ElseNode node) { Console.Write("else"); node.ElseBody.Accept(this); }
/// <summary> /// Performs "Else" specific operations. /// </summary> /// <param name="node">The "Else" node.</param> public virtual void Visit(ElseNode node) { _labels.Add($"esac_{node.Parent.Else.FullSpan.Start}{node.Parent.Else.FullSpan.End}", Instructions.Count); }
public IEnumerable <StatementNode> Visit(ElseNode node) => (node.BlockOrIfNode.Match( body => Visit(body), node => Flatten(node) )).Append(node);
public override void Visit(ElseNode node) { symbolTable.OpenScope(); node.ElseBody.Accept(this); symbolTable.CloseScope(); }
public ElseNodeGUIContent(ElseNode node, NodeMachineEditor editor) : base(node, editor) { this.text = "else"; this.shrinkTextWithZoom = true; }
/// <summary> /// Visit Else node in BFS manner. /// </summary> /// <param name="node">Else node that will be visited.</param> public override void Visit(ElseNode node) { node.Accept(Visitor); node.Descendant.Accept(this); _contextChangeTracker.Push(true); }
public string Visit(ElseNode node) => ASTHelper.PrintToken(node.Token) + node.BlockOrIfNode.Match(b => Visit(b), n => Print(n));
public ElseBuilder(ElseNode elseNode) { node = elseNode; DotDefinition = new List <IDotElement>(); }
private ParserState ParseIf(ParserState state) { List <StringBuilder> conditionStrings = new List <StringBuilder>(); List <StringBuilder> resultStrings = new List <StringBuilder>(); var curIndex = -1; bool isNewLine = true; bool isConditionDone = false; int codeBlockCount = 0; while (!state.Done()) { if (state.Char() == Sym.cCodeOpen) { codeBlockCount++; } else if (state.Char() == Sym.cCodeClose) { codeBlockCount--; } bool isWhiteSpace = (state.Char() == ' ' || state.Char() == '\t'); bool isSkippableWhitespace = isNewLine && isWhiteSpace; bool isNewListItem = isNewLine && (codeBlockCount <= 0) && state.Char() == Sym.cList; if (isNewListItem) { curIndex++; isConditionDone = false; conditionStrings.Add(Utils.GetTempStringBuilder()); resultStrings.Add(Utils.GetTempStringBuilder()); } else if (curIndex > -1) { if (!isConditionDone) { if (state.Char() == '?' || state.Char() == Sym.cLineBreak) { isConditionDone = true; } else { conditionStrings[curIndex].Append(state.Char()); } } else { if (!isSkippableWhitespace) { resultStrings[curIndex].Append(state.Char()); } } } isNewLine = (state.Char() == Sym.cLineBreak) || isSkippableWhitespace || isNewListItem; state.Step(); } var conditions = new Node[conditionStrings.Count]; for (int i = 0; i < conditionStrings.Count; i++) { var str = Utils.Release(conditionStrings[i]); if (str != null) { str = str.Trim(); } if (str == "else") { conditions[i] = new ElseNode(); } else { conditions[i] = CreateExpression(str); } } var results = new Node[resultStrings.Count]; for (int i = 0; i < resultStrings.Count; i++) { var str = Utils.Release(resultStrings[i]); if (str != null) { str = str.Trim(); } var dialogState = new ParserState(new BlockNode(BlockMode.Dialog), str); dialogState = ParseDialog(dialogState); results[i] = dialogState.RootNode; } state.CurNode.AddChild(new IfNode(conditions, results, false)); return(state); }
/// <summary> /// Visit Else node. /// </summary> /// <param name="node">Else node of AST</param> public abstract void Visit(ElseNode node);
private void ReportLackOfElseReturnExpression(ElseNode node) { AddSyntaxError(node.FullSpan, string.Format(AnalysisMessage.LackOfElseReturnExpression, node.Parent), SyntaxErrorKind.LackOfExpression); }
public IEnumerable <ValueNode> Visit(ElseNode node) => node.HasIf ? ExtractValue((IfNode)node.BlockOrIfNode) : emptyArray;
public override void Visit(ElseNode node) => ProduceDebuggerInstructions(node, n => base.Visit(n));
internal abstract void Visit(ElseNode node);
/// <summary> /// Visit Else node in BFS manner. /// </summary> /// <param name="node">Else node that will be visited.</param> public virtual void Visit(ElseNode node) { node.Descendant.Accept(this); node.Accept(_visitor); }
public IEnumerable <StatementNode> Visit(ElseNode node) => Visit(node.Body);