public ThenNode Then(string value) { ThenNode thenNode = new ThenNode(); Match(TokenType.THEN); return(thenNode); }
public override void Visit(ThenNode node) { if (node.Descendants.Length == 0) { ReportLackOfThenExpression(node); } }
private WhenThenNode[] ComposeWhenThenNodes() { var nodes = new List <WhenThenNode>(); while (!IsElseNode(Current)) { WhenNode when = null; ThenNode then = null; switch (Current.TokenType) { case StatementType.When: when = new WhenNode(ConsumeAndGetToken(), ComposeWhere()); goto case StatementType.Then; case StatementType.Then: then = new ThenNode(ConsumeAndGetToken(), ComposeWhere()); break; default: throw new NotSupportedException(); } if (when == null || then == null) { throw new NullReferenceException(); } nodes.Add(new WhenThenNode(when, then)); } return(nodes.ToArray()); }
/// <summary> /// Visit Then node in DFS manner. /// </summary> /// <param name="node">Then node that will be visited.</param> public void Visit(ThenNode node) { while (_contextChangeTracker.Count > 0) { _contextChangeTracker.Pop(); _scope = _scope.OuterScope; } _scope = new ScopeContext(_scope, _functionScopeTable, "then"); }
/// <summary> /// Performs "Then" specific operations. /// </summary> /// <param name="node">The "Numeric" node.</param> public virtual void Visit(ThenNode node) { var elseSpan = node.Parent.Parent.Else.FullSpan; Instructions.Add(new JumpToLabel($"esac_{elseSpan.Start}{elseSpan.End}")); if (node.Parent.ArrayOrder == node.Parent.Parent.WhenThenExpressions.Length - 1) { _labels.Add($"else_{node.Parent.Parent.Else.FullSpan.Start}{node.Parent.Parent.Else.FullSpan.End}", Instructions.Count); } }
public KeyValuePair <object, Continue> Eval(Env e, Continue k) { return(PredNode.Eval(e, b => { if ((bool)b) { return ThenNode.Eval(e, k); } else { return ElseNode.Eval(e, k); } })); }
/// <summary> /// Visit Then node in DFS manner. /// </summary> /// <param name="node">Then node that will be visited.</param> public virtual void Visit(ThenNode node) { node.Descendant.Accept(this); node.Accept(_visitor); }
private void ReportLackOfThenExpression(ThenNode node) { AddSyntaxError(node.FullSpan, string.Format(AnalysisMessage.LackOfThenReturnExpression, node), SyntaxErrorKind.LackOfExpression); }
public override void Visit(ThenNode node) => ProduceDebuggerInstructions(node, n => base.Visit(n));
/// <summary> /// Visit Then node. /// </summary> /// <param name="node">Then node of AST</param> public abstract void Visit(ThenNode node);
/// <summary> /// Visit Then node in BFS manner. /// </summary> /// <param name="node">Then node that will be visited.</param> public override void Visit(ThenNode node) { node.Accept(Visitor); node.Descendant.Accept(this); _contextChangeTracker.Push(true); }