Example #1
0
        /// <summary>
        /// Parses an out or any edge expression with an enclosed variable definition.
        /// Throws on mis match.
        /// </summary>
        /// <returns> An edge node.</returns>
        private static Node ParseOutAnyEdge(ref int position, List <Token> tokens)
        {
            EdgeNode          edgeNode;
            MatchVariableNode matchVariableNode;

            CheckLeftBrace(ref position, tokens);
            matchVariableNode = (MatchVariableNode)(ParseMatchVariable(ref position, tokens));
            CheckRightBrace(ref position, tokens);


            // -> || -
            if (CheckToken(position, Token.TokenType.Dash, tokens))
            {
                position++;
                edgeNode = new AnyEdgeNode();
                if (CheckToken(position, Token.TokenType.Greater, tokens))
                {
                    position++;
                    edgeNode = new OutEdgeNode();
                }
            }
            else
            {
                throw new ArgumentException($"EdgeParser, expected ending of edge.");
            }

            edgeNode.AddMatchVariable(matchVariableNode);
            return(edgeNode);
        }
Example #2
0
        /// <summary>
        /// Tries to parse an anonymous edge type.
        /// </summary>
        /// <returns> An anonymous edge or null. </returns>
        static private Node TryParseEmptyEdge(ref int position, List <Token> tokens)
        {
            EdgeNode edgeNode;

            if (CheckEmptyAnyEdge(ref position, tokens))
            {
                edgeNode = new AnyEdgeNode();
                position++;
                return(edgeNode);
            }
            else if (CheckEmptyOutEdge(ref position, tokens))
            {
                edgeNode = new OutEdgeNode();
                position = position + 2;
                return(edgeNode);
            }
            else if (CheckEmptyInEdge(ref position, tokens))
            {
                edgeNode = new InEdgeNode();
                position = position + 2;
                return(edgeNode);
            }
            else
            {
                return(null);
            }
        }
Example #3
0
        /// <summary>
        /// Tries to jump to a variable node inside edge or to the next vertex.
        /// </summary>
        public void Visit(OutEdgeNode node)
        {
            this.readingVertex = false;

            ParsedPatternNode em = new OutEdgeParsedPatternNode();

            currentPattern.AddParsedPatternNode(em);

            if (node.matchVariable != null)
            {
                node.matchVariable.Accept(this);
            }
            if (node.next == null)
            {
                throw new ArgumentException($"{this.GetType()}, missing end vertex from edge.");
            }
            else
            {
                node.next.Accept(this);
            }
        }
Example #4
0
 public void Visit(OutEdgeNode node)
 {
     throw new NotImplementedException();
 }