public void Visit(RelationalExpr node)
 {
     VisitChildren (node);
     ApplyOperatorToOperands (node);
 }
예제 #2
0
        private Expression ExprRelational()
        {
            if ((Token.Types)currentToken.Type == Token.Types.Equal ||
                (Token.Types)currentToken.Type == Token.Types.Less) {

                RelationalExpr relationalExpr;

                if ((Token.Types)currentToken.Type == Token.Types.Equal) {
                    Match (Token.Types.Equal);
                    relationalExpr = new RelationalExpr ("=", currentToken.Row, currentToken.Column);
                } else {
                    Match (Token.Types.Less);
                    relationalExpr = new RelationalExpr ("<", currentToken.Row, currentToken.Column);
                }

                relationalExpr.AddChild (ExprC ());
                Expression expression = ExprRelational ();

                if (expression.Name != null) {
                    relationalExpr.AddChild (expression);
                }

                return relationalExpr;
            } else if ((Token.Types)currentToken.Type == Token.Types.And ||
                       (Token.Types)currentToken.Type == Token.Types.RightParenthesis ||
                       (Token.Types)currentToken.Type == Token.Types.Range ||
                       (Token.Types)currentToken.Type == Token.Types.Do ||
                       (Token.Types)currentToken.Type == Token.Types.Semicolon) {
                return new RelationalExpr(null, currentToken.Row, currentToken.Column);
            }

            throw new SyntaxError ("invalid type " + currentToken.Type, currentToken.Row,
                currentToken.Column);
        }