コード例 #1
0
        public ThenNode Then(string value)
        {
            ThenNode thenNode = new ThenNode();

            Match(TokenType.THEN);
            return(thenNode);
        }
コード例 #2
0
 public override void Visit(ThenNode node)
 {
     if (node.Descendants.Length == 0)
     {
         ReportLackOfThenExpression(node);
     }
 }
コード例 #3
0
        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());
        }
コード例 #4
0
        /// <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");
        }
コード例 #5
0
        /// <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);
            }
        }
コード例 #6
0
 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);
         }
     }));
 }
コード例 #7
0
ファイル: Traverser.cs プロジェクト: Puchaczov/TQL.RDL
 /// <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);
 }
コード例 #8
0
 private void ReportLackOfThenExpression(ThenNode node)
 {
     AddSyntaxError(node.FullSpan, string.Format(AnalysisMessage.LackOfThenReturnExpression, node),
                    SyntaxErrorKind.LackOfExpression);
 }
コード例 #9
0
 public override void Visit(ThenNode node) => ProduceDebuggerInstructions(node, n => base.Visit(n));
コード例 #10
0
ファイル: AnalyzerBase.cs プロジェクト: Puchaczov/TQL.RDL
 /// <summary>
 ///     Visit Then node.
 /// </summary>
 /// <param name="node">Then node of AST</param>
 public abstract void Visit(ThenNode node);
コード例 #11
0
 /// <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);
 }