// ?? 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)); } }
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); } }
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); }
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)); } }
/// <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)); }