Пример #1
0
        public override void GetContent(CompilerContext context, ParseTreeNode parseNode)
        {
            _Sources = new HashSet<AAttributeAssignOrUpdateOrRemove>();

            #region VIA edge

            IDNode _EdgeAttr = null;

            if (parseNode.ChildNodes[4].AstNode is IDNode) //Semantic Web Yoda style
            {
                _EdgeAttr = (parseNode.ChildNodes[4].AstNode as IDNode);
            }
            else //Human language style
            {
                _EdgeAttr = (parseNode.ChildNodes[6].AstNode as IDNode);
            }

            #endregion

            #region sources

            var typeNode = (parseNode.ChildNodes[1].AstNode as ATypeNode);
            ParsingResult.PushIExceptional(typeNode.ParsingResult);

            var tupleDef = (parseNode.ChildNodes[2].AstNode as TupleNode).TupleDefinition;

            var tupleDefSourceType = new TupleDefinition(tupleDef.KindOfTuple);

            foreach (var item in tupleDef.TupleElements)
            {
                var attrName = typeNode.ReferenceAndType.TypeName + DBConstants.EdgeTraversalDelimiterSymbol + ((IDChainDefinition)((BinaryExpressionDefinition)item.Value).Left).ContentString;
                var leftNode = new IDChainDefinition(attrName, new List<TypeReferenceDefinition>() { typeNode.ReferenceAndType });
                leftNode.AddPart(new ChainPartTypeOrAttributeDefinition(((IDChainDefinition)((BinaryExpressionDefinition)item.Value).Left).ContentString));
                var rightNode = ((BinaryExpressionDefinition)item.Value).Right;

                var binExpression = new BinaryExpressionDefinition(((BinaryExpressionDefinition)item.Value).OperatorSymbol, leftNode, rightNode);

                tupleDefSourceType.AddElement(new TupleElement(item.TypeOfValue, binExpression));
            }

            _Sources.Add(new AttributeRemoveList(_EdgeAttr.IDChainDefinition, _EdgeAttr.IDChainDefinition.TypeName, tupleDefSourceType));

            #endregion

            #region sources FROM

            if (parseNode.ChildNodes[6].ChildNodes[0].AstNode is ATypeNode)  //Semantic Web Yoda style
            {
                typeNode = (parseNode.ChildNodes[6].ChildNodes[0].AstNode as ATypeNode);
                _Targets = (parseNode.ChildNodes[6].ChildNodes[1].AstNode as TupleNode).TupleDefinition;
            }
            else  //Human language style
            {
                typeNode = (parseNode.ChildNodes[4].ChildNodes[0].AstNode as ATypeNode);
                _Targets = (parseNode.ChildNodes[4].ChildNodes[1].AstNode as TupleNode).TupleDefinition;
            }

            ParsingResult.PushIExceptional(typeNode.ParsingResult);
            _SourceType = typeNode.ReferenceAndType;

            if (_Targets.Count() > 1)
            {
                var firstElement = (BinaryExpressionDefinition)_Targets.First().Value;
                _Targets.Remove(_Targets.First());

                _Condition = GetConditionNode(new OrOperator().ContraryOperationSymbol, firstElement, _Targets);
            }
            else
            {
                _Condition = (BinaryExpressionDefinition)_Targets.First().Value;
            }

            #endregion
        }
 public Error_DuplicateReferenceOccurence(TypeReferenceDefinition myType)
 {
     Type = myType.ToString();
 }
Пример #3
0
        public void GetContent(CompilerContext context, ParseTreeNode parseNode)
        {
            var dbTypeName = parseNode.ChildNodes[0].Token.ValueString;

            if (parseNode.ChildNodes.Count == 2)
            {
                ReferenceAndType = new TypeReferenceDefinition(dbTypeName, parseNode.ChildNodes[1].Token.ValueString);
            }
            else
            {
                ReferenceAndType = new TypeReferenceDefinition(dbTypeName, dbTypeName);
            }
        }
Пример #4
0
        public override void GetContent(CompilerContext myCompilerContext, ParseTreeNode myParseTreeNode)
        {
            var _GraphQLGrammar = GetGraphQLGrammar(myCompilerContext);

            _Targets = new HashSet<AAttributeAssignOrUpdateOrRemove>();

            #region FROM Sources

            var typeNode = (myParseTreeNode.ChildNodes[1].AstNode as ATypeNode);
            ParsingResult.PushIExceptional(typeNode.ParsingResult);
            _SourceType = typeNode.ReferenceAndType;

            _Sources = (myParseTreeNode.ChildNodes[2].AstNode as TupleNode).TupleDefinition;

            if(_Sources.Count() > 1 )
            {
                var firstElement = (BinaryExpressionDefinition)_Sources.First().Value;
                _Sources.Remove(_Sources.First());
                _Condition = GetConditionNode(new OrOperator().ContraryOperationSymbol, firstElement, _Sources);
            }

            else
            {
                _Condition = (BinaryExpressionDefinition) _Sources.First().Value;
            }

            #endregion

            #region Find statement "VIA Edge"

            IDNode _EdgeAttr = null;

            // Semantic Web Yoda-style...
            if (myParseTreeNode.ChildNodes[3].Token.AsSymbol == _GraphQLGrammar.S_VIA)
            {
                _EdgeAttr = (myParseTreeNode.ChildNodes[4].AstNode as IDNode);
            }

            else // Human language style...
            {
                if (myParseTreeNode.ChildNodes[5].Token.AsSymbol == _GraphQLGrammar.S_VIA)
                {
                    _EdgeAttr = (myParseTreeNode.ChildNodes[6].AstNode as IDNode);
                }
            }

            #endregion

            #region Find statement "TO Targets"

            TupleDefinition tupleDef = null;

            // Semantic Web Yoda-style...
            if (myParseTreeNode.ChildNodes[5].Token.AsSymbol == _GraphQLGrammar.S_TO)
            {
                typeNode = (myParseTreeNode.ChildNodes[6].ChildNodes[0].AstNode as ATypeNode);
                tupleDef = (myParseTreeNode.ChildNodes[6].ChildNodes[1].AstNode as TupleNode).TupleDefinition;
            }

            else // Human language style...
            {
                if (myParseTreeNode.ChildNodes[3].Token.AsSymbol == _GraphQLGrammar.S_TO)
                {
                    typeNode = (myParseTreeNode.ChildNodes[4].ChildNodes[0].AstNode as ATypeNode);
                    tupleDef = (myParseTreeNode.ChildNodes[4].ChildNodes[1].AstNode as TupleNode).TupleDefinition;
                }
            }

            #endregion

            #region Processing...

            ParsingResult.PushIExceptional(typeNode.ParsingResult);

            var _TargetType        = typeNode.ReferenceAndType;
            var tupleDefTargetType = new TupleDefinition(tupleDef.KindOfTuple);

            foreach (var item in tupleDef.TupleElements)
            {

                var attrName = _TargetType.TypeName + DBConstants.EdgeTraversalDelimiterSymbol + ((IDChainDefinition)((BinaryExpressionDefinition)item.Value).Left).ContentString;
                var leftNode = new IDChainDefinition(attrName, new List<TypeReferenceDefinition>() { _TargetType });
                leftNode.AddPart(new ChainPartTypeOrAttributeDefinition(((IDChainDefinition)((BinaryExpressionDefinition)item.Value).Left).ContentString));
                var rightNode = ((BinaryExpressionDefinition)item.Value).Right;

                var binExpression = new BinaryExpressionDefinition(((BinaryExpressionDefinition)item.Value).OperatorSymbol, leftNode, rightNode);

                tupleDefTargetType.AddElement(new TupleElement(item.TypeOfValue, binExpression));

            }

            _Targets.Add(new AttributeAssignOrUpdateList(new CollectionDefinition(CollectionType.Set, tupleDefTargetType), _EdgeAttr.IDChainDefinition, false));

            #endregion
        }