Revision 44098 trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.expressionevaluator/org.gvsig.expressionevaluator.lib/org.gvsig.expressionevaluator.lib.impl/src/main/java/org/gvsig/expressionevaluator/impl/SQLLexicalAnalyzer.java

View differences:

SQLLexicalAnalyzer.java
1 1
package org.gvsig.expressionevaluator.impl;
2 2

  
3
import org.gvsig.expressionevaluator.ExpressionSyntaxException;
3 4
import org.gvsig.expressionevaluator.spi.AbstractLexicalAnalyzer;
4 5
import org.gvsig.expressionevaluator.LexicalAnalyzer;
5 6

  
......
62 63
        case '<':
63 64
            ch = getch();
64 65
            switch( ch ) {
66
            case EOF:
67
                throw new ExpressionSyntaxException(I18N.unexpected_end_of_source(), this);
65 68
            case '>':
66 69
                token.set(Token.OP_NE, "<>");
67 70
                return token;
......
75 78

  
76 79
        case '>':
77 80
            ch = getch();
78
            if( ch == '=' ) {
81
            switch( ch ) {
82
            case EOF:
83
                throw new ExpressionSyntaxException(I18N.unexpected_end_of_source(), this);
84
            case '=':
79 85
                token.set(Token.OP_GE, ">=");
80 86
                return token;
81 87
            }
......
96 102
            token.set(Token.PARENTHESIS_CLOSE, ")");
97 103
            return token;
98 104
        case '+':
99
            ch = getch();
100
            if( !Character.isDigit(ch) ) {
101
                ungetch();
102
                token.set(Token.OP_ADD, "+");
103
                return token;
104
            }
105
            ungetch();
106
            parseNumber();
107
            token.setLiteral("+" + token.getLiteral());
105
            token.set(Token.OP_ADD, "+");
108 106
            return token;
107
//            ch = getch();
108
//            if( ch == EOF ) {
109
//                throw new ExpressionSyntaxException(I18N.unexpected_end_of_source(), this);
110
//            }
111
//            if( !Character.isDigit(ch) ) {
112
//                ungetch();
113
//                token.set(Token.OP_ADD, "+");
114
//                return token;
115
//            }
116
//            ungetch();
117
//            parseNumber();
118
//            token.setLiteral("+" + token.getLiteral());
119
//            return token;
109 120
        case '-':
110 121
            ch = getch();
111
            if( ch=='>' ) {
122
            switch( ch ) {
123
            case EOF:
124
                throw new ExpressionSyntaxException(I18N.unexpected_end_of_source(), this);
125
            case '>':
112 126
                // SQL Extension to access object methods and attributes
113 127
                token.set(Token.OP_GETATTR, "->");
114 128
                return token;
115 129
            }
116
            if( Character.isDigit(ch) ) {
117
                ungetch();
118
                ungetch();
119
                parseNumber();
120
                return token;
121
            }
130
//            if( Character.isDigit(ch) ) {
131
//                ungetch();
132
//                ungetch();
133
//                parseNumber();
134
//                return token;
135
//            }
136
            ungetch();
122 137
            token.set(Token.OP_SUBST, "-");
123 138
            return token;
124 139

  
......
127 142
            ch = getch();
128 143
            while( ch != '"' ) {
129 144
                if( ch == EOF ) {
130
                    throw new RuntimeException("Found end of source and expected end of string");
145
                    throw new ExpressionSyntaxException(I18N.End_of_string_was_expected_and_end_of_source_was_found(), this);
131 146
                }
132 147
                buffer.add(ch);
133 148
                ch = getch();
134 149
            }
135 150
            if( buffer.length() < 1 ) {
136
                throw new RuntimeException();
151
                throw new ExpressionSyntaxException(I18N.Incorrect_string_length(), this);
137 152
            }
138 153
            token.set(Token.IDENTIFIER, buffer.toString());
139 154
            return token;
......
143 158
            ch = getch();
144 159
            while( ch != ']' ) {
145 160
                if( ch == EOF ) {
146
                    throw new RuntimeException("Found end of source and expected end of string");
161
                    throw new ExpressionSyntaxException(I18N.Closing_square_bracket_was_expected_and_end_of_source_was_found(), this);
147 162
                }
148 163
                buffer.add(ch);
149 164
                ch = getch();
150 165
            }
151 166
            if( buffer.length() < 1 ) {
152
                throw new RuntimeException();
167
                throw new ExpressionSyntaxException(I18N.Incorrect_identifier_length(), this);
153 168
            }
154 169
            token.set(Token.IDENTIFIER, buffer.toString());
155 170
            return token;

Also available in: Unified diff