You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by di...@apache.org on 2007/10/22 01:23:48 UTC
svn commit: r586971 - in /commons/proper/jexl/branches/2.0: ./
src/java/org/apache/commons/jexl/ src/java/org/apache/commons/jexl/parser/
src/test/org/apache/commons/jexl/parser/
Author: dion
Date: Sun Oct 21 16:23:47 2007
New Revision: 586971
URL: http://svn.apache.org/viewvc?rev=586971&view=rev
Log:
2.0 starting
Added:
commons/proper/jexl/branches/2.0/
- copied from r576365, commons/proper/jexl/trunk/
Modified:
commons/proper/jexl/branches/2.0/maven.xml
commons/proper/jexl/branches/2.0/project.properties
commons/proper/jexl/branches/2.0/project.xml
commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/ExpressionFactory.java
commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/ExpressionImpl.java
commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/ScriptImpl.java
commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/parser/Parser.jjt
commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/parser/ParserTest.java
Modified: commons/proper/jexl/branches/2.0/maven.xml
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/maven.xml?rev=586971&r1=576365&r2=586971&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/maven.xml (original)
+++ commons/proper/jexl/branches/2.0/maven.xml Sun Oct 21 16:23:47 2007
@@ -107,5 +107,10 @@
file="${maven.dist.dir}/${maven.final.name}-src.tar.gz.md5" />
</postGoal>
+
+ <!-- javacc helpers -->
+ <preGoal name="java:compile">
+ <attainGoal name="javacc"/>
+ </preGoal>
</project>
Modified: commons/proper/jexl/branches/2.0/project.properties
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/project.properties?rev=586971&r1=576365&r2=586971&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/project.properties (original)
+++ commons/proper/jexl/branches/2.0/project.properties Sun Oct 21 16:23:47 2007
@@ -15,6 +15,8 @@
maven.repo.remote=http://repo1.maven.org/maven
+maven.announcement.lenient=true
+
# uncomment the next line to work in offline mode (no jar download & no linkcheck)
#maven.mode.online=
maven.changelog.factory=org.apache.maven.svnlib.SvnChangeLogFactory
@@ -71,6 +73,8 @@
rulesets/design.xml,\
rulesets/strings.xml
+maven.pmd.targetjdk=1.3
+
maven.checkstyle.properties=${basedir}/src/conf/checkstyle.xml
maven.checkstyle.excludes=org/apache/commons/jexl/parser/Parser*.java,\
org/apache/commons/jexl/parser/SimpleCharStream.java,\
@@ -81,3 +85,10 @@
# Source distro should unpack in a different directory (as against the binary distro)
maven.dist.src.assembly.dir=${maven.dist.assembly.dir}/src/${maven.final.name}-src
+#
+# javacc plugin properties
+#
+maven.javacc.jjtree.grammar=${basedir}/src/java/org/apache/commons/jexl/parser/Parser.jjt
+maven.javacc.javacc.grammar=${maven.gen.src}/org/apache/commons/jexl/parser/Parser.jj
+maven.javacc.javacc.package=org.apache.commons.jexl.parser
+maven.javacc.jjtree.package=org.apache.commons.jexl.parser
\ No newline at end of file
Modified: commons/proper/jexl/branches/2.0/project.xml
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/project.xml?rev=586971&r1=576365&r2=586971&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/project.xml (original)
+++ commons/proper/jexl/branches/2.0/project.xml Sun Oct 21 16:23:47 2007
@@ -22,7 +22,7 @@
<groupId>commons-jexl</groupId>
<artifactId>commons-jexl</artifactId>
<inceptionYear>2003</inceptionYear>
- <currentVersion>1.1.1-SNAPSHOT</currentVersion>
+ <currentVersion>SNAPSHOT</currentVersion>
<name>Commons JEXL</name>
<shortDescription>Commons JEXL Expression Language Engine</shortDescription>
<description>Jexl is an implementation of the JSTL Expression Language with extensions.</description>
@@ -140,13 +140,13 @@
</dependency>
<dependency>
<groupId>maven</groupId>
- <artifactId>maven-xdoc-plugin</artifactId>
- <version>1.9.2</version>
- <url>http://maven.apache.org/maven-1.x/reference/plugins/xdoc/</url>
+ <artifactId>maven-jcoverage-plugin</artifactId>
+ <version>1.0.9</version>
+ <url>http://maven.apache.org/maven-1.x/plugins/jcoverage/</url>
<type>plugin</type>
<properties>
<comment>
- <strong>Site Only</strong> - v1.9.2 (minimum)
+ <strong>Site Only</strong>
</comment>
</properties>
</dependency>
Modified: commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/ExpressionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/ExpressionFactory.java?rev=586971&r1=576365&r2=586971&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/ExpressionFactory.java (original)
+++ commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/ExpressionFactory.java Sun Oct 21 16:23:47 2007
@@ -148,20 +148,10 @@
// throw an exception.
SimpleNode node = (SimpleNode) tree.jjtGetChild(0);
- // TODO: Can we get rid of these checks?
- if (node instanceof ASTReferenceExpression
- || node instanceof ASTExpressionExpression
- || node instanceof ASTStatementExpression
- || node instanceof ASTIfStatement
- || node instanceof ASTWhileStatement
- || node instanceof ASTForeachStatement
- ) {
- return new ExpressionImpl(expression, node);
- }
- log.error("Invalid Expression, node of type: "
- + node.getClass().getName());
- throw new Exception("Invalid Expression: not a Reference, Expression, "
- + "Statement or If");
+ Interpreter interpreter = new Interpreter();
+ // TODO: remove this from the parser.
+ // interpreter.setUberspect(parser.getUberspect());
+ return new ExpressionImpl(expression, node, interpreter);
}
/**
Modified: commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/ExpressionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/ExpressionImpl.java?rev=586971&r1=576365&r2=586971&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/ExpressionImpl.java (original)
+++ commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/ExpressionImpl.java Sun Oct 21 16:23:47 2007
@@ -21,6 +21,7 @@
import java.util.List;
import org.apache.commons.jexl.parser.SimpleNode;
+import org.apache.commons.jexl.parser.ParserVisitor;
/**
* Instances of ExpressionImpl are created by the {@link ExpressionFactory},
@@ -32,6 +33,7 @@
*/
class ExpressionImpl implements Expression {
+ // TODO: move resolving to interpreter
/** resolvers called before expression evaluation. */
protected List preResolvers;
@@ -50,14 +52,20 @@
protected SimpleNode node;
/**
+ * The interpreter of the expression
+ */
+ protected Interpreter interpreter;
+
+ /**
* do not let this be generally instantiated with a 'new'.
*
* @param expr the expression.
* @param ref the parsed expression.
*/
- ExpressionImpl(String expr, SimpleNode ref) {
+ ExpressionImpl(String expr, SimpleNode ref, Interpreter interp) {
expression = expr;
node = ref;
+ interpreter = interp;
}
/**
@@ -77,7 +85,7 @@
}
}
- val = node.value(context);
+ val = interpreter.interpret(node, context);
/*
* if null, call post resolvers
@@ -128,7 +136,7 @@
}
/**
- * {@inheritDoc}
+ * {@inheritDoc}
*/
public void addPreResolver(JexlExprResolver resolver) {
if (preResolvers == null) {
Modified: commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/ScriptImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/ScriptImpl.java?rev=586971&r1=576365&r2=586971&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/ScriptImpl.java (original)
+++ commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/ScriptImpl.java Sun Oct 21 16:23:47 2007
@@ -29,7 +29,7 @@
private final String text;
/** syntax tree. */
private final ASTJexlScript parsedScript;
-
+
/**
* Create a new Script from the given string and parsed syntax.
* @param scriptText the text of the script.
@@ -44,8 +44,9 @@
* {@inheritDoc}
*/
public Object execute(JexlContext context) throws Exception {
- // TODO Auto-generated method stub
- return parsedScript.value(context);
+ Interpreter interpreter = new Interpreter();
+ return interpreter.interpret(parsedScript, context);
+ //return parsedScript.value(context);
}
/**
Modified: commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/parser/Parser.jjt
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/parser/Parser.jjt?rev=586971&r1=576365&r2=586971&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/parser/Parser.jjt (original)
+++ commons/proper/jexl/branches/2.0/src/java/org/apache/commons/jexl/parser/Parser.jjt Sun Oct 21 16:23:47 2007
@@ -29,6 +29,7 @@
MULTI=true;
STATIC=false;
VISITOR=true;
+ NODE_EXTENDS="JEXLNode";
NODE_USES_PARSER=true;
UNICODE_INPUT=true;
}
@@ -45,6 +46,8 @@
public class Parser
{
+
+ /** TODO: The uberspect belongs in the interpreter's implementation */
private Uberspect uberspect;
public void setUberspect(Uberspect uberspect)
@@ -133,9 +136,7 @@
}
{
t=<IDENTIFIER>
- {
- jjtThis.val = t.image;
- }
+ { jjtThis.image = t.image; }
}
@@ -334,9 +335,7 @@
{
(
t=<INTEGER_LITERAL>
- {
- jjtThis.val = Integer.valueOf(t.image);
- }
+ { jjtThis.image = t.image; }
)
}
@@ -347,9 +346,7 @@
{
(
t=<FLOAT_LITERAL>
- {
- jjtThis.val = Float.valueOf(t.image);
- }
+ { jjtThis.image = t.image; }
)
}
@@ -360,9 +357,7 @@
{
(
t=<STRING_LITERAL>
- {
- jjtThis.literal = t.image.substring(1,t.image.length()-1);
- }
+ { jjtThis.image = t.image; }
)
}
@@ -447,7 +442,7 @@
void SizeMethod() : {}
{
- "size" "(" ")"
+ "size" "(" ")"
}
void Reference() : {}
Modified: commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/parser/ParserTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/parser/ParserTest.java?rev=586971&r1=576365&r2=586971&view=diff
==============================================================================
--- commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/parser/ParserTest.java (original)
+++ commons/proper/jexl/branches/2.0/src/test/org/apache/commons/jexl/parser/ParserTest.java Sun Oct 21 16:23:47 2007
@@ -53,7 +53,8 @@
JexlContext jc = JexlHelper.createContext();
- sn.interpret(jc);
+ // TODO: Remove
+ //sn.interpret(jc);
}
public void testParse2()
@@ -64,9 +65,11 @@
JexlContext jc = JexlHelper.createContext();
SimpleNode sn = parser.parse(new StringReader("foo = \"bar\";"));
- sn.interpret(jc);
+ // TODO: Remove
+ //sn.interpret(jc);
sn = parser.parse(new StringReader("foo = 'bar';"));
- sn.interpret(jc);
+ // TODO: Remove
+ //sn.interpret(jc);
}
public static void main(String[] args)
Re: [jexl] 2.0?
Posted by Dion Gillard <di...@trongus.com>.
The main drivers we talked about ages ago (can't find it now) were:
- Decoupling the syntax tree from the interpretation, so that
alternate interpreters/compilers can be easily plugged in.
- Allow the grammar to change without the need to keep changing the
generated code.
- Structure the interpreter/expression evaluator so that alternate
null handling can be easily provided, separate from the context
- Remove some of the unnecessary throws Exception code.
- Make javacc generation part of the build process.
etc....
Got any ideas?
So far, I've started to implement a simple interpreter as a proof of concept.
It passes some tests :-)
On 10/22/07, peter royal <pr...@apache.org> wrote:
> On Oct 21, 2007, at 4:23 PM, dion@apache.org wrote:
> > 2.0 starting
>
> ooh!
>
> what all do you want to achieve?
>
> -pete
>
>
> --
> proyal@apache.org - http://fotap.org/~osi
>
>
>
>
>
--
dIon Gillard
Rule #131 of Acquisition: Information is Profit.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
[jexl] 2.0?
Posted by peter royal <pr...@apache.org>.
On Oct 21, 2007, at 4:23 PM, dion@apache.org wrote:
> 2.0 starting
ooh!
what all do you want to achieve?
-pete
--
proyal@apache.org - http://fotap.org/~osi