Author: scabanovich
Date: 2008-09-23 11:37:49 -0400 (Tue, 23 Sep 2008)
New Revision: 10413
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELArgument.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELArgumentInvocation.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELExpression.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELInstance.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELInvocationExpression.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELMethodInvocation.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELModel.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELObject.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELObjectType.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELParameters.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELPropertyInvocation.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ELParser.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ELParserFactory.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/IRule.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ITokenDescription.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/LexicalToken.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/SyntaxError.java
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/
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELArgumentExpressionImpl.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELArgumentImpl.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELComplexExpressionImpl.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELExpressionImpl.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELInstanceImpl.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELInvocationExpressionImpl.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELMethodInvocationImpl.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELModelImpl.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELMultiExpressionImpl.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELObjectImpl.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELOperatorImpl.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELParametersImpl.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELPropertyInvocationImpl.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELValueExpressionImpl.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/
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/rule/
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/ArgRule.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/BasicStates.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/CallRule.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/ErrorRecoveryRule.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/ExpressionRule.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/OperationRule.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ArgEndTokenDescription.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ArgStartTokenDescription.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/CommaTokenDescription.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ConstantTokenDescription.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/DotTokenDescription.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/EndELTokenDescription.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ExprEndTokenDescription.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ExprStartTokenDescription.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/JavaNameTokenDescription.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/ParamEndTokenDescription.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ParamStartTokenDescription.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ParamUtil.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/StartELTokenDescription.java
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/StringTokenDescription.java
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/WhiteSpaceTokenDescription.java
Modified:
trunk/common/plugins/org.jboss.tools.common.el.core/META-INF/MANIFEST.MF
Log:
JBIDE-1497
Initial implementation of new EL parser
Modified: trunk/common/plugins/org.jboss.tools.common.el.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el.core/META-INF/MANIFEST.MF 2008-09-23
15:37:42 UTC (rev 10412)
+++ trunk/common/plugins/org.jboss.tools.common.el.core/META-INF/MANIFEST.MF 2008-09-23
15:37:49 UTC (rev 10413)
@@ -5,9 +5,12 @@
Bundle-Name: El Plug-in
Bundle-SymbolicName: org.jboss.tools.common.el.core
Bundle-Version: 2.0.0
-Provide-Package: org.jboss.tools.common.el.core
+Provide-Package: org.jboss.tools.common.el.core,
+ org.jboss.tools.common.el.core.model,
+ org.jboss.tools.common.el.core.parser
Bundle-Activator: org.jboss.tools.common.el.core.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.core.resources,
+ org.eclipse.jface.text,
org.jboss.tools.common.resref.core;reprovide=true
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELArgument.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELArgument.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELArgument.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.core.model;
+
+import org.jboss.tools.common.el.core.parser.LexicalToken;
+
+/**
+ * Argument object includes opening token, the argument expression proper,
+ * and closing token:
+ * '[' expression ']'
+ *
+ * @author V. Kabanovich
+ *
+ */
+public interface ELArgument {
+
+ public LexicalToken getOpenArgumentToken();
+
+ public ELExpression getArgument();
+
+ public LexicalToken getCloseArgumentToken();
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELArgumentInvocation.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELArgumentInvocation.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELArgumentInvocation.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.core.model;
+
+/**
+ * Kind of invocation in which argument is represented as
+ * '[' expression ']'.
+ * Details are returned by method getArgument().
+ *
+ * @author V. Kabanovich
+ */
+public interface ELArgumentInvocation extends ELInvocationExpression {
+
+ public ELArgument getArgument();
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELExpression.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELExpression.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELExpression.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.core.model;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public interface ELExpression extends ELObject {
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELInstance.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELInstance.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELInstance.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.core.model;
+
+import org.jboss.tools.common.el.core.parser.LexicalToken;
+
+/**
+ * Instance of EL includes opening token, the expression proper,
+ * and closing token:
+ * '#{' expression '}'
+ * '${' expression '}'
+ *
+ * @author V. Kabanovich
+ *
+ */
+public interface ELInstance extends ELObject {
+
+ public LexicalToken getOpenInstanceToken();
+
+ public ELExpression getExpression();
+
+ public LexicalToken getCloseInstanceToken();
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELInvocationExpression.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELInvocationExpression.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELInvocationExpression.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.core.model;
+
+/**
+ * Generic interface for all kinds of expressions that involve
+ * resolving variables, properties, methods etc. in underlying
+ * model (i.e. Java model).
+ * The important property of such an expression is that it
+ * can be associated to left operand that serves as scope
+ * for its resolution. If left operand is not explicitly set,
+ * it is implied.
+ *
+ * @author V. Kabanovich
+ *
+ */
+public interface ELInvocationExpression extends ELExpression {
+
+ /**
+ *
+ * @return Preceding expression, that serves
+ * as scope for resolving this expression,
+ * Two expressions are connected syntactically,
+ * for instance expr1.expr2 or expr1[expr2]
+ * or in other ways specified by language.
+ */
+ public ELInvocationExpression getLeft();
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELMethodInvocation.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELMethodInvocation.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELMethodInvocation.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.core.model;
+
+import org.jboss.tools.common.el.core.parser.LexicalToken;
+
+/**
+ * Invocation with syntax
+ * LEFT . NAME PARAMETERS
+ *
+ * @author V. Kabanovich
+ *
+ */
+public interface ELMethodInvocation extends ELInvocationExpression {
+
+ public LexicalToken getSeparator();
+
+ public LexicalToken getName();
+
+ public ELParameters getParameters();
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELModel.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELModel.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELModel.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.core.model;
+
+import java.util.List;
+
+/**
+ * ELModel object is the result of EL parsing that includes
+ * all found instances of EL in the source string.
+ *
+ * @author V. Kabanovich
+ *
+ */
+public interface ELModel extends ELObject {
+
+ public String getSource();
+
+ public List<ELInstance> getInstances();
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELObject.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELObject.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELObject.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.core.model;
+
+import java.util.List;
+
+import org.jboss.tools.common.el.core.parser.LexicalToken;
+
+/**
+ * Super type for all objects in EL model.
+ * @author V. Kabanovich
+ *
+ */
+public interface ELObject {
+
+ public ELObjectType getType();
+
+ public ELModel getModel();
+
+ public int getLength();
+
+ public String getText();
+
+ public ELObject getParent();
+
+ public List<ELObject> getChildren();
+
+ public LexicalToken getFirstToken();
+
+ public LexicalToken getLastToken();
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELObjectType.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELObjectType.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELObjectType.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.core.model;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public enum ELObjectType {
+ EL_UNKNOWN,
+ EL_MODEL,
+ EL_INSTANCE,
+ EL_METHOD_INVOCATION,
+ EL_QUALIFIED_NAME,
+ EL_PROPERTY_INVOCATION,
+ EL_ARGUMENT_INVOCATION,
+ EL_OPERATOR,
+ EL_VALUE,
+ EL_COMPLEX_EXPRESSION,
+ EL_MULTI_EXPRESSION,
+ EL_ARGUMENT,
+ EL_PARAMETERS;
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELParameters.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELParameters.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELParameters.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.core.model;
+
+import java.util.List;
+
+import org.jboss.tools.common.el.core.parser.LexicalToken;
+
+/**
+ * Details of parameters in method invocation
+ * '(' (expr (, expr)*)? ')'
+ *
+ * @author V. Kabanovich
+ *
+ */
+public interface ELParameters extends ELObject {
+
+ public LexicalToken getOpenParametersToken();
+
+ public List<ELExpression> getParameters();
+
+ public LexicalToken getCloseParametersToken();
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELPropertyInvocation.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELPropertyInvocation.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/model/ELPropertyInvocation.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.core.model;
+
+import org.jboss.tools.common.el.core.parser.LexicalToken;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public interface ELPropertyInvocation extends ELInvocationExpression {
+
+ public LexicalToken getSeparator();
+
+ public LexicalToken getName();
+
+ /**
+ * If all left expressions are also property invocations
+ * (or variable names in terms of underlying model),
+ * this method returns qualified name as
+ * NAME (. NAME)*
+ * Otherwise, (i.e. if some left expression is method or
+ * argument invocation), null is returned.
+ *
+ * @return
+ */
+ public String getQualifiedName();
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ELParser.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ELParser.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ELParser.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.core.parser;
+
+import java.util.List;
+
+import org.jboss.tools.common.el.core.model.ELModel;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public interface ELParser {
+
+ public ELModel parse(String source);
+
+ public List<SyntaxError> getSyntaxErrors();
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ELParserFactory.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ELParserFactory.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ELParserFactory.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.core.parser;
+
+import java.util.List;
+
+import org.jboss.tools.common.el.core.model.ELModel;
+import org.jboss.tools.common.el.internal.core.model.ELModelImpl;
+import org.jboss.tools.common.el.internal.core.parser.ELParserImpl;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class ELParserFactory {
+
+ public static ELParser createDefaultParser() {
+ return new ELParser() {
+ ELParserImpl impl = new ELParserImpl();
+ List<SyntaxError> errors = null;
+
+ public ELModel parse(String source) {
+ Tokenizer t = TokenizerFactory.createDefaultTokenizer();
+ LexicalToken token = t.parse(source);
+ errors = t.getErrors();
+ if(token == null) {
+ return null;
+ }
+ ELModelImpl model = impl.parse(token);
+ model.setSource(source);
+ return model;
+ }
+
+ public List<SyntaxError> getSyntaxErrors() {
+ return errors;
+ }
+ };
+ }
+
+ public static ELParser createJbossParser() {
+ return new ELParser() {
+ ELParserImpl impl = new ELParserImpl();
+ List<SyntaxError> errors = null;
+
+ public ELModel parse(String source) {
+ Tokenizer t = TokenizerFactory.createJbossTokenizer();
+ LexicalToken token = t.parse(source);
+ errors = t.getErrors();
+ if(token == null) {
+ return null;
+ }
+ ELModelImpl model = impl.parse(token);
+ model.setSource(source);
+ return model;
+ }
+
+ public List<SyntaxError> getSyntaxErrors() {
+ return errors;
+ }
+ };
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/IRule.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/IRule.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/IRule.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.core.parser;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public interface IRule {
+
+ public int[] getStartStates();
+
+ public int[] getTokenTypes(int state);
+
+ public int getFinalState(int state, int token);
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ITokenDescription.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ITokenDescription.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/ITokenDescription.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.core.parser;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public interface ITokenDescription {
+
+ /**
+ *
+ * @return Unique type of this kind of token.
+ */
+ public int getType();
+
+ /**
+ *
+ * @return Human readable name.
+ */
+ public String getName();
+
+ /**
+ * Determines if this token is relevant at this point
+ * @param tokenizer
+ * @param last
+ * @param offset
+ * @return
+ */
+ public boolean isStart(Tokenizer tokenizer, int offset);
+
+ /**
+ *
+ * @param tokenizer
+ * @param last
+ * @param offset
+ * @return
+ */
+ public boolean read(Tokenizer tokenizer, int offset);
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/LexicalToken.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/LexicalToken.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/LexicalToken.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.core.parser;
+
+import org.eclipse.jface.text.rules.IToken;
+
+public class LexicalToken implements IToken {
+ private LexicalToken previous;
+ private LexicalToken next;
+
+ private int start;
+ private int length;
+ private CharSequence chars;
+ private int type;
+
+ /**
+ * Constructs the ELToken object
+ *
+ * @param start
+ * @param length
+ * @param chars
+ * @param type
+ */
+ public LexicalToken(int start, int length, CharSequence chars, int type) {
+ this.start = start;
+ this.length = length;
+ this.chars = chars;
+ this.type = type;
+ }
+
+ /**
+ * Returns string representation for the token
+ */
+ public String toString() {
+ return "ELToken(" + start + ", " + length + ", " + type +
") [" + (chars == null ? "<Empty>" : chars.toString()) +
"]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
//$NON-NLS-6$
+ }
+
+ /*
+ * @see org.eclipse.jface.text.rules.IToken#getData()
+ */
+ public Object getData() {
+// return (chars == null ? null : chars.subSequence(start, start+length).toString());
+ return getText();
+ }
+
+ /**
+ * @return offset of token
+ */
+ public int getStart() {
+ return start;
+ }
+
+ /**
+ * @return length of token
+ */
+ public int getLength() {
+ return length;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.rules.IToken#isEOF()
+ */
+ public boolean isEOF() {
+ return (start == -1 && length == -1 && chars == null);
+ }
+
+ /*
+ * @see org.eclipse.jface.text.rules.IToken#isOther()
+ */
+ public boolean isOther() {
+ return false;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.rules.IToken#isUndefined()
+ */
+ public boolean isUndefined() {
+ return false;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.rules.IToken#isWhitespace()
+ */
+ public boolean isWhitespace() {
+ return false;
+ }
+
+ /*
+ * Returns the token type
+ */
+ public int getType(){
+ return type;
+ }
+
+ /*
+ * Returns the token text
+ */
+ public String getText() {
+ return chars.toString();
+ }
+
+ public LexicalToken getPreviousToken() {
+ return previous;
+ }
+
+ public LexicalToken getNextToken() {
+ return next;
+ }
+
+ public void setNextToken(LexicalToken n) {
+ if(n != null) {
+ n.previous = this;
+ }
+ next = n;
+ }
+
+ void makeItFirst() {
+ previous = null;
+ }
+
+ public LexicalToken findTokenBackword(int type) {
+ if(previous == null) return null;
+ if(previous.type == type) return previous;
+ return previous.findTokenBackword(type);
+ }
+
+ public LexicalToken findTokenForward(int type) {
+ if(next == null) return null;
+ if(next.type == type) return next;
+ return next.findTokenForward(type);
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/SyntaxError.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/SyntaxError.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/SyntaxError.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.core.parser;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class SyntaxError {
+ int position;
+ int state;
+
+ public SyntaxError(int position, int state) {
+ this.position = position;
+ this.state = state;
+ }
+
+ public int getState() {
+ return state;
+ }
+
+ public int getPosition() {
+ return position;
+ }
+
+}
Added:
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
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/Tokenizer.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,172 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.core.parser;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.jboss.tools.common.el.internal.core.parser.rule.BasicStates;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class Tokenizer {
+
+ private Map<Integer, ITokenDescription> tokenDescriptions = new
HashMap<Integer, ITokenDescription>();
+ private Map<Integer, List<IRule>> rules = new HashMap<Integer,
List<IRule>>();
+
+ private String sourceString;
+ private int index = 0;
+
+ private LexicalToken start = new LexicalToken(0, 0, "", -1000);
+ private LexicalToken last = start;
+
+ private int state;
+ private Properties context = new Properties();
+
+ List<SyntaxError> errors = new ArrayList<SyntaxError>();
+
+ public Tokenizer() {}
+
+ public void setTokenDescriptions(ITokenDescription[] ds) {
+ for (int i = 0; i < ds.length; i++) {
+ int type = ds[i].getType();
+ if(tokenDescriptions.containsKey(type)) {
+ throw new IllegalArgumentException("Token type " + type + " is not
unique.");
+ }
+ tokenDescriptions.put(type, ds[i]);
+ }
+ }
+
+ public ITokenDescription getTokenDescription(int id) {
+ return tokenDescriptions.get(id);
+ }
+
+ public void setRules(IRule[] rules) {
+ for (int i = 0; i < rules.length; i++) {
+ int[] ss = rules[i].getStartStates();
+ for (int j = 0; j < ss.length; j++) {
+ List<IRule> rs = this.rules.get(ss[j]);
+ if(rs == null) {
+ rs = new ArrayList<IRule>();
+ this.rules.put(ss[j], rs);
+ }
+ rs.add(rules[i]);
+ }
+ }
+ }
+
+ public LexicalToken parse(String sourceString) {
+ this.sourceString = sourceString;
+ errors.clear();
+ index = 0;
+ start = new LexicalToken(0, 0, "", -1000);
+ last = start;
+ state = BasicStates.STATE_EXPECTING_EL;
+
+ while(index < sourceString.length()) {
+ boolean done = false;
+ List<IRule> rs = rules.get(state);
+ for (IRule rule : rs) {
+ int[] ts = rule.getTokenTypes(state);
+ for (int j = 0; !done && j < ts.length; j++) {
+ ITokenDescription td = tokenDescriptions.get(ts[j]);
+ if (td != null && td.isStart(this, index)) {
+ td.read(this, index);
+ state = rule.getFinalState(state, ts[j]);
+ done = true;
+ }
+ }
+ }
+ if(!done) {
+ if(state == BasicStates.STATE_EXPECTING_EL || state == BasicStates.STATE_ERROR) {
+ char ch = readNextChar();
+ if(ch == '\0') break;
+ } else {
+ errors.add(new SyntaxError(index, state));
+ state = BasicStates.STATE_ERROR;
+ }
+ }
+ }
+ LexicalToken result = start.getNextToken();
+ if(result != null) {
+ result.makeItFirst();
+ }
+ return result;
+ }
+
+ public List<SyntaxError> getErrors() {
+ return errors;
+ }
+
+ public void addToken(int type, int start, int end) {
+ if(end < 0) return;
+ LexicalToken t = new LexicalToken(start, end - start, getCharSequence(start, end),
type);
+ last.setNextToken(t);
+ last = t;
+ index = end;
+ }
+
+ public Properties getContext() {
+ return context;
+ }
+
+ private CharSequence getCharSequence(int start, int end) {
+ String text = sourceString.substring(start, end);
+ return text.subSequence(0, text.length());
+ }
+
+ public char readNextChar() {
+ char c = '\0';
+ if (index < sourceString.length()) {
+ c = sourceString.charAt(index);
+ }
+ index++;
+ return c;
+ }
+
+ public char lookUpChar(int i) {
+ return (i < 0 || sourceString.length() <= i) ? '\0' :
sourceString.charAt(i);
+ }
+
+ /*
+ * returns the character to the document
+ */
+ public void releaseChar() {
+ if (index > 0) {
+ index--;
+ }
+ }
+
+ public boolean startsWith(String s) {
+ int l = index + s.length();
+ if(l > sourceString.length()) return false;
+ for (int i = index; i < l; i++) {
+ if(lookUpChar(i) != s.charAt(i - index)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public LexicalToken getLastToken() {
+ return last;
+ }
+
+ public int getState() {
+ return state;
+ }
+}
Added:
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
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/core/parser/TokenizerFactory.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,125 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.core.parser;
+
+import java.util.List;
+
+import org.jboss.tools.common.el.core.model.ELExpression;
+import org.jboss.tools.common.el.core.model.ELModel;
+import org.jboss.tools.common.el.internal.core.parser.rule.ArgRule;
+import org.jboss.tools.common.el.internal.core.parser.rule.CallRule;
+import org.jboss.tools.common.el.internal.core.parser.rule.ErrorRecoveryRule;
+import org.jboss.tools.common.el.internal.core.parser.rule.ExpressionRule;
+import org.jboss.tools.common.el.internal.core.parser.rule.OperationRule;
+import org.jboss.tools.common.el.internal.core.parser.token.ArgEndTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.ArgStartTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.CommaTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.DotTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.EndELTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.ExprEndTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.ExprStartTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.JavaNameTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.OperationTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.ParamEndTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.ParamStartTokenDescription;
+import
org.jboss.tools.common.el.internal.core.parser.token.PrimitiveValueTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.StartELTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.StringTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.UnaryTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.WhiteSpaceTokenDescription;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class TokenizerFactory {
+
+ public static Tokenizer createDefaultTokenizer() {
+ Tokenizer t = new Tokenizer();
+ t.setTokenDescriptions(new ITokenDescription[]{
+ ArgEndTokenDescription.INSTANCE,
+ ArgStartTokenDescription.INSTANCE,
+ DotTokenDescription.INSTANCE,
+ EndELTokenDescription.INSTANCE,
+ JavaNameTokenDescription.INSTANCE,
+ OperationTokenDescription.INSTANCE,
+ UnaryTokenDescription.INSTANCE,
+ PrimitiveValueTokenDescription.INSTANCE,
+ StartELTokenDescription.INSTANCE,
+ StringTokenDescription.INSTANCE,
+ WhiteSpaceTokenDescription.INSTANCE,
+ });
+ t.setRules(new IRule[]{
+ ExpressionRule.INSTANCE,
+ ArgRule.INSTANCE,
+ CallRule.INSTANCE,
+ OperationRule.INSTANCE,
+ ErrorRecoveryRule.INSTANCE,
+ });
+ return t;
+ }
+
+ public static Tokenizer createJbossTokenizer() {
+ Tokenizer t = new Tokenizer();
+ t.setTokenDescriptions(new ITokenDescription[]{
+ ArgEndTokenDescription.INSTANCE,
+ ArgStartTokenDescription.INSTANCE,
+ CommaTokenDescription.INSTANCE,
+ DotTokenDescription.INSTANCE,
+ EndELTokenDescription.INSTANCE,
+ JavaNameTokenDescription.INSTANCE,
+ OperationTokenDescription.INSTANCE,
+ ParamEndTokenDescription.INSTANCE,
+ ParamStartTokenDescription.INSTANCE,
+ ExprStartTokenDescription.INSTANCE,
+ ExprEndTokenDescription.INSTANCE,
+ UnaryTokenDescription.INSTANCE,
+ PrimitiveValueTokenDescription.INSTANCE,
+ StartELTokenDescription.INSTANCE,
+ StringTokenDescription.INSTANCE,
+ WhiteSpaceTokenDescription.INSTANCE,
+ });
+ t.setRules(new IRule[]{
+ ExpressionRule.INSTANCE,
+ ArgRule.INSTANCE,
+ CallRule.INSTANCE,
+ OperationRule.INSTANCE,
+ ErrorRecoveryRule.INSTANCE,
+ });
+ return t;
+ }
+
+ public static void main(String[] args) {
+ String text = //"#{a.b.}";
+"#{a.b + s.h((6 != -8) & (7 + -iy88.g[9].h(7 div 8).i.j)+(8) ? 4 :
7,'p', a.b.c.d[null])}";
+//"q82#{a( g.h(7 + 8) + 8, g['h'].j(),'p')}k#{b}";
+ Tokenizer t = createJbossTokenizer();
+ LexicalToken token = t.parse(text);
+ LexicalToken ti = token;
+
+ while(ti != null) {
+ int type = ti.getType();
+ System.out.println(type + ":" + ti.getText() + ":");
+ ti = ti.getNextToken();
+ }
+ List<SyntaxError> errors = t.getErrors();
+ for (SyntaxError e: errors) {
+ System.out.println("state=" + e.getState() + " position=" +
e.getPosition());
+ }
+ ELParser parser = ELParserFactory.createJbossParser();
+ ELModel model = parser.parse(text);
+ System.out.println(model);
+ ELExpression expr = model.getInstances().get(0).getExpression();
+ System.out.println("Expression=" + expr);
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELArgumentExpressionImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELArgumentExpressionImpl.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELArgumentExpressionImpl.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.model;
+
+import org.jboss.tools.common.el.core.model.ELArgumentInvocation;
+import org.jboss.tools.common.el.core.model.ELObjectType;
+
+/**
+ *
+ * @author V. Kabanovich
+ */
+public class ELArgumentExpressionImpl extends ELInvocationExpressionImpl implements
ELArgumentInvocation {
+ ELArgumentImpl argument;
+
+ public ELArgumentExpressionImpl() {}
+
+ public void addChild(ELObjectImpl child) {
+ }
+
+ public ELArgumentImpl getArgument() {
+ return argument;
+ }
+
+ public void setArgument(ELArgumentImpl argument) {
+ this.argument = argument;
+ if(argument != null) {
+ argument.setParent(this);
+ setLastToken(argument.getLastToken());
+ }
+ }
+
+ public String toString() {
+ return super.toString() + ((argument != null) ? argument.toString() : "");
+ }
+
+ public ELObjectType getType() {
+ return ELObjectType.EL_ARGUMENT_INVOCATION;
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELArgumentImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELArgumentImpl.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELArgumentImpl.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.model;
+
+import org.jboss.tools.common.el.core.model.ELArgument;
+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.parser.token.ArgEndTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.ArgStartTokenDescription;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class ELArgumentImpl extends ELObjectImpl implements ELArgument {
+ ELExpressionImpl argument;
+
+ public ELArgumentImpl() {}
+
+ public ELExpressionImpl getArgument() {
+ return argument;
+ }
+
+ public LexicalToken getOpenArgumentToken() {
+ LexicalToken result = getFirstToken();
+ if(result != null && result.getType() == ArgStartTokenDescription.ARG_START) {
+ return result;
+ } else {
+ return null;
+ }
+ }
+
+ public LexicalToken getCloseArgumentToken() {
+ LexicalToken result = getLastToken();
+ if(result != null && result.getType() == ArgEndTokenDescription.ARG_END) {
+ return result;
+ } else {
+ return null;
+ }
+ }
+
+ public void addChild(ELObjectImpl child) {
+ if(child instanceof ELExpressionImpl) {
+ setArgument((ELExpressionImpl)child);
+ } else {
+ throw new IllegalArgumentException("EL argument can have only EL expression as
its child.");
+ }
+ }
+
+ public void setArgument(ELExpressionImpl arg) {
+ if(argument == arg) return;
+ if(argument != null) {
+ removeChild(argument);
+ }
+ if(arg != null) {
+ super.addChild(arg);
+ }
+ argument = arg;
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ if(getOpenArgumentToken() != null) {
+ sb.append(getOpenArgumentToken().getText());
+ }
+ if(argument != null) {
+ sb.append(argument.toString());
+ }
+ if(getCloseArgumentToken() != null) {
+ sb.append(getCloseArgumentToken().getText());
+ }
+ return sb.toString();
+ }
+
+ public ELObjectType getType() {
+ return ELObjectType.EL_ARGUMENT;
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELComplexExpressionImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELComplexExpressionImpl.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELComplexExpressionImpl.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.model;
+
+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.parser.token.ExprEndTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.ExprStartTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.UnaryTokenDescription;
+
+/**
+ * '(' expression ')'
+ * @author V. Kabanovich
+ */
+public class ELComplexExpressionImpl extends ELExpressionImpl {
+ ELExpressionImpl expression;
+
+ public ELComplexExpressionImpl() {
+ }
+
+ public ELExpressionImpl getExpression() {
+ return expression;
+ }
+
+ public LexicalToken getOpenExpressionToken() {
+ LexicalToken result = getFirstToken();
+ if(result != null &&
+ (result.getType() == ExprStartTokenDescription.EXPR_START
+ || result.getType() == UnaryTokenDescription.UNARY)) {
+ return result;
+ } else {
+ return null;
+ }
+ }
+
+ public LexicalToken getCloseExpressionToken() {
+ LexicalToken result = getLastToken();
+ if(result != null && result.getType() == ExprEndTokenDescription.EXPR_END) {
+ return result;
+ } else {
+ return null;
+ }
+ }
+
+ public void addChild(ELObjectImpl child) {
+ if(child instanceof ELExpressionImpl) {
+ setExpression((ELExpressionImpl)child);
+ } else {
+ throw new IllegalArgumentException("EL instance can have only EL expression as
child.");
+ }
+ }
+
+ public void setExpression(ELExpressionImpl expression) {
+ if(this.expression == expression) {
+ return;
+ }
+ if(this.expression != null) {
+ removeChild(this.expression);
+ }
+ this.expression = expression;
+ if(expression != null) {
+ super.addChild(expression);
+ }
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ if(getOpenExpressionToken() != null) {
+ sb.append(getOpenExpressionToken().getText());
+ }
+ if(expression != null) {
+ sb.append(expression.toString());
+ }
+ if(getCloseExpressionToken() != null) {
+ sb.append(getCloseExpressionToken().getText());
+ }
+ return sb.toString();
+ }
+
+ public ELObjectType getType() {
+ return ELObjectType.EL_COMPLEX_EXPRESSION;
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELExpressionImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELExpressionImpl.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELExpressionImpl.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.model;
+
+import org.jboss.tools.common.el.core.model.ELExpression;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public abstract class ELExpressionImpl extends ELObjectImpl implements ELExpression {
+
+ public ELExpressionImpl() {}
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELInstanceImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELInstanceImpl.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELInstanceImpl.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.model;
+
+import org.jboss.tools.common.el.core.model.ELExpression;
+import org.jboss.tools.common.el.core.model.ELInstance;
+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.parser.token.EndELTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.StartELTokenDescription;
+
+/**
+ * '#{' expression '}'
+ * @author V. Kabanovich
+ */
+public class ELInstanceImpl extends ELObjectImpl implements ELInstance {
+ ELExpressionImpl expression;
+
+ public ELInstanceImpl() {
+ }
+
+ public LexicalToken getOpenInstanceToken() {
+ LexicalToken result = getFirstToken();
+ if(result != null && result.getType() == StartELTokenDescription.START_EL) {
+ return result;
+ } else {
+ return null;
+ }
+ }
+
+ public LexicalToken getCloseInstanceToken() {
+ LexicalToken result = getLastToken();
+ if(result != null && result.getType() == EndELTokenDescription.END_EL) {
+ return result;
+ } else {
+ return null;
+ }
+ }
+
+ public ELExpression getExpression() {
+ return expression;
+ }
+
+ public void addChild(ELObjectImpl child) {
+ if(child instanceof ELExpressionImpl) {
+ setExpression((ELExpressionImpl)child);
+ } else {
+ throw new IllegalArgumentException("EL instance can have only EL expression as
child.");
+ }
+ }
+
+ public void setExpression(ELExpressionImpl expression) {
+ if(this.expression == expression) {
+ return;
+ }
+ if(this.expression != null) {
+ removeChild(this.expression);
+ }
+ this.expression = expression;
+ if(expression != null) {
+ super.addChild(expression);
+ }
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ if(getOpenInstanceToken() != null) {
+ sb.append(getOpenInstanceToken().getText());
+ }
+ if(expression != null) {
+ sb.append(expression.toString());
+ }
+ if(getCloseInstanceToken() != null) {
+ sb.append(getCloseInstanceToken().getText());
+ }
+ return sb.toString();
+ }
+
+ public ELObjectType getType() {
+ return ELObjectType.EL_INSTANCE;
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELInvocationExpressionImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELInvocationExpressionImpl.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELInvocationExpressionImpl.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.model;
+
+import org.jboss.tools.common.el.core.model.ELInvocationExpression;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public abstract class ELInvocationExpressionImpl extends ELExpressionImpl implements
ELInvocationExpression {
+ protected ELInvocationExpressionImpl left;
+
+ public ELInvocationExpressionImpl() {}
+
+ public void addChild(ELObjectImpl child) {
+ }
+
+ public ELInvocationExpressionImpl getLeft() {
+ return left;
+ }
+
+ public void setLeft(ELInvocationExpressionImpl left) {
+ this.left = left;
+ if(left != null) {
+ left.setParent(this);
+ setFirstToken(left.getFirstToken());
+ }
+ }
+
+ public String toString() {
+ return left != null ? left.toString() : "";
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELMethodInvocationImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELMethodInvocationImpl.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELMethodInvocationImpl.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.model;
+
+import org.jboss.tools.common.el.core.model.ELMethodInvocation;
+import org.jboss.tools.common.el.core.model.ELObjectType;
+
+/**
+ * LEFT . name parameters
+ * @author V. Kabanovich
+ */
+public class ELMethodInvocationImpl extends ELPropertyInvocationImpl implements
ELMethodInvocation {
+ ELParametersImpl parameters;
+
+ public ELMethodInvocationImpl() {}
+
+ public void addChild(ELObjectImpl child) {
+ }
+
+ public ELParametersImpl getParameters() {
+ return parameters;
+ }
+
+ public void setParameters(ELParametersImpl parameters) {
+ this.parameters = parameters;
+ if(parameters != null) {
+ parameters.setParent(this);
+ setLastToken(parameters.getLastToken());
+ }
+ }
+
+ public String getQualifiedName() {
+ return null;
+ }
+
+ public String toString() {
+ return super.toString() + ((parameters != null) ? parameters.toString() :
"");
+ }
+
+ public ELObjectType getType() {
+ return ELObjectType.EL_METHOD_INVOCATION;
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELModelImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELModelImpl.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELModelImpl.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.tools.common.el.core.model.ELInstance;
+import org.jboss.tools.common.el.core.model.ELModel;
+import org.jboss.tools.common.el.core.model.ELObjectType;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class ELModelImpl extends ELObjectImpl implements ELModel {
+ String source;
+ List<ELInstance> instances = new ArrayList<ELInstance>();
+
+ public ELModelImpl() {}
+
+ public ELModelImpl getModel() {
+ return this;
+ }
+
+ public String getSource() {
+ return source;
+ }
+
+ public List<ELInstance> getInstances() {
+ return instances;
+ }
+
+ public void setSource(String source) {
+ this.source = source;
+ }
+
+ public void addChild(ELObjectImpl child) {
+ if(child instanceof ELInstanceImpl) {
+ addInstance((ELInstanceImpl)child);
+ } else {
+ throw new IllegalArgumentException("EL root can have onle ELInstances as its
children.");
+ }
+ }
+
+ public void addInstance(ELInstanceImpl instance) {
+ super.addChild(instance);
+ instances.add(instance);
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ for (ELInstance p: instances) {
+ sb.append(p.toString());
+ }
+ return sb.toString();
+ }
+
+ public ELObjectType getType() {
+ return ELObjectType.EL_MODEL;
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELMultiExpressionImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELMultiExpressionImpl.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELMultiExpressionImpl.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.tools.common.el.core.model.ELObject;
+import org.jboss.tools.common.el.core.model.ELObjectType;
+
+/**
+ * expression (operation expression)+
+ * @author V. Kabanovich
+ */
+public class ELMultiExpressionImpl extends ELExpressionImpl {
+ List<ELExpressionImpl> expressions = new ArrayList<ELExpressionImpl>();
+ List<ELOperatorImpl> operators = new ArrayList<ELOperatorImpl>();
+
+ public ELMultiExpressionImpl() {
+ }
+
+ public List<ELExpressionImpl> getExpressions() {
+ return expressions;
+ }
+
+ public List<ELOperatorImpl> getOperators() {
+ return operators;
+ }
+
+ public void addChild(ELObjectImpl child) {
+ if(child instanceof ELExpressionImpl) {
+ addExpression((ELExpressionImpl)child);
+ } else if(child instanceof ELOperatorImpl) {
+ addOperator((ELOperatorImpl)child);
+ } else {
+ throw new IllegalArgumentException("EL instance can have only EL expression as
child.");
+ }
+ }
+
+ public void addExpression(ELExpressionImpl expression) {
+ if(expressions.size() > operators.size()) {
+ throw new IllegalArgumentException("Expecting operator");
+ }
+ super.addChild(expression);
+ expressions.add(expression);
+ }
+
+ public void addOperator(ELOperatorImpl operator) {
+ while(expressions.size() <= operators.size()) {
+ addChild(new ELExpressionImpl() {
+ public ELObjectType getType() {
+ return ELObjectType.EL_UNKNOWN;
+ }
+ });
+ }
+ super.addChild(operator);
+ operators.add(operator);
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ if(children != null) for (ELObject c: children) {
+ sb.append(c.toString());
+ }
+ return sb.toString();
+ }
+
+ public ELObjectType getType() {
+ return ELObjectType.EL_MULTI_EXPRESSION;
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELObjectImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELObjectImpl.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELObjectImpl.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.tools.common.el.core.model.ELObject;
+import org.jboss.tools.common.el.core.parser.LexicalToken;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public abstract class ELObjectImpl implements ELObject {
+ protected LexicalToken firstToken;
+ protected LexicalToken lastToken;
+ protected ELObjectImpl parent;
+ protected List<ELObject> children = new ArrayList<ELObject>();
+
+ public ELObjectImpl() {
+ }
+
+ public ELModelImpl getModel() {
+ return parent == null ? null : parent.getModel();
+ }
+
+ public int getLength() {
+ int start = firstToken.getStart();
+ LexicalToken lt = (lastToken != null) ? lastToken : firstToken;
+ int end = lt.getStart() + lt.getLength();
+ return end - start;
+ }
+
+ public String getText() {
+ if(getModel() == null) return null;
+ String source = getModel().getSource();
+ int start = firstToken.getStart();
+ LexicalToken lt = (lastToken != null) ? lastToken : firstToken;
+ int end = lt.getStart() + lt.getLength();
+ return source.substring(start, end);
+ }
+
+ public ELObjectImpl getParent() {
+ return parent;
+ }
+
+ public List<ELObject> getChildren() {
+ return children;
+ }
+
+ public LexicalToken getFirstToken() {
+ return firstToken;
+ }
+
+ public LexicalToken getLastToken() {
+ return lastToken;
+ }
+
+ public void setParent(ELObjectImpl parent) {
+ this.parent = parent;
+ }
+
+ public void addChild(ELObjectImpl child) {
+ children.add(child);
+ child.setParent(this);
+ }
+
+ protected void removeChild(ELObjectImpl child) {
+ if(children.contains(child)) {
+ children.remove(child);
+ child.setParent(null);
+ }
+ }
+
+ public void setFirstToken(LexicalToken firstToken) {
+ this.firstToken = firstToken;
+ }
+
+ public void setLastToken(LexicalToken lastToken) {
+ this.lastToken = lastToken;
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELOperatorImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELOperatorImpl.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELOperatorImpl.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.model;
+
+import org.jboss.tools.common.el.core.model.ELObjectType;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class ELOperatorImpl extends ELObjectImpl {
+
+ public ELOperatorImpl() {}
+
+ public void addChild(ELObjectImpl child) {
+ }
+
+ public String toString() {
+ return getFirstToken() != null ? getFirstToken().getText() : "";
+ }
+
+ public ELObjectType getType() {
+ return ELObjectType.EL_OPERATOR;
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELParametersImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELParametersImpl.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELParametersImpl.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.tools.common.el.core.model.ELExpression;
+import org.jboss.tools.common.el.core.model.ELObjectType;
+import org.jboss.tools.common.el.core.model.ELParameters;
+import org.jboss.tools.common.el.core.parser.LexicalToken;
+import org.jboss.tools.common.el.internal.core.parser.token.ParamEndTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.ParamStartTokenDescription;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class ELParametersImpl extends ELObjectImpl implements ELParameters {
+ List<ELExpression> parameters = new ArrayList<ELExpression>();
+
+ public ELParametersImpl() {}
+
+ public LexicalToken getOpenParametersToken() {
+ LexicalToken result = getFirstToken();
+ if(result != null && result.getType() ==
ParamStartTokenDescription.PARAM_START) {
+ return result;
+ } else {
+ return null;
+ }
+ }
+
+ public LexicalToken getCloseParametersToken() {
+ LexicalToken result = getLastToken();
+ if(result != null && result.getType() == ParamEndTokenDescription.PARAM_END) {
+ return result;
+ } else {
+ return null;
+ }
+ }
+
+ public List<ELExpression> getParameters() {
+ return parameters;
+ }
+
+ public void addChild(ELObjectImpl child) {
+ if(child instanceof ELExpressionImpl) {
+ addParameter((ELExpressionImpl)child);
+ } else {
+ throw new IllegalArgumentException("EL parameters can have only EL expressions as
its children.");
+ }
+ }
+
+ public void addParameter(ELExpressionImpl param) {
+ super.addChild(param);
+ parameters.add(param);
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer();
+ LexicalToken t = getOpenParametersToken();
+ if(t != null) sb.append(t.getText());
+ boolean first = true;
+ for (ELExpression p: parameters) {
+ if(!first) {
+ sb.append(',');
+ } else {
+ first = false;
+ }
+ sb.append(p.toString());
+
+ }
+ t = getCloseParametersToken();
+ if(t != null) sb.append(t.getText());
+ return sb.toString();
+ }
+
+ public ELObjectType getType() {
+ return ELObjectType.EL_PARAMETERS;
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELPropertyInvocationImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELPropertyInvocationImpl.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELPropertyInvocationImpl.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.model;
+
+import org.jboss.tools.common.el.core.model.ELObjectType;
+import org.jboss.tools.common.el.core.model.ELPropertyInvocation;
+import org.jboss.tools.common.el.core.parser.LexicalToken;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class ELPropertyInvocationImpl extends ELInvocationExpressionImpl implements
ELPropertyInvocation {
+ LexicalToken dot;
+ LexicalToken name;
+
+ public ELPropertyInvocationImpl() {}
+
+ public void addChild(ELObjectImpl child) {
+ }
+
+ public LexicalToken getSeparator() {
+ return dot;
+ }
+
+ public LexicalToken getName() {
+ return name;
+ }
+
+ public void setName(LexicalToken name) {
+ this.name = name;
+ if(name != null) {
+ if(left == null) setFirstToken(name);
+ }
+ }
+
+ public void setSeparator(LexicalToken separator) {
+ dot = separator;
+ }
+
+ public String getQualifiedName() {
+ if(name == null) return null;
+ if(left == null) return name.getText();
+ if(!(left instanceof ELPropertyInvocationImpl)) {
+ return null;
+ }
+ String p = ((ELPropertyInvocationImpl)left).getQualifiedName();
+ if(p == null) return null;
+ return p + "." + name.getText();
+ }
+
+ public String toString() {
+ return super.toString() + (dot != null ? dot.getText() : "")
+ + (name != null ? name.getText() : "");
+ }
+
+ public ELObjectType getType() {
+ return ELObjectType.EL_PROPERTY_INVOCATION;
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELValueExpressionImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELValueExpressionImpl.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/model/ELValueExpressionImpl.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.model;
+
+import org.jboss.tools.common.el.core.model.ELObjectType;
+
+/**
+ * string | primitive
+ * @author V. Kabanovich
+ */
+public class ELValueExpressionImpl extends ELExpressionImpl {
+
+ public ELValueExpressionImpl() {}
+
+ public void addChild(ELObjectImpl child) {
+ }
+
+ public String toString() {
+ return getFirstToken() != null ? getFirstToken().getText() : "";
+ }
+
+ public ELObjectType getType() {
+ return ELObjectType.EL_VALUE;
+ }
+
+}
Added:
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
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/ELParserImpl.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,275 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.parser;
+
+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;
+import org.jboss.tools.common.el.internal.core.model.ELComplexExpressionImpl;
+import org.jboss.tools.common.el.internal.core.model.ELExpressionImpl;
+import org.jboss.tools.common.el.internal.core.model.ELInstanceImpl;
+import org.jboss.tools.common.el.internal.core.model.ELInvocationExpressionImpl;
+import org.jboss.tools.common.el.internal.core.model.ELMethodInvocationImpl;
+import org.jboss.tools.common.el.internal.core.model.ELModelImpl;
+import org.jboss.tools.common.el.internal.core.model.ELMultiExpressionImpl;
+import org.jboss.tools.common.el.internal.core.model.ELOperatorImpl;
+import org.jboss.tools.common.el.internal.core.model.ELParametersImpl;
+import org.jboss.tools.common.el.internal.core.model.ELPropertyInvocationImpl;
+import org.jboss.tools.common.el.internal.core.model.ELValueExpressionImpl;
+import org.jboss.tools.common.el.internal.core.parser.token.ArgEndTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.ArgStartTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.CommaTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.DotTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.EndELTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.ExprEndTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.ExprStartTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.JavaNameTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.OperationTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.ParamEndTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.ParamStartTokenDescription;
+import
org.jboss.tools.common.el.internal.core.parser.token.PrimitiveValueTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.StartELTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.StringTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.UnaryTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.WhiteSpaceTokenDescription;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class ELParserImpl {
+ ELModelImpl model;
+
+ LexicalToken current;
+
+ public ELModelImpl parse(LexicalToken start) {
+ model = new ELModelImpl();
+ current = start;
+ while(current != null) {
+ if(current.getType() == StartELTokenDescription.START_EL) {
+ ELInstanceImpl instance = readELInstance();
+ if(instance != null) {
+ model.addInstance(instance);
+ }
+ } else if(!hasNextToken()) {
+ break;
+ } else {
+ setNextToken();
+ }
+ }
+ return model;
+ }
+
+ protected ELInstanceImpl readELInstance() {
+ if(current.getType() != StartELTokenDescription.START_EL) {
+ return null;
+ }
+ ELInstanceImpl instance = new ELInstanceImpl();
+ instance.setFirstToken(current);
+ setNextToken();
+ ELExpressionImpl expression = readExpression();
+ if(expression != null) {
+ instance.setExpression(expression);
+ instance.setLastToken(expression.getLastToken());
+ }
+ do {
+ if(current.getType() == StartELTokenDescription.START_EL) {
+ instance.setLastToken(current.getPreviousToken());
+ return instance;
+ } else if(current.getType() == EndELTokenDescription.END_EL) {
+ instance.setLastToken(current);
+ setNextToken();
+ return instance;
+ } else if(!hasNextToken()) {
+ instance.setLastToken(current);
+ return instance;
+ }
+ setNextToken();
+ } while(true);
+ }
+
+ protected ELExpressionImpl readExpression() {
+ ELExpressionImpl single = readSingleExpression();
+ if(single == null) return null;
+ if(current.getType() != OperationTokenDescription.OPERATION) {
+ return single;
+ }
+ ELMultiExpressionImpl multi = new ELMultiExpressionImpl();
+ multi.setFirstToken(single.getFirstToken());
+ multi.addExpression(single);
+ while(current.getType() == OperationTokenDescription.OPERATION &&
hasNextToken()) {
+ ELOperatorImpl operator = new ELOperatorImpl();
+ operator.setFirstToken(current);
+ operator.setLastToken(current);
+ multi.addOperator(operator);
+ multi.setLastToken(operator.getLastToken());
+ setNextToken();
+ single = readSingleExpression();
+ if(single != null) {
+ multi.addExpression(single);
+ multi.setLastToken(single.getLastToken());
+ }
+ }
+ return multi;
+ }
+
+ protected ELExpressionImpl readSingleExpression() {
+ switch(current.getType()) {
+ case ExprStartTokenDescription.EXPR_START:
+ case UnaryTokenDescription.UNARY:
+ return readComplexExpression();
+ case PrimitiveValueTokenDescription.PRIMITIVE_VALUE:
+ case StringTokenDescription.STRING:
+ ELExpressionImpl expr = new ELValueExpressionImpl();
+ expr.setFirstToken(current);
+ expr.setLastToken(current);
+ setNextToken();
+ return expr;
+ case JavaNameTokenDescription.JAVA_NAME:
+ return readInvocationExpression();
+ }
+ return null;
+ }
+
+ protected ELExpressionImpl readComplexExpression() {
+ ELComplexExpressionImpl expr = new ELComplexExpressionImpl();
+ expr.setFirstToken(current);
+ if(!hasNextToken()) {
+ expr.setLastToken(current);
+ return expr;
+ }
+ setNextToken();
+ ELExpressionImpl child = readExpression();
+ if(child != null) {
+ expr.setExpression(child);
+ expr.setLastToken(child.getLastToken());
+ }
+ if(current.getType() == ExprEndTokenDescription.EXPR_END) {
+ expr.setLastToken(current);
+ setNextToken();
+ }
+ return expr;
+ }
+
+ protected ELInvocationExpressionImpl readInvocationExpression() {
+ if(current.getType() != JavaNameTokenDescription.JAVA_NAME) {
+ return null;
+ }
+ ELPropertyInvocationImpl name = new ELPropertyInvocationImpl();
+ name.setName(current);
+ ELInvocationExpressionImpl result = name;
+ setNextToken();
+ switch (current.getType()) {
+ case ArgStartTokenDescription.ARG_START:
+ while(current.getType() == ArgStartTokenDescription.ARG_START) {
+ ELArgumentImpl arg = readArgument();
+ ELArgumentExpressionImpl call = new ELArgumentExpressionImpl();
+ call.setArgument(arg);
+ call.setLeft(result);
+ result = call;
+ }
+ break;
+ case ParamStartTokenDescription.PARAM_START:
+ ELParametersImpl params = readParameters();
+ ELMethodInvocationImpl method = new ELMethodInvocationImpl();
+ method.setParameters(params);
+ method.setName(name.getName());
+ result = method;
+ }
+ if(current.getType() == DotTokenDescription.DOT) {
+ LexicalToken dot = current;
+ setNextToken();
+ ELInvocationExpressionImpl right = readInvocationExpression();
+ if(right != null) {
+ ELInvocationExpressionImpl r = right;
+ while(r.getLeft() != null) r = r.getLeft();
+ if(r instanceof ELPropertyInvocationImpl) {
+ ((ELPropertyInvocationImpl)r).setSeparator(dot);
+ } else {
+ //is it possible?
+ }
+ r.setLeft(result);
+ result = right;
+ }
+ }
+ return result;
+ }
+
+ protected ELParametersImpl readParameters() {
+ ELParametersImpl parameters = new ELParametersImpl();
+ parameters.setFirstToken(current);
+ if(!hasNextToken()) {
+ parameters.setLastToken(current);
+ return parameters;
+ }
+ setNextToken();
+ ELExpressionImpl expression = readExpression();
+ if(expression != null) {
+ parameters.addParameter(expression);
+ parameters.setLastToken(expression.getLastToken());
+ }
+ while(current.getType() == CommaTokenDescription.COMMA) {
+ if(!hasNextToken()) {
+ parameters.setLastToken(current);
+ return parameters;
+ }
+ setNextToken();
+ expression = readExpression();
+ if(expression != null) {
+ parameters.addParameter(expression);
+ parameters.setLastToken(expression.getLastToken());
+ }
+ }
+ if(current.getType() == ParamEndTokenDescription.PARAM_END) {
+ parameters.setLastToken(current);
+ setNextToken();
+ }
+
+ return parameters;
+ }
+
+ protected ELArgumentImpl readArgument() {
+ ELArgumentImpl arg = new ELArgumentImpl();
+ arg.setFirstToken(current);
+ arg.setLastToken(current);
+ if(!hasNextToken()) return arg;
+ setNextToken();
+ ELExpressionImpl expr = readExpression();
+ if(expr != null) {
+ arg.setArgument(expr);
+ arg.setLastToken(expr.getLastToken());
+ }
+ if(current.getType() == ArgEndTokenDescription.ARG_END) {
+ arg.setLastToken(current);
+ setNextToken();
+ }
+ return arg;
+ }
+
+ private boolean hasNextToken() {
+ return lookUpNextToken(current) != null;
+ }
+
+ private LexicalToken lookUpNextToken(LexicalToken token) {
+ LexicalToken c = token;
+ while(c != null && (c == token || c.getType() ==
WhiteSpaceTokenDescription.WHITESPACE)) {
+ c = c.getNextToken();
+ }
+ return c;
+ }
+
+ private void setNextToken() {
+ LexicalToken t = lookUpNextToken(current);
+ if(t != null) current = t;
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/ArgRule.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/ArgRule.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/ArgRule.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.parser.rule;
+
+import org.jboss.tools.common.el.core.parser.IRule;
+import org.jboss.tools.common.el.internal.core.parser.token.ArgEndTokenDescription;
+import
org.jboss.tools.common.el.internal.core.parser.token.PrimitiveValueTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.StringTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.WhiteSpaceTokenDescription;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class ArgRule implements IRule, BasicStates {
+
+ public static ArgRule INSTANCE = new ArgRule();
+
+ public int[] getStartStates() {
+ return new int[] {
+ STATE_EXPECTING_ARG,
+ STATE_EXPECTING_ARG_CLOSE,
+ };
+ }
+
+ public int getFinalState(int state, int token) {
+ switch (token) {
+ case WhiteSpaceTokenDescription.WHITESPACE:
+ return state;
+ case PrimitiveValueTokenDescription.PRIMITIVE_VALUE:
+ case StringTokenDescription.STRING:
+ return STATE_EXPECTING_ARG_CLOSE;
+ case ArgEndTokenDescription.ARG_END:
+ return STATE_EXPECTING_CALL_AFTER_METHOD;
+ }
+
+ return 0;
+ }
+
+ public int[] getTokenTypes(int state) {
+ switch(state) {
+ case STATE_EXPECTING_ARG:
+ return new int[] {
+ WhiteSpaceTokenDescription.WHITESPACE,
+ PrimitiveValueTokenDescription.PRIMITIVE_VALUE,
+ StringTokenDescription.STRING,
+ };
+ case STATE_EXPECTING_ARG_CLOSE:
+ return new int[] {
+ WhiteSpaceTokenDescription.WHITESPACE,
+ ArgEndTokenDescription.ARG_END,
+ };
+ }
+ return new int[0];
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/BasicStates.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/BasicStates.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/BasicStates.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.parser.rule;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public interface BasicStates {
+ public int STATE_EXPECTING_EL = 0;
+ // 1) "#{" --> EXPRESSION
+ public int STATE_ERROR = -1;
+
+
+ public int STATE_EXPECTING_EXPRESSION = 101;
+ // 1) "}" --> EL
+ // 2) NAME --> call
+ // 3) Primitive, String --> operation
+ // 4) unary, expr --> operand
+ public int STATE_EXPECTING_NAME = 102;
+ // 1) NAME --> call
+ public int STATE_EXPECTING_PARAM = 103;
+ // 1) ")" --> call after method
+ // 2) Primitive, String --> operation
+ // 3) NAME --> call
+ // 4) unary, expr --> operand
+ public int STATE_EXPECTING_OPERAND = 104;
+ // 1) Primitive, String --> operation
+ // 2) NAME --> call
+ // 4) unary, expr --> operand
+
+ public int STATE_EXPECTING_OPERATION = 400;
+ // 1) "," --> operand
+ // 2) ")" --> param: call after method
+ // expr: operation
+ // 3) Operation --> operand
+ // 4) not in param "}" --> EL
+
+ //For all calls: 1) not in params "}" --> EL
+ // 2) "." --> name
+ // 3) in params "," --> operand
+ // 4) in params OPERATION --> operand
+ // 5) in params ")" --> call after method
+ // in expr ")" --> operation
+ public int STATE_EXPECTING_CALL = 201;
+ // 5) "(" --> param
+ // 6) "[" --> arg
+ public int STATE_EXPECTING_CALL_AFTER_METHOD = 202; //same after arg
+
+ public int STATE_EXPECTING_ARG = 301;
+ // 1) Primitive, String --> arg close
+ public int STATE_EXPECTING_ARG_CLOSE = 302;
+ // 1) "]" --> call after method
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/CallRule.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/CallRule.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/CallRule.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.parser.rule;
+
+import org.jboss.tools.common.el.core.parser.IRule;
+import org.jboss.tools.common.el.internal.core.parser.token.ArgStartTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.CommaTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.DotTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.EndELTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.ExprEndTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.OperationTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.ParamEndTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.ParamStartTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.WhiteSpaceTokenDescription;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class CallRule implements IRule, BasicStates {
+
+ public static CallRule INSTANCE = new CallRule();
+
+ public int[] getStartStates() {
+ return new int[] {
+ STATE_EXPECTING_CALL,
+ STATE_EXPECTING_CALL_AFTER_METHOD,
+ };
+ }
+
+ public int getFinalState(int state, int token) {
+ switch (token) {
+ case WhiteSpaceTokenDescription.WHITESPACE:
+ return state;
+ case EndELTokenDescription.END_EL:
+ return STATE_EXPECTING_EL;
+ case DotTokenDescription.DOT:
+ return STATE_EXPECTING_NAME;
+ case CommaTokenDescription.COMMA:
+ case OperationTokenDescription.OPERATION:
+ return STATE_EXPECTING_OPERAND;
+ case ParamEndTokenDescription.PARAM_END:
+ return STATE_EXPECTING_CALL_AFTER_METHOD;
+ case ParamStartTokenDescription.PARAM_START:
+ return STATE_EXPECTING_PARAM;
+ case ArgStartTokenDescription.ARG_START:
+ return STATE_EXPECTING_ARG;
+ case ExprEndTokenDescription.EXPR_END:
+ return STATE_EXPECTING_OPERATION;
+ }
+
+ return 0;
+ }
+
+ public int[] getTokenTypes(int state) {
+ switch(state) {
+ case STATE_EXPECTING_CALL:
+ return new int[] {
+ WhiteSpaceTokenDescription.WHITESPACE,
+ EndELTokenDescription.END_EL,
+ DotTokenDescription.DOT,
+ CommaTokenDescription.COMMA,
+ OperationTokenDescription.OPERATION,
+ ParamEndTokenDescription.PARAM_END,
+ ExprEndTokenDescription.EXPR_END,
+ ParamStartTokenDescription.PARAM_START,
+ ArgStartTokenDescription.ARG_START,
+ };
+ case STATE_EXPECTING_CALL_AFTER_METHOD:
+ return new int[] {
+ WhiteSpaceTokenDescription.WHITESPACE,
+ EndELTokenDescription.END_EL,
+ DotTokenDescription.DOT,
+ CommaTokenDescription.COMMA,
+ OperationTokenDescription.OPERATION,
+ ParamEndTokenDescription.PARAM_END,
+ ExprEndTokenDescription.EXPR_END,
+ };
+ }
+ return new int[0];
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/ErrorRecoveryRule.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/ErrorRecoveryRule.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/ErrorRecoveryRule.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.parser.rule;
+
+import org.jboss.tools.common.el.core.parser.IRule;
+import org.jboss.tools.common.el.internal.core.parser.token.ArgEndTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.EndELTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.ExprEndTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.ParamEndTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.StartELTokenDescription;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class ErrorRecoveryRule implements IRule {
+
+ public static ErrorRecoveryRule INSTANCE = new ErrorRecoveryRule();
+
+ public int getFinalState(int state, int token) {
+ switch (token) {
+ case EndELTokenDescription.END_EL:
+ return BasicStates.STATE_EXPECTING_EL;
+ case StartELTokenDescription.START_EL:
+ return BasicStates.STATE_EXPECTING_EXPRESSION;
+ case ArgEndTokenDescription.ARG_END:
+ return BasicStates.STATE_EXPECTING_CALL_AFTER_METHOD;
+ case ParamEndTokenDescription.PARAM_END:
+ return BasicStates.STATE_EXPECTING_CALL_AFTER_METHOD;
+ case ExprEndTokenDescription.EXPR_END:
+ return BasicStates.STATE_EXPECTING_OPERATION;
+ }
+ return 0;
+ }
+
+ public int[] getStartStates() {
+ return new int[]{BasicStates.STATE_ERROR};
+ }
+
+ public int[] getTokenTypes(int state) {
+ return new int[]{
+ ArgEndTokenDescription.ARG_END,
+ ParamEndTokenDescription.PARAM_END,
+ ExprEndTokenDescription.EXPR_END,
+ EndELTokenDescription.END_EL,
+ StartELTokenDescription.START_EL
+ };
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/ExpressionRule.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/ExpressionRule.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/ExpressionRule.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,114 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.parser.rule;
+
+import org.jboss.tools.common.el.core.parser.IRule;
+import org.jboss.tools.common.el.internal.core.parser.token.EndELTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.ExprStartTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.JavaNameTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.ParamEndTokenDescription;
+import
org.jboss.tools.common.el.internal.core.parser.token.PrimitiveValueTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.StartELTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.StringTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.UnaryTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.WhiteSpaceTokenDescription;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class ExpressionRule implements IRule, BasicStates {
+
+ public static ExpressionRule INSTANCE = new ExpressionRule();
+
+ public int[] getStartStates() {
+ return new int[] {
+ STATE_EXPECTING_EL,
+
+ STATE_EXPECTING_EXPRESSION,
+ STATE_EXPECTING_NAME,
+ STATE_EXPECTING_PARAM,
+ STATE_EXPECTING_OPERAND
+ };
+ }
+
+ public int getFinalState(int state, int token) {
+ switch (token) {
+ case StartELTokenDescription.START_EL:
+ return STATE_EXPECTING_EXPRESSION;
+
+ case WhiteSpaceTokenDescription.WHITESPACE:
+ return state;
+ case EndELTokenDescription.END_EL:
+ return STATE_EXPECTING_EL;
+ case JavaNameTokenDescription.JAVA_NAME:
+ return STATE_EXPECTING_CALL;
+ case StringTokenDescription.STRING:
+ case PrimitiveValueTokenDescription.PRIMITIVE_VALUE:
+ return STATE_EXPECTING_OPERATION;
+ case ParamEndTokenDescription.PARAM_END:
+ return STATE_EXPECTING_CALL_AFTER_METHOD;
+ case ExprStartTokenDescription.EXPR_START:
+ case UnaryTokenDescription.UNARY:
+ return STATE_EXPECTING_OPERAND;
+ }
+
+ return 0;
+ }
+
+ public int[] getTokenTypes(int state) {
+ switch(state) {
+ case STATE_EXPECTING_EL:
+ return new int[]{
+ StartELTokenDescription.START_EL
+ };
+
+ case STATE_EXPECTING_EXPRESSION:
+ return new int[] {
+ WhiteSpaceTokenDescription.WHITESPACE,
+ EndELTokenDescription.END_EL,
+ PrimitiveValueTokenDescription.PRIMITIVE_VALUE,
+ JavaNameTokenDescription.JAVA_NAME,
+ StringTokenDescription.STRING,
+ ExprStartTokenDescription.EXPR_START,
+ UnaryTokenDescription.UNARY,
+ };
+ case STATE_EXPECTING_NAME:
+ return new int[] {
+ WhiteSpaceTokenDescription.WHITESPACE,
+ JavaNameTokenDescription.JAVA_NAME,
+ };
+ case STATE_EXPECTING_PARAM:
+ return new int[] {
+ WhiteSpaceTokenDescription.WHITESPACE,
+ PrimitiveValueTokenDescription.PRIMITIVE_VALUE,
+ JavaNameTokenDescription.JAVA_NAME,
+ StringTokenDescription.STRING,
+ ExprStartTokenDescription.EXPR_START,
+ UnaryTokenDescription.UNARY,
+ ParamEndTokenDescription.PARAM_END
+ };
+ case STATE_EXPECTING_OPERAND:
+ return new int[] {
+ WhiteSpaceTokenDescription.WHITESPACE,
+ PrimitiveValueTokenDescription.PRIMITIVE_VALUE,
+ StringTokenDescription.STRING,
+ ExprStartTokenDescription.EXPR_START,
+ UnaryTokenDescription.UNARY,
+ JavaNameTokenDescription.JAVA_NAME,
+ };
+
+ }
+ return new int[0];
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/OperationRule.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/OperationRule.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/rule/OperationRule.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.parser.rule;
+
+import org.jboss.tools.common.el.core.parser.IRule;
+import org.jboss.tools.common.el.internal.core.parser.token.CommaTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.EndELTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.ExprEndTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.OperationTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.ParamEndTokenDescription;
+import org.jboss.tools.common.el.internal.core.parser.token.WhiteSpaceTokenDescription;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class OperationRule implements IRule, BasicStates {
+
+ public static OperationRule INSTANCE = new OperationRule();
+
+ public int[] getStartStates() {
+ return new int[] {
+ STATE_EXPECTING_OPERATION,
+ };
+ }
+
+ public int getFinalState(int state, int token) {
+ switch (token) {
+ case WhiteSpaceTokenDescription.WHITESPACE:
+ return state;
+ case EndELTokenDescription.END_EL:
+ return STATE_EXPECTING_EL;
+ case CommaTokenDescription.COMMA:
+ case OperationTokenDescription.OPERATION:
+ return STATE_EXPECTING_OPERAND;
+ case ParamEndTokenDescription.PARAM_END:
+ return STATE_EXPECTING_CALL_AFTER_METHOD;
+ case ExprEndTokenDescription.EXPR_END:
+ return STATE_EXPECTING_OPERATION;
+ }
+
+ return 0;
+ }
+
+ public int[] getTokenTypes(int state) {
+ if(state == STATE_EXPECTING_OPERATION) {
+ return new int[] {
+ WhiteSpaceTokenDescription.WHITESPACE,
+ ParamEndTokenDescription.PARAM_END,
+ ExprEndTokenDescription.EXPR_END,
+ CommaTokenDescription.COMMA,
+ OperationTokenDescription.OPERATION,
+ EndELTokenDescription.END_EL,
+ };
+ }
+ return new int[0];
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ArgEndTokenDescription.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ArgEndTokenDescription.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ArgEndTokenDescription.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.parser.token;
+
+import org.jboss.tools.common.el.core.parser.Tokenizer;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class ArgEndTokenDescription extends ConstantTokenDescription {
+ public static final int ARG_END = 11;
+ public static final String CLOSE = "]";
+
+ public static ArgEndTokenDescription INSTANCE = new ArgEndTokenDescription();
+
+ public ArgEndTokenDescription () {
+ super(CLOSE, ARG_END);
+ }
+
+ public boolean isStart(Tokenizer tokenizer, int offset) {
+ return isInArg(tokenizer) && super.isStart(tokenizer, offset);
+ }
+
+ public boolean read(Tokenizer tokenizer, int offset) {
+ boolean b = super.read(tokenizer, offset);
+ if(b) {
+ tokenizer.getContext().remove("arg");
+ }
+ return b;
+ }
+
+ private boolean isInArg(Tokenizer tokenizer) {
+ return tokenizer.getContext().get("arg") != null;
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ArgStartTokenDescription.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ArgStartTokenDescription.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ArgStartTokenDescription.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.parser.token;
+
+import org.jboss.tools.common.el.core.parser.Tokenizer;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class ArgStartTokenDescription extends ConstantTokenDescription {
+ public static final int ARG_START = 10;
+ public static final String OPEN = "[";
+
+ public static ArgStartTokenDescription INSTANCE = new ArgStartTokenDescription();
+
+ public ArgStartTokenDescription () {
+ super(OPEN, ARG_START);
+ }
+
+ public boolean read(Tokenizer tokenizer, int offset) {
+ boolean b = super.read(tokenizer, offset);
+ if(b) {
+ tokenizer.getContext().put("arg", OPEN);
+ }
+ return b;
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/CommaTokenDescription.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/CommaTokenDescription.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/CommaTokenDescription.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.parser.token;
+
+import org.jboss.tools.common.el.core.parser.Tokenizer;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class CommaTokenDescription extends ConstantTokenDescription {
+ public static final int COMMA = 8;
+
+ public static CommaTokenDescription INSTANCE = new CommaTokenDescription();
+
+ public CommaTokenDescription () {
+ super(",", COMMA);
+ }
+
+ public boolean isStart(Tokenizer tokenizer, int offset) {
+ if(!super.isStart(tokenizer, offset)) {
+ return false;
+ }
+ return ParamUtil.isMethodParamContext(tokenizer.getContext());
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ConstantTokenDescription.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ConstantTokenDescription.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ConstantTokenDescription.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.parser.token;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.tools.common.el.core.parser.ITokenDescription;
+import org.jboss.tools.common.el.core.parser.Tokenizer;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class ConstantTokenDescription implements ITokenDescription {
+ List<String> content = new ArrayList<String>();
+ int type;
+
+ public ConstantTokenDescription(String content, int type) {
+ this.content.add(content);
+ this.type = type;
+ }
+
+ protected void addContent(String content) {
+ this.content.add(content);
+ }
+
+ public String getName() {
+ return content.get(0);
+ }
+
+ public int getType() {
+ return type;
+ }
+
+ public boolean isStart(Tokenizer tokenizer, int offset) {
+ for (String s: content) {
+ if(tokenizer.startsWith(s)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean read(Tokenizer tokenizer, int offset) {
+ for (String s: content) {
+ if(tokenizer.startsWith(s)) {
+ tokenizer.addToken(type, offset, offset + s.length());
+ return true;
+ }
+ }
+ return true;
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/DotTokenDescription.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/DotTokenDescription.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/DotTokenDescription.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.parser.token;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class DotTokenDescription extends ConstantTokenDescription {
+ public static final int DOT = 4;
+
+ public static DotTokenDescription INSTANCE = new DotTokenDescription();
+
+ public DotTokenDescription () {
+ super(".", DOT);
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/EndELTokenDescription.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/EndELTokenDescription.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/EndELTokenDescription.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.parser.token;
+
+import org.jboss.tools.common.el.core.parser.Tokenizer;
+import org.jboss.tools.common.el.internal.core.parser.rule.BasicStates;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class EndELTokenDescription extends ConstantTokenDescription {
+ public static final int END_EL = 2;
+
+ public static EndELTokenDescription INSTANCE = new EndELTokenDescription();
+
+ public EndELTokenDescription () {
+ super("}", END_EL);
+ }
+
+ public boolean isStart(Tokenizer tokenizer, int offset) {
+ if(!super.isStart(tokenizer, offset)) {
+ return false;
+ }
+ if(tokenizer.getState() == BasicStates.STATE_ERROR) {
+ return true;
+ }
+ return ParamUtil.isParamHistoryEmpty(tokenizer.getContext());
+ }
+
+ public boolean read(Tokenizer tokenizer, int offset) {
+ boolean b = super.read(tokenizer, offset);
+ if(b) {
+ ParamUtil.cleanParamHistory(tokenizer.getContext());
+ }
+ return b;
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ExprEndTokenDescription.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ExprEndTokenDescription.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ExprEndTokenDescription.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.parser.token;
+
+import org.jboss.tools.common.el.core.parser.Tokenizer;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class ExprEndTokenDescription extends ConstantTokenDescription {
+ public static final int EXPR_END = 14;
+
+ public static ExprEndTokenDescription INSTANCE = new ExprEndTokenDescription();
+
+ public ExprEndTokenDescription () {
+ super(")", EXPR_END);
+ }
+
+ public boolean isStart(Tokenizer tokenizer, int offset) {
+ if(!super.isStart(tokenizer, offset)) {
+ return false;
+ }
+ return ParamUtil.isComplexExpressionContext(tokenizer.getContext());
+ }
+
+ public boolean read(Tokenizer tokenizer, int offset) {
+ boolean b = super.read(tokenizer, offset);
+ if(b) {
+ ParamUtil.closeCurrentParamContext(tokenizer.getContext());
+ }
+ return b;
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ExprStartTokenDescription.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ExprStartTokenDescription.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ExprStartTokenDescription.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.parser.token;
+
+import org.jboss.tools.common.el.core.parser.Tokenizer;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class ExprStartTokenDescription extends ConstantTokenDescription {
+ public static final int EXPR_START = 13;
+
+ public static ExprStartTokenDescription INSTANCE = new ExprStartTokenDescription();
+
+ public ExprStartTokenDescription () {
+ super("(", EXPR_START);
+ }
+
+ public boolean read(Tokenizer tokenizer, int offset) {
+ boolean b = super.read(tokenizer, offset);
+ if(b) {
+ ParamUtil.openComplexExpressionContext(tokenizer.getContext());
+ }
+ return b;
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/JavaNameTokenDescription.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/JavaNameTokenDescription.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/JavaNameTokenDescription.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.parser.token;
+
+import org.jboss.tools.common.el.core.parser.ITokenDescription;
+import org.jboss.tools.common.el.core.parser.Tokenizer;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class JavaNameTokenDescription implements ITokenDescription {
+ public static final int JAVA_NAME = 3;
+
+ public static JavaNameTokenDescription INSTANCE = new JavaNameTokenDescription();
+
+ public String getName() {
+ return "NAME";
+ }
+
+ public int getType() {
+ return JAVA_NAME;
+ }
+
+ public boolean isStart(Tokenizer tokenizer, int offset) {
+ char ch = tokenizer.lookUpChar(offset);
+ return Character.isJavaIdentifierStart(ch);
+ }
+
+ public boolean read(Tokenizer tokenizer, int offset) {
+ int i = offset;
+ char ch = '\0';
+ while(Character.isJavaIdentifierPart(ch = tokenizer.readNextChar())) {
+ i++;
+ }
+ if(ch != '\0') {
+ tokenizer.releaseChar();
+ }
+ tokenizer.addToken(getType(), offset, i);
+ return false;
+ }
+
+}
Added:
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
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/OperationTokenDescription.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.parser.token;
+
+import org.jboss.tools.common.el.core.parser.ITokenDescription;
+import org.jboss.tools.common.el.core.parser.Tokenizer;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class OperationTokenDescription implements ITokenDescription {
+ public static final int OPERATION = 12;
+
+ static String[] OPS = {
+ "&&", "||", "==", "!=",
"<=", ">=",
+ "+", "-", "*", "/", "&",
"%", "|", "?" , ":", "^",
"<", ">",
+ };
+ private static final String[] OPS_2 = {
+ "div", "and", "or", "not", "mod",
+ };
+
+ public static OperationTokenDescription INSTANCE = new OperationTokenDescription();
+
+ public String getName() {
+ return "Operator";
+ }
+
+ public int getType() {
+ return OPERATION;
+ }
+
+ public boolean isStart(Tokenizer tokenizer, int offset) {
+ int end = -1;
+ boolean canBeFollowedByOperand = true;
+ for (int i = 0; end < 0 && i < OPS.length; i++) {
+ if(tokenizer.startsWith(OPS[i])) {
+ end = offset + OPS[i].length();
+ }
+ }
+ for (int i = 0; end < 0 && i < OPS_2.length; i++) {
+ if(tokenizer.startsWith(OPS_2[i])) {
+ end = offset + OPS_2[i].length();
+ canBeFollowedByOperand = false;
+ }
+ }
+ if(end < 0) return false;
+ char ch = tokenizer.lookUpChar(end);
+ if(Character.isWhitespace(ch) || ch == '\0' || ch == '('
+ || (canBeFollowedByOperand && Character.isJavaIdentifierPart(ch))) {
+ return true;
+ }
+
+ return false;
+ }
+
+ public boolean read(Tokenizer tokenizer, int offset) {
+ if(!isStart(tokenizer, offset)) {
+ return false;
+ }
+ int end = -1;
+ for (int i = 0; end < 0 && i < OPS.length; i++) {
+ if(tokenizer.startsWith(OPS[i])) {
+ end = offset + OPS[i].length();
+ }
+ }
+ for (int i = 0; end < 0 && i < OPS_2.length; i++) {
+ if(tokenizer.startsWith(OPS_2[i])) {
+ end = offset + OPS_2[i].length();
+ }
+ }
+ tokenizer.addToken(OPERATION, offset, end);
+ return true;
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ParamEndTokenDescription.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ParamEndTokenDescription.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ParamEndTokenDescription.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.parser.token;
+
+import org.jboss.tools.common.el.core.parser.Tokenizer;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class ParamEndTokenDescription extends ConstantTokenDescription {
+ public static final int PARAM_END = 9;
+
+ public static ParamEndTokenDescription INSTANCE = new ParamEndTokenDescription();
+
+ public ParamEndTokenDescription () {
+ super(")", PARAM_END);
+ }
+
+ public boolean isStart(Tokenizer tokenizer, int offset) {
+ if(!super.isStart(tokenizer, offset)) {
+ return false;
+ }
+ return ParamUtil.isMethodParamContext(tokenizer.getContext());
+ }
+
+ public boolean read(Tokenizer tokenizer, int offset) {
+ boolean b = super.read(tokenizer, offset);
+ if(b) {
+ ParamUtil.closeCurrentParamContext(tokenizer.getContext());
+ }
+ return b;
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ParamStartTokenDescription.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ParamStartTokenDescription.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ParamStartTokenDescription.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.parser.token;
+
+import org.jboss.tools.common.el.core.parser.Tokenizer;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class ParamStartTokenDescription extends ConstantTokenDescription {
+ public static final int PARAM_START = 7;
+
+ public static ParamStartTokenDescription INSTANCE = new ParamStartTokenDescription();
+
+ public ParamStartTokenDescription () {
+ super("(", PARAM_START);
+ }
+
+ public boolean read(Tokenizer tokenizer, int offset) {
+ boolean b = super.read(tokenizer, offset);
+ if(b) {
+ ParamUtil.openMethodParamContext(tokenizer.getContext());
+ }
+ return b;
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ParamUtil.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ParamUtil.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/ParamUtil.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.parser.token;
+
+import java.util.ArrayList;
+import java.util.Properties;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class ParamUtil {
+ static String PARAM_HISTORY = "(_level";
+
+ static class ParamHistory extends ArrayList<String>{
+ private static final long serialVersionUID = 1L;
+ }
+
+ public static boolean isParamHistoryEmpty(Properties context) {
+ ParamHistory i = (ParamHistory)(context.get(PARAM_HISTORY));
+ return i == null || i.size() == 0;
+ }
+
+ public static void cleanParamHistory(Properties context) {
+ context.remove(PARAM_HISTORY);
+ }
+
+ public static void createParamHistory(Properties context) {
+ context.put(PARAM_HISTORY, new ParamHistory());
+ }
+
+ public static boolean isMethodParamContext(Properties context) {
+ ParamHistory i = (ParamHistory)(context.get(PARAM_HISTORY));
+ return i != null && i.size() > 0 &&
"params".equals(i.get(i.size() - 1));
+ }
+
+ public static boolean isComplexExpressionContext(Properties context) {
+ ParamHistory i = (ParamHistory)(context.get("(_level"));
+ return i != null && i.size() > 0 &&
"expr".equals(i.get(i.size() - 1));
+ }
+
+ public static void closeCurrentParamContext(Properties context) {
+ ParamHistory i = (ParamHistory)(context.get(PARAM_HISTORY));
+ if(i != null && i.size() > 0) {
+ i.remove(i.size() - 1);
+ }
+ }
+
+ public static void openMethodParamContext(Properties context) {
+ ParamHistory i = (ParamHistory)(context.get("(_level"));
+ i.add("params");
+ }
+
+ public static void openComplexExpressionContext(Properties context) {
+ ParamHistory i = (ParamHistory)(context.get("(_level"));
+ i.add("expr");
+ }
+
+}
Added:
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
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/PrimitiveValueTokenDescription.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.parser.token;
+
+import org.jboss.tools.common.el.core.parser.ITokenDescription;
+import org.jboss.tools.common.el.core.parser.Tokenizer;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class PrimitiveValueTokenDescription implements ITokenDescription {
+ public static final int PRIMITIVE_VALUE = 6;
+
+ public static PrimitiveValueTokenDescription INSTANCE = new
PrimitiveValueTokenDescription();
+
+ private static final String[] OPS_2 = {
+ "null", "true", "false",
+ };
+ public String getName() {
+ return "Primitive";
+ }
+
+ public int getType() {
+ return PRIMITIVE_VALUE;
+ }
+
+ public boolean isStart(Tokenizer tokenizer, int offset) {
+ if(isNumber(tokenizer, offset)) {
+ return true;
+ }
+ int end = -1;
+ boolean canBeFollowedByOperand = true;
+ for (int i = 0; end < 0 && i < OPS_2.length; i++) {
+ if(tokenizer.startsWith(OPS_2[i])) {
+ end = offset + OPS_2[i].length();
+ canBeFollowedByOperand = false;
+ }
+ }
+ if(end < 0) return false;
+ char ch = tokenizer.lookUpChar(end);
+ if(Character.isWhitespace(ch) || ch == '\0' ||
!Character.isJavaIdentifierPart(ch)
+ || (canBeFollowedByOperand && Character.isJavaIdentifierPart(ch))) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean isNumber(Tokenizer tokenizer, int offset) {
+ //TODO improve
+ char ch = tokenizer.lookUpChar(offset);
+ return Character.isDigit(ch);
+ }
+
+ public boolean read(Tokenizer tokenizer, int offset) {
+ if(isNumber(tokenizer, offset)) {
+ return readNumber(tokenizer, offset);
+ }
+ int end = -1;
+ for (int i = 0; end < 0 && i < OPS_2.length; i++) {
+ if(tokenizer.startsWith(OPS_2[i])) {
+ end = offset + OPS_2[i].length();
+ }
+ }
+ tokenizer.addToken(getType(), offset, end);
+ return true;
+ }
+
+ private boolean readNumber(Tokenizer tokenizer, int offset) {
+ int i = offset;
+ char ch = '\0';
+ boolean lastCharIsWrong = false;
+ int dotCount = 0;
+ while((ch = tokenizer.readNextChar()) != '\0') {
+ if(ch == '.') {
+ dotCount++;
+ if(dotCount > 1) {
+ lastCharIsWrong = true;
+ break;
+ }
+ } else if(!Character.isDigit(ch)) {
+ //TODO improve: 0x1, 1d, .f, etc
+ lastCharIsWrong = true;
+ break;
+ }
+ i++;
+
+ }
+ if(lastCharIsWrong) {
+ tokenizer.releaseChar();
+ }
+ tokenizer.addToken(getType(), offset, i);
+ return true;
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/StartELTokenDescription.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/StartELTokenDescription.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/StartELTokenDescription.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.parser.token;
+
+import org.jboss.tools.common.el.core.parser.Tokenizer;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class StartELTokenDescription extends ConstantTokenDescription {
+ public static final int START_EL = 1;
+
+ public static StartELTokenDescription INSTANCE = new StartELTokenDescription();
+
+ public StartELTokenDescription () {
+ super("#{", START_EL);
+ addContent("${");
+ }
+
+ public boolean read(Tokenizer tokenizer, int offset) {
+ boolean b = super.read(tokenizer, offset);
+ if(b) {
+ ParamUtil.createParamHistory(tokenizer.getContext());
+ }
+ return b;
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/StringTokenDescription.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/StringTokenDescription.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/StringTokenDescription.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.parser.token;
+
+import org.jboss.tools.common.el.core.parser.ITokenDescription;
+import org.jboss.tools.common.el.core.parser.Tokenizer;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class StringTokenDescription implements ITokenDescription {
+ public static final int STRING = 5;
+
+ public static StringTokenDescription INSTANCE = new StringTokenDescription();
+
+ public String getName() {
+ return "String";
+ }
+
+ public int getType() {
+ return STRING;
+ }
+
+ public boolean isStart(Tokenizer tokenizer, int offset) {
+ char ch = tokenizer.lookUpChar(offset);
+ return ch == '"' || ch == '\'';
+ }
+
+ public boolean read(Tokenizer tokenizer, int offset) {
+ char ch = tokenizer.readNextChar();
+ char chE = ch;
+ int i = offset;
+ while(ch != '\0') {
+ i++;
+ ch = tokenizer.readNextChar();
+ if(ch == '\\') {
+ i++;
+ ch = tokenizer.readNextChar();
+ } else if(ch == chE) {
+ i++;
+ break;
+ }
+ }
+ tokenizer.addToken(getType(), offset, i);
+ return i > offset;
+ }
+
+}
Added:
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
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/UnaryTokenDescription.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.parser.token;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class UnaryTokenDescription extends ConstantTokenDescription {
+ public static final int UNARY = 15;
+
+ public static UnaryTokenDescription INSTANCE = new UnaryTokenDescription();
+
+ public UnaryTokenDescription() {
+ super("!", UNARY);
+ addContent("--");
+ addContent("++");
+ addContent("+");
+ addContent("-");
+ }
+
+}
Added:
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/WhiteSpaceTokenDescription.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/WhiteSpaceTokenDescription.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.el.core/src/org/jboss/tools/common/el/internal/core/parser/token/WhiteSpaceTokenDescription.java 2008-09-23
15:37:49 UTC (rev 10413)
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.common.el.internal.core.parser.token;
+
+import org.jboss.tools.common.el.core.parser.ITokenDescription;
+import org.jboss.tools.common.el.core.parser.Tokenizer;
+
+/**
+ *
+ * @author V. Kabanovich
+ *
+ */
+public class WhiteSpaceTokenDescription implements ITokenDescription {
+ public static final int WHITESPACE = 0;
+
+ public static WhiteSpaceTokenDescription INSTANCE = new WhiteSpaceTokenDescription();
+
+ public String getName() {
+ return "Whitespace";
+ }
+
+ public int getType() {
+ return WHITESPACE;
+ }
+
+ public boolean isStart(Tokenizer tokenizer, int offset) {
+ char i = tokenizer.lookUpChar(offset);
+ return Character.isWhitespace(i);
+ }
+
+ public boolean read(Tokenizer tokenizer, int offset) {
+ int i = offset;
+ char ch = '\0';
+ while(Character.isWhitespace(ch = tokenizer.readNextChar())) {
+ i++;
+ }
+ if(ch != '\0') {
+ tokenizer.releaseChar();
+ }
+ tokenizer.addToken(getType(), offset, i);
+ return false;
+ }
+
+}