Ejemplo n.º 1
0
        // ?? TODO: Move to partial class
        #region Node Specific Methods

        #region COMMON

        /// <summary>
        /// Generic Table Symbol Creation from an Identifier
        /// </summary>
        /// <param name="xoContext.CurrentNode"></param>
        /// <param name="xoContext.List"></param>
        /// <returns></returns>
        private static SyntaxNode TableSymbolConvertToken(ParsingContext xoContext, Boolean xbIsPreconsumption = false)
        {
            SyntaxKind eKind = xoContext.List.Peek().ExpectedType;

            // If we need to perform a context sensitive conversion
            if (SyntaxKindFacts.IsIdentifier(eKind) ||
                eKind == SyntaxKind.OpenParenthesisToken)
            {
                return(SyntaxNodeFactory.FactoryCreateTable(xoContext));
            }
            else
            {
                // Everything else
                return(DefaultTryConsumeNext(xoContext));
            }
        }
Ejemplo n.º 2
0
        private static CanConsumeResult CaseCanConsume(ParsingContext xoContext, Boolean xbIsPreconsumption = false)
        {
            SyntaxKind eNextKind = xoContext.List.Peek().ExpectedType;

            // Can consume When and Else. thats it
            if (eNextKind == SyntaxKind.WhenKeyword ||
                eNextKind == SyntaxKind.ElseKeyword)
            {
                return(CanConsumeResult.Consume);
            }
            else if (eNextKind == SyntaxKind.EndKeyword)
            {
                xoContext.CurrentNode.Add(new SyntaxNode(xoContext.List.Pop()));

                // Only assign an alias if it is a symbol
                if (xoContext.CurrentNode.GetType() == typeof(Symbol))
                {
                    ((Symbol)xoContext.CurrentNode).Alias = SyntaxNodeFactory.ScanAheadForAlias(xoContext.List);
                }

                return(CanConsumeResult.Complete);
            }
            else
            {
                // Improper closing of the CASE
                xoContext.CurrentNode.Add(new SyntaxNode(new SyntaxToken(SyntaxKind.EndKeyword, "END")));

                // Only assign an alias if it is a symbol
                if (xoContext.CurrentNode.GetType() == typeof(Symbol))
                {
                    ((Symbol)xoContext.CurrentNode).Alias = SyntaxNodeFactory.ScanAheadForAlias(xoContext.List);
                }

                return(CanConsumeResult.Complete);

                //return DefaultCanConsumeNext(xoContext);
            }
        }
Ejemplo n.º 3
0
    public SyntaxNode constructSyntaxNode(VisualNode e)
    {
        Debug.Log("Id of currentl constructing node is " + e.ID);
        SyntaxNode node = SyntaxNodeFactory.produce(e.ID);

        if (node is BlockNode)
        {
            if (node is IfNode)
            {
                //It should still retain while if is while
                IfNode ifBlock = (IfNode)node;
                BinaryOperationNode conditionalStatement = new BinaryOperationNode();

                //Set it's attributes with fields in the operationVisual
                BlockVisual           block     = (BlockVisual)e;
                BinaryOperationVisual condition = (BinaryOperationVisual)block.condition;

                if (condition == null)
                {
                    //Throw an exception
                }

                convertBinaryOperation((BinaryOperationNode)conditionalStatement, (BinaryOperationVisual)condition);
                ifBlock.SetCondition(conditionalStatement);
            }
        }
        else if (e is BinaryOperationVisual)
        {
            if (node is BinaryOperationNode)
            {
                convertBinaryOperation((BinaryOperationNode)node, (BinaryOperationVisual)e);
            }
        }


        //It should hold all it's changes.
        return(node);
    }
Ejemplo n.º 4
0
        private static CanConsumeResult SubQueryCanConsumeNext(ParsingContext xoContext, Boolean xbIsPreconsumption = false)
        {
            SyntaxKind oKind = xoContext.List.Peek().ExpectedType;

            // If we get a closing parenthesis
            if (xoContext.CurrentNode.ExpectedType == SyntaxKind.IdentifierSubQuerySymbol &&
                oKind == SyntaxKind.CloseParenthesisToken)
            {
                xoContext.List.Pop();

                // Just add an Alias
                ((Symbol)xoContext.CurrentNode).Alias = SyntaxNodeFactory.ScanAheadForAlias(xoContext.List);

                return(CanConsumeResult.Complete);
            }
            else if (oKind == SyntaxKind.SelectKeyword)
            {
                return(CheckIfConsumptionIsAllowed(xoContext));
            }
            else
            {
                return(DefaultCanConsumeNext(xoContext));
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Provides context sensitive generation of a new Node
 /// </summary>
 /// <param name="xoContext.CurrentNode"></param>
 /// <param name="xoContext.List"></param>
 /// <returns></returns>
 private static SyntaxNode DefaultTryConsumeNext(ParsingContext xoContext, Boolean xbIsPreconsumption = false)
 {
     return(SyntaxNodeFactory.ContextSensitiveConvertTokenToNode(xoContext));
 }