Author: scabanovich
Date: 2008-10-02 09:49:45 -0400 (Thu, 02 Oct 2008)
New Revision: 10626
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/Tokenizer.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/TokenizerFactory.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/ELParserImpl.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/OperationTokenDescription.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/PrimitiveValueTokenDescription.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/UnaryTokenDescription.java
Log:
JBIDE-1497.
Parser fixes.
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/Tokenizer.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/Tokenizer.java 2008-10-02
13:33:55 UTC (rev 10625)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/Tokenizer.java 2008-10-02
13:49:45 UTC (rev 10626)
@@ -24,6 +24,7 @@
*
*/
public class Tokenizer {
+ static int LITERAL = -10;
private Map<Integer, ITokenDescription> tokenDescriptions = new
HashMap<Integer, ITokenDescription>();
private Map<Integer, List<IRule>> rules = new HashMap<Integer,
List<IRule>>();
@@ -127,6 +128,14 @@
public void addToken(int type, int start, int end) {
if(end < 0) return;
+ int lastEnd = last.getStart() + last.getLength();
+ if(start > lastEnd) {
+ int length = start - lastEnd;
+ LexicalToken t = new LexicalToken(lastEnd, length, getCharSequence(lastEnd, start),
LITERAL);
+ last.setNextToken(t);
+ last = t;
+ index = start;
+ }
LexicalToken t = new LexicalToken(start, end - start, getCharSequence(start, end),
type);
last.setNextToken(t);
last = t;
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/TokenizerFactory.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/TokenizerFactory.java 2008-10-02
13:33:55 UTC (rev 10625)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/TokenizerFactory.java 2008-10-02
13:49:45 UTC (rev 10626)
@@ -98,7 +98,7 @@
}
public static void main(String[] args) {
- String text = "#{a.b + 7d -c.d + g}#{hh.vv..m()}";
+ String text = "ioioio#{1.2e1}ioioio#{0}";
//"#{a[b()['l'].j]}";
//"#{g11.g12.y13} #{#{ #{a14.b15(x.t.u(uu.ii[9], j)).b16(m17(v18(i19[2]).u20).)+
a21(c.).b.}";
//"#{not a.b(x,y) + s.h((6 != -8) & (7 + -iy88.g[9].h(7 div 8).i.j)+(8) ? 4 :
7,'p', a.b.c.d[null])}";
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/ELParserImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/ELParserImpl.java 2008-10-02
13:33:55 UTC (rev 10625)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/ELParserImpl.java 2008-10-02
13:49:45 UTC (rev 10626)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.common.el.internal.core.parser;
+import org.jboss.tools.common.el.core.model.ELObjectType;
import org.jboss.tools.common.el.core.parser.LexicalToken;
import org.jboss.tools.common.el.internal.core.model.ELArgumentImpl;
import org.jboss.tools.common.el.internal.core.model.ELArgumentExpressionImpl;
@@ -80,6 +81,14 @@
instance.setFirstToken(current);
setNextToken();
ELExpressionImpl expression = readExpression();
+ if(expression == null) {
+ //create fake invocation expression
+ expression = new ELPropertyInvocationImpl();
+ int p = current != null ? current.getStart() : instance.getEndPosition();
+ LexicalToken t = new LexicalToken(p, 0, "",
JavaNameTokenDescription.JAVA_NAME);
+ expression.setFirstToken(t);
+ expression.setLastToken(t);
+ }
if(expression != null) {
instance.setExpression(expression);
instance.setLastToken(expression.getLastToken());
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/OperationTokenDescription.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/OperationTokenDescription.java 2008-10-02
13:33:55 UTC (rev 10625)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/OperationTokenDescription.java 2008-10-02
13:49:45 UTC (rev 10626)
@@ -27,6 +27,7 @@
};
private static final String[] OPS_2 = {
"div", "and", "or", "not", "mod",
+ "eq", "ne", "lt", "ge", "le",
};
public static OperationTokenDescription INSTANCE = new OperationTokenDescription();
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/PrimitiveValueTokenDescription.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/PrimitiveValueTokenDescription.java 2008-10-02
13:33:55 UTC (rev 10625)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/PrimitiveValueTokenDescription.java 2008-10-02
13:49:45 UTC (rev 10626)
@@ -87,6 +87,7 @@
}
char ch = '\0';
boolean lastCharIsWrong = false;
+ boolean inE = false;
while((ch = tokenizer.readNextChar()) != '\0') {
if(ch == '.') {
dotCount--;
@@ -95,12 +96,31 @@
break;
}
} else if(!Character.isDigit(ch)) {
- if(TYPE_CHAR.indexOf(ch) >= 0) {
+ if(inE) {
+ //
+ } if(TYPE_CHAR.indexOf(ch) >= 0) {
char ch1 = tokenizer.lookUpChar(i + 1);
if(ch1 == '\0' || !Character.isJavaIdentifierPart(ch1)) {
i++;
break;
}
+ } else if(ch == 'e' || ch == 'E') {
+ char ch1 = tokenizer.lookUpChar(i + 1);
+ char ch2 = tokenizer.lookUpChar(i + 2);
+ if((ch1 == '+' || ch1 == '-') && Character.isDigit(ch2)) {
+ tokenizer.readNextChar();
+ tokenizer.readNextChar();
+ i += 3;
+ inE = true;
+ dotCount = 0;
+ continue;
+ } else if(Character.isDigit(ch1)) {
+ tokenizer.readNextChar();
+ i += 2;
+ inE = true;
+ dotCount = 0;
+ continue;
+ }
}
lastCharIsWrong = true;
break;
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/UnaryTokenDescription.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/UnaryTokenDescription.java 2008-10-02
13:33:55 UTC (rev 10625)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/UnaryTokenDescription.java 2008-10-02
13:49:45 UTC (rev 10626)
@@ -23,7 +23,7 @@
public static UnaryTokenDescription INSTANCE = new UnaryTokenDescription();
private static final String[] OPS_2 = {
- "not",
+ "not", "empty"
};
public UnaryTokenDescription() {