예제 #1
0
        public static Either <ParseException, Pair <List <IToken>, RelationNode> > Parse(List <IToken> tokens, IScopedTable <IEntityType, string> parentTypeTable)
        {
            Console.WriteLine("RelationNode");
            var maybeSimple = SimpleNode.Parse(tokens, parentTypeTable);

            if (maybeSimple.IsLeft)
            {
                return(maybeSimple.LeftToList()[0]);
            }

            var simple1 = maybeSimple.RightToList()[0].Second;

            tokens = maybeSimple.RightToList()[0].First;
            if (tokens.Count < 1)
            {
                return(new Pair <List <IToken>, RelationNode>(tokens, new RelationNode(simple1, parentTypeTable)));
            }
            if (!(tokens[0] is LeOperatorToken || tokens[0] is LtOperatorToken ||
                  tokens[0] is GeOperatorToken || tokens[0] is GtOperatorToken ||
                  tokens[0] is EqualsOperatorToken || tokens[0] is NotEqualsOperatorToken))
            {
                return(new Pair <List <IToken>, RelationNode>(tokens, new RelationNode(simple1, parentTypeTable)));
            }

            var token = tokens[0];

            tokens = tokens.Skip(1).ToList();
            var maybeSimple2 = SimpleNode.Parse(tokens, parentTypeTable);

            if (maybeSimple2.IsLeft)
            {
                return(maybeSimple2.LeftToList()[0]);
            }
            var simple2 = maybeSimple2.RightToList()[0].Second;

            tokens = maybeSimple2.RightToList()[0].First;
            while (tokens.Count > 0)
            {
                if (tokens[0] is NewLineSymbolToken || tokens[0] is CommentToken)
                {
                    tokens = tokens.Skip(1).ToList();
                }
                else
                {
                    break;
                }
            }

            return(new Pair <List <IToken>, RelationNode>(tokens, new RelationNode(simple1, token, simple2, parentTypeTable)));
        }
예제 #2
0
 private RelationNode(SimpleNode simple1, IScopedTable <IEntityType, string> parentTypeTable)
 {
     Simple1         = simple1;
     ParentTypeTable = parentTypeTable;
 }