@@ -172,8 +172,15 @@ private boolean isPropertyStart(ParserState state) {
172172 * 检查是否是包装表达式起始
173173 */
174174 private boolean isExpressionStart (ParserState state ) {
175- return (state .getCurrentChar () == parser .MARK_START_EXPRESSION && state .peekNextChar () == parser .MARK_BRACE_OPEN )
176- || state .getCurrentChar () == parser .MARK_BRACE_OPEN ;
175+ int cur = state .getCurrentChar ();
176+ int next = state .peekNextChar ();
177+
178+ // 只有明确看到 #{ 或 { 才认为是包装表达式的开始
179+ if (cur == parser .MARK_START_EXPRESSION ) {
180+ return next == parser .MARK_BRACE_OPEN ;
181+ }
182+
183+ return cur == parser .MARK_BRACE_OPEN ;
177184 }
178185
179186 /**
@@ -360,7 +367,12 @@ private Expression parsePrimaryExpression(ParserState state) {
360367 expr = new ConstantNode (null );
361368 } else {
362369 String identifier = parseIdentifier (state );
363- expr = new VariableNode (identifier );
370+
371+ if (identifier != null && identifier .length () > 0 ) {
372+ expr = new VariableNode (identifier );
373+ } else {
374+ throw state .error ("Expression is invalid" );
375+ }
364376 }
365377
366378 return parsePostfix (state , expr );
@@ -740,6 +752,11 @@ public int peekNextChar() {
740752 }
741753 }
742754
755+ public CompilationException error (String message ) {
756+ String charDesc = (ch == -1 ) ? "EOF" : "'" + (char ) ch + "'" ;
757+ return new CompilationException (message + " (found " + charDesc + ") at position " + position );
758+ }
759+
743760 /**
744761 * 跳过空白字符
745762 */
0 commit comments