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

            // -
            if (!CheckToken(position, Token.TokenType.Dash, tokens))
            {
                throw new ArgumentException($"EdgeParser, expected beginning of edge.");
            }
            else
            {
                position++;
            }

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

            // -
            if (CheckToken(position, Token.TokenType.Dash, tokens))
            {
                position++;
                edgeNode = new InEdgeNode();
            }
            else
            {
                throw new ArgumentException($"MatchParser, expected ending of edge.");
            }

            edgeNode.AddMatchVariable(matchVariableNode);
            return(edgeNode);
        }
Exemple #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);
            }
        }
        /// <summary>
        /// Tries to jump to a variable node inside an edge or to the next vertex.
        /// </summary>
        public void Visit(InEdgeNode node)
        {
            this.readingVertex = false;

            ParsedPatternNode em = new InEdgeParsedPatternNode();

            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);
            }
        }
 public void Visit(InEdgeNode node)
 {
     throw new NotImplementedException();
 }