private void GetContent(CompilerContext context, ParseTreeNode parseNode) { if (parseNode.HasChildNodes()) { if (parseNode.ChildNodes[1].Token.ValueString.ToLower() == "graph") _SelectOutputType = SelectOutputTypes.Graph; else _SelectOutputType = SelectOutputTypes.Tree; } }
public void Init(ParsingContext context, ParseTreeNode parseNode) { if (HasChildNodes(parseNode)) { if (parseNode.ChildNodes[1].Token.ValueString.ToLower() == "graph") _SelectOutputType = SelectOutputTypes.Graph; else _SelectOutputType = SelectOutputTypes.Tree; } }
public void Init(ParsingContext context, ParseTreeNode parseNode) { if (HasChildNodes(parseNode)) { if (parseNode.ChildNodes[1].Token.ValueString.ToLower() == "graph") { _SelectOutputType = SelectOutputTypes.Graph; } else { _SelectOutputType = SelectOutputTypes.Tree; } } }
public override void GetContent(CompilerContext context, ParseTreeNode parseNode) { #region Data TypeList = new List<TypeReferenceDefinition>(); GroupByIDs = new List<IDChainDefinition>(); SelectedElements = new List<Tuple<AExpressionDefinition, string, SelectValueAssignment>>(); Limit = null; Offset = null; WhereExpressionDefinition = null; ResolutionDepth = -1; #endregion #region TypeList foreach (ParseTreeNode aNode in parseNode.ChildNodes[1].ChildNodes) { ATypeNode aType = (ATypeNode)aNode.AstNode; // use the overrides equals to check duplicated references if (!TypeList.Contains(aType.ReferenceAndType)) { TypeList.Add(aType.ReferenceAndType); } else { throw new GraphDBException(new Error_DuplicateReferenceOccurence(aType.ReferenceAndType)); } } #endregion #region selList foreach (ParseTreeNode aNode in parseNode.ChildNodes[3].ChildNodes) { SelectionListElementNode aColumnItemNode = (SelectionListElementNode)aNode.AstNode; String typeName = null; if (aColumnItemNode.SelType != TypesOfSelect.None) { if (aColumnItemNode.SelType == TypesOfSelect.Ad) { typeName = aColumnItemNode.TypeName; } foreach (var reference in GetTypeReferenceDefinitions(context)) { //SelectedElements.Add(new IDChainDefinition(new ChainPartTypeOrAttributeDefinition(reference.TypeName), aColumnItemNode.SelType, typeName), null); SelectedElements.Add(new Tuple<AExpressionDefinition, string, SelectValueAssignment>( new IDChainDefinition(new ChainPartTypeOrAttributeDefinition(reference.TypeName), aColumnItemNode.SelType, typeName), null, aColumnItemNode.ValueAssignment)); } continue; } SelectedElements.Add(new Tuple<AExpressionDefinition, string, SelectValueAssignment>( aColumnItemNode.ColumnSourceValue, aColumnItemNode.AliasId, aColumnItemNode.ValueAssignment)); } #endregion #region whereClauseOpt if (parseNode.ChildNodes[4].HasChildNodes()) { WhereExpressionNode tempWhereNode = (WhereExpressionNode)parseNode.ChildNodes[4].AstNode; if (tempWhereNode.BinaryExpressionDefinition != null) { WhereExpressionDefinition = tempWhereNode.BinaryExpressionDefinition; } } #endregion #region groupClauseOpt if (parseNode.ChildNodes[5].HasChildNodes() && parseNode.ChildNodes[5].ChildNodes[2].HasChildNodes()) { foreach (ParseTreeNode node in parseNode.ChildNodes[5].ChildNodes[2].ChildNodes) { GroupByIDs.Add(((IDNode)node.AstNode).IDChainDefinition); } } #endregion #region havingClauseOpt if (parseNode.ChildNodes[6].HasChildNodes()) { Having = ((BinaryExpressionNode)parseNode.ChildNodes[6].ChildNodes[1].AstNode).BinaryExpressionDefinition; } #endregion #region orderClauseOpt if (parseNode.ChildNodes[7].HasChildNodes()) { OrderByDefinition = ((OrderByNode)parseNode.ChildNodes[7].AstNode).OrderByDefinition; } #endregion //#region MatchingClause //if (parseNode.ChildNodes[8].HasChildNodes()) //{ // throw new NotImplementedException(); //} //#endregion #region Offset if (parseNode.ChildNodes[9].HasChildNodes()) { Offset = ((OffsetNode)parseNode.ChildNodes[9].AstNode).Count; } #endregion #region Limit if (parseNode.ChildNodes[10].HasChildNodes()) { Limit = ((LimitNode)parseNode.ChildNodes[10].AstNode).Count; } #endregion #region Depth if (parseNode.ChildNodes[11].HasChildNodes()) { ResolutionDepth = Convert.ToUInt16(parseNode.ChildNodes[11].ChildNodes[1].Token.Value); } #endregion #region Select Output if (parseNode.ChildNodes[12].HasChildNodes()) { _SelectOutputType = (parseNode.ChildNodes[12].AstNode as SelectOutputOptNode).SelectOutputType; } #endregion }
public void Init(ParsingContext context, ParseTreeNode parseNode) { #region Data TypeList = new List <TypeReferenceDefinition>(); GroupByIDs = new List <IDChainDefinition>(); SelectedElements = new List <Tuple <AExpressionDefinition, string, SelectValueAssignment> >(); Limit = null; Offset = null; WhereExpressionDefinition = null; ResolutionDepth = -1; #endregion #region TypeList foreach (ParseTreeNode aNode in parseNode.ChildNodes[1].ChildNodes) { ATypeNode aType = (ATypeNode)aNode.AstNode; // use the overrides equals to check duplicated references if (!TypeList.Contains(aType.ReferenceAndType)) { TypeList.Add(aType.ReferenceAndType); } else { throw new DuplicateReferenceOccurrenceException(aType.ReferenceAndType.TypeName); } } #endregion #region selList foreach (ParseTreeNode aNode in parseNode.ChildNodes[3].ChildNodes) { SelectionListElementNode aColumnItemNode = (SelectionListElementNode)aNode.AstNode; String typeName = null; if (aColumnItemNode.SelType != TypesOfSelect.None) { foreach (var reference in GetTypeReferenceDefinitions(context)) { //SelectedElements.Add(new IDChainDefinition(new ChainPartTypeOrAttributeDefinition(reference.TypeName), aColumnItemNode.SelType, typeName), null); SelectedElements.Add(new Tuple <AExpressionDefinition, string, SelectValueAssignment>( new IDChainDefinition( new ChainPartTypeOrAttributeDefinition(reference.TypeName), aColumnItemNode.SelType, typeName), null, aColumnItemNode.ValueAssignment)); } continue; } SelectedElements.Add(new Tuple <AExpressionDefinition, string, SelectValueAssignment>( aColumnItemNode.ColumnSourceValue, aColumnItemNode.AliasId, aColumnItemNode.ValueAssignment)); } #endregion #region whereClauseOpt if (parseNode.ChildNodes[4].ChildNodes != null && parseNode.ChildNodes[4].ChildNodes.Count > 0) { WhereExpressionNode tempWhereNode = (WhereExpressionNode)parseNode.ChildNodes[4].AstNode; if (tempWhereNode.BinaryExpressionDefinition != null) { WhereExpressionDefinition = tempWhereNode.BinaryExpressionDefinition; } } #endregion #region groupClauseOpt if (HasChildNodes(parseNode.ChildNodes[5]) && HasChildNodes(parseNode.ChildNodes[5].ChildNodes[2])) { foreach (ParseTreeNode node in parseNode.ChildNodes[5].ChildNodes[2].ChildNodes) { GroupByIDs.Add(((IDNode)node.AstNode).IDChainDefinition); } } #endregion #region havingClauseOpt if (HasChildNodes(parseNode.ChildNodes[6])) { Having = ((BinaryExpressionNode)parseNode.ChildNodes[6].ChildNodes[1].AstNode).BinaryExpressionDefinition; } #endregion #region orderClauseOpt if (HasChildNodes(parseNode.ChildNodes[7])) { OrderByDefinition = ((OrderByNode)parseNode.ChildNodes[7].AstNode).OrderByDefinition; } #endregion #region Offset if (HasChildNodes(parseNode.ChildNodes[8])) { Offset = ((OffsetNode)parseNode.ChildNodes[8].AstNode).Count; } #endregion #region Limit if (HasChildNodes(parseNode.ChildNodes[9])) { Limit = ((LimitNode)parseNode.ChildNodes[9].AstNode).Count; } #endregion #region Depth if (HasChildNodes(parseNode.ChildNodes[10])) { ResolutionDepth = Convert.ToUInt16(parseNode.ChildNodes[10].ChildNodes[1].Token.Value); } #endregion #region Select Output if (HasChildNodes(parseNode.ChildNodes[11])) { _SelectOutputType = (parseNode.ChildNodes[11].AstNode as SelectOutputOptNode).SelectOutputType; } #endregion }