Esempio n. 1
0
        public Node ExprRel()
        {
            var node = ExprAdd();

            while (firstOfExprRel.Contains(CurrentToken))
            {
                switch (CurrentToken)
                {
                case TokenCategory.LESS:
                    var node_less = new Less();
                    node_less.AnchorToken = Expect(TokenCategory.LESS);
                    node_less.Add(node);
                    node_less.Add(ExprAdd());
                    node = node_less;
                    break;

                case TokenCategory.LESSEQUAL:
                    var node_ltet = new LessThanOrEqualTo();
                    node_ltet.AnchorToken = Expect(TokenCategory.LESSEQUAL);
                    node_ltet.Add(node);
                    node_ltet.Add(ExprAdd());
                    node = node_ltet;
                    break;

                case TokenCategory.GREATER:
                    var node_gt = new GreaterThan();
                    node_gt.AnchorToken = Expect(TokenCategory.GREATER);
                    node_gt.Add(node);
                    node_gt.Add(ExprAdd());
                    node = node_gt;
                    break;

                case TokenCategory.GREATEREQUAL:
                    var node_gtet = new GreaterThanOrEqualTo();
                    node_gtet.AnchorToken = Expect(TokenCategory.GREATEREQUAL);
                    node_gtet.Add(node);
                    node_gtet.Add(ExprAdd());
                    node = node_gtet;
                    break;

                default:
                    throw new SyntaxError(firstOfExprRel, tokenStream.Current);
                }
            }
            return(node);
        }