Revision 45153 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/DefaultCompiler.java
DefaultCompiler.java | ||
---|---|---|
46 | 46 |
|
47 | 47 |
@Override |
48 | 48 |
public void save_state() { |
49 |
this.trace("save_state"); |
|
49 | 50 |
((AbstractLexicalAnalyzer)lexer).save_state(); |
50 | 51 |
this.states.push(state); |
51 | 52 |
} |
... | ... | |
54 | 55 |
public void restore_state() { |
55 | 56 |
((AbstractLexicalAnalyzer)lexer).restore_state(); |
56 | 57 |
state = this.states.pop(); |
58 |
this.trace("restore_state"); |
|
57 | 59 |
} |
58 | 60 |
|
59 | 61 |
@Override |
60 | 62 |
public void drop_state() { |
61 | 63 |
((AbstractLexicalAnalyzer)lexer).drop_state(); |
62 | 64 |
this.states.pop(); |
65 |
this.trace("drop_state"); |
|
63 | 66 |
} |
64 | 67 |
|
65 | 68 |
@Override |
... | ... | |
116 | 119 |
} |
117 | 120 |
|
118 | 121 |
@Override |
119 |
public Code parse_expression() { |
|
120 |
return DefaultCompiler.this.parse_expression(); |
|
122 |
public Code parse_expression(boolean allow_assignement) {
|
|
123 |
return DefaultCompiler.this.parse_expression(allow_assignement);
|
|
121 | 124 |
} |
122 | 125 |
|
123 | 126 |
@Override |
... | ... | |
132 | 135 |
|
133 | 136 |
@Override |
134 | 137 |
public void trace(String msg) { |
135 |
// System.out.println(msg+". "+this.getLexicalAnalyzer().getSourceContext()); |
|
138 |
// LexicalAnalyzer lex = this.getLexicalAnalyzer(); |
|
139 |
// String s = StringUtils.left(lex.getSource(), lex.getPosition()) + "[*]" + StringUtils.mid(lex.getSource(), lex.getPosition(), 200); |
|
140 |
// if( s.length()>200 ) { |
|
141 |
// s = "..."+StringUtils.mid(s, lex.getPosition()-100, 200)+"..."; |
|
142 |
// } |
|
143 |
// System.out.println(msg+". "+s); |
|
136 | 144 |
} |
137 | 145 |
} |
138 | 146 |
|
... | ... | |
206 | 214 |
} |
207 | 215 |
return code; |
208 | 216 |
} |
217 |
|
|
218 |
public Code parse_expression() { |
|
219 |
return this.parse_expression(true); |
|
220 |
} |
|
209 | 221 |
|
210 |
public Code parse_expression() { |
|
222 |
public Code parse_expression(boolean allow_assignement) {
|
|
211 | 223 |
Code code = parse_relational(); |
224 |
if( code != null && allow_assignement) { |
|
225 |
Token token = lexer.look(); |
|
226 |
if( token.is("AS") ) { |
|
227 |
lexer.next(); |
|
228 |
token = lexer.look(); |
|
229 |
if( token.getType() != Token.IDENTIFIER ) { |
|
230 |
throw new ExpressionSyntaxException( |
|
231 |
I18N.An_identifier_was_expected_and_XliteralX_was_found(token.getLiteral()), |
|
232 |
lexer |
|
233 |
); |
|
234 |
} |
|
235 |
token = lexer.next(); |
|
236 |
code = codeBuilder.let(token.getLiteral(),code); |
|
237 |
} |
|
238 |
} |
|
212 | 239 |
return code; |
213 | 240 |
} |
214 | 241 |
|
... | ... | |
703 | 730 |
StatementContext context = new DefaultStatementContext(); |
704 | 731 |
Code code; |
705 | 732 |
BaseCodes args = (BaseCodes) this.codeBuilder.args(); |
733 |
context.trace("compiler.parse_gramars"); |
|
706 | 734 |
Statement stmt = this.grammars.getApplicableStatement(context); |
707 | 735 |
while( stmt!=null ) { |
708 | 736 |
code = stmt.parse(context); |
Also available in: Unified diff