You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by hi...@apache.org on 2012/06/20 16:03:14 UTC

svn commit: r1352110 - in /ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl: ./ expr/ expr/func/ xtext/

Author: hibou
Date: Wed Jun 20 14:03:13 2012
New Revision: 1352110

URL: http://svn.apache.org/viewvc?rev=1352110&view=rev
Log:
Introduction of an expression language to do basic computing on string and numbers. For now, it is only used for property and reference assignment

Added:
    ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AssignPropertyTask.java   (with props)
    ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AssignReferenceTask.java   (with props)
    ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/
    ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/AddAntExpression.java   (with props)
    ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/AntExpression.java   (with props)
    ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/CommutativeAntExpression.java   (with props)
    ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/CommutativeArithmeticAntExpression.java   (with props)
    ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/FuncAntExpression.java   (with props)
    ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/MultiAntExpression.java   (with props)
    ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/MultiplicationAntExpression.java   (with props)
    ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PrimaryAntExpression.java   (with props)
    ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PropExpression.java   (with props)
    ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/
    ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/AntFunction.java   (with props)
    ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/EvalAntFunction.java   (with props)
    ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/FunctionRegistry.java   (with props)
    ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/IndexOfAntFunction.java   (with props)
    ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseDoubleAntFunction.java   (with props)
    ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseFloatAntFunction.java   (with props)
    ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseIntAntFunction.java   (with props)
    ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseLongAntFunction.java   (with props)
    ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/SubStringAntFunction.java   (with props)
Removed:
    ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/RefTask.java
Modified:
    ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AbstractAntDslProjectHelper.java
    ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AntDSL.g
    ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/AntDSL.xtext
    ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/AntDslXTextProjectHelper.java

Modified: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AbstractAntDslProjectHelper.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AbstractAntDslProjectHelper.java?rev=1352110&r1=1352109&r2=1352110&view=diff
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AbstractAntDslProjectHelper.java (original)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AbstractAntDslProjectHelper.java Wed Jun 20 14:03:13 2012
@@ -32,6 +32,7 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Vector;
 
+import org.apache.ant.antdsl.expr.func.FunctionRegistry;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.ExtensionPoint;
 import org.apache.tools.ant.MagicNames;
@@ -53,6 +54,8 @@ public abstract class AbstractAntDslProj
 
     private static final String REFID_CONTEXT = "antdsl.parsingcontext";
 
+    public static final String REFID_FUNCTION_REGISTRY = "antdsl.function.registry";
+
     public String getDefaultBuildFile() {
         return "build.ant";
     }
@@ -73,6 +76,12 @@ public abstract class AbstractAntDslProj
             project.addReference(REFID_CONTEXT, context);
         }
 
+        FunctionRegistry functionRegistry = (FunctionRegistry) project.getReference(REFID_FUNCTION_REGISTRY);
+        if (functionRegistry == null) {
+            functionRegistry = new FunctionRegistry();
+            project.addReference(REFID_FUNCTION_REGISTRY, functionRegistry);
+        }
+
         if (getImportStack().size() > 1) {
             context.setIgnoreProjectTag(true);
             Target currentTarget = context.getCurrentTarget();
@@ -450,8 +459,7 @@ public abstract class AbstractAntDslProj
         ProjectComponentContainer container = new ProjectComponentContainer();
         element.configure(container);
         if (!(c.isAssignableFrom(container.component.getClass()))) {
-            throw new BuildException("Incorrect element: expecting a " + c.getSimpleName() + " but was : "
-                    + container.component.getClass().getName());
+            throw new BuildException("Incorrect element: expecting a " + c.getSimpleName() + " but was : " + container.component.getClass().getName());
         }
         @SuppressWarnings("unchecked")
         T expected = (T) container.component;

Modified: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AntDSL.g
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AntDSL.g?rev=1352110&r1=1352109&r2=1352110&view=diff
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AntDSL.g (original)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AntDSL.g Wed Jun 20 14:03:13 2012
@@ -29,6 +29,7 @@ import org.apache.ant.antdsl.AbstractAnt
 import org.apache.ant.antdsl.IfTask.ConditionnalSequential;
 import org.apache.ant.antdsl.Target;
 import org.apache.ant.antdsl.ExtensionPoint;
+import org.apache.ant.antdsl.expr.*;
 import org.apache.tools.ant.*;
 import org.apache.tools.ant.taskdefs.*;
 import org.apache.tools.ant.taskdefs.MacroDef.Attribute;
@@ -137,15 +138,15 @@ innerElement returns [InnerElement ie = 
 assignment returns [Task assign]:
     p=propertyAssignment { assign = p; } | r=refAssignment { assign = r; } ;
 
-propertyAssignment returns [Property p = new Property()]:
+propertyAssignment returns [AssignPropertyTask p = new AssignPropertyTask()]:
     'prop'
     { projectHelper.mapCommonTask(project, context, p); }
-    NAME { p.setName($NAME.text); } '=' STRING { p.setValue(projectHelper.readString($STRING.text)); } ;
+    NAME { p.setName($NAME.text); } '=' e=expr { p.setValue(e); } ;
 
-refAssignment returns [RefTask r = new RefTask()]:
+refAssignment returns [AssignReferenceTask r = new AssignReferenceTask()]:
     'ref'
     { projectHelper.mapCommonTask(project, context, r); }
-    NAME { r.setName($NAME.text); } '=' STRING { r.setValue(projectHelper.readString($STRING.text)); } ;
+    NAME { r.setName($NAME.text); } '=' e=expr { r.setValue(e); } ;
 
 branch returns [IfTask if_ = new IfTask()]:
     { projectHelper.mapCommonTask(project, context, if_); }
@@ -214,6 +215,56 @@ boolNotExpr returns [Condition c]:
       c = not;
     };
 
+expr returns [AntExpression e]:
+    me=multExpr { e = me; } ;
+
+multExpr returns [AntExpression e]:
+    ae=addExpr { e = ae; }
+    ( '*' right=addExpr
+      {  MultiplicationAntExpression me = new MultiplicationAntExpression();
+         me.setProject(project);
+         me.add(e);
+         me.add(right);
+         e = me;
+      }
+    )*;
+
+addExpr returns [AntExpression e]:
+    pe=primaryExpr { e = pe; }
+    ( '+' right=primaryExpr
+      { AddAntExpression ae = new AddAntExpression();
+        ae.setProject(project);
+        ae.add(e);
+        ae.add(right);
+        e = ae;
+      }
+    )*;
+
+primaryExpr returns [AntExpression e]:
+      fe=funcExpr { e = fe; }
+    | ne=numExpr { e = ne; }
+    | se=stringExpr { e = se; }
+    | pe=propExpr { e = pe; };
+
+funcExpr returns [FuncAntExpression fe = new FuncAntExpression()]:
+    { fe.setProject(project); }
+    NAME { fe.setName($NAME.text); }
+    '(' arg=expr { fe.addArgument(arg); }
+        (',' arg=expr  { fe.addArgument(arg); } )*
+    ')';
+
+numExpr returns [PrimaryAntExpression pe = new PrimaryAntExpression()]:
+    { pe.setProject(project); }
+    INT { pe.setValue(Integer.parseInt($INT.text)); };
+
+stringExpr returns [PrimaryAntExpression pe = new PrimaryAntExpression()]:
+    { pe.setProject(project); }
+    STRING { pe.setValue(projectHelper.readString($STRING.text)); };
+
+propExpr returns [PropExpression pe = new PropExpression()]:
+    { pe.setProject(project); }
+    PROPERTY { pe.setProperty($PROPERTY.text.substring(1)); };
+
 macrodef returns [MacroDef macroDef = new MacroDef()]:
     ( DOC { macroDef.setDescription(projectHelper.readDoc($DOC.text)); } )?
     'macrodef' NAME { macroDef.setName($NAME.text); }

Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AssignPropertyTask.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AssignPropertyTask.java?rev=1352110&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AssignPropertyTask.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AssignPropertyTask.java Wed Jun 20 14:03:13 2012
@@ -0,0 +1,43 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ant.antdsl;
+
+import org.apache.ant.antdsl.expr.AntExpression;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.PropertyHelper;
+import org.apache.tools.ant.Task;
+
+public class AssignPropertyTask extends Task {
+
+    private String name;
+
+    private AntExpression value;
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setValue(AntExpression value) {
+        this.value = value;
+    }
+
+    @Override
+    public void execute() throws BuildException {
+        PropertyHelper.setProperty(getProject(), name, value.eval());
+    }
+}

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AssignPropertyTask.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AssignPropertyTask.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AssignPropertyTask.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AssignReferenceTask.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AssignReferenceTask.java?rev=1352110&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AssignReferenceTask.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AssignReferenceTask.java Wed Jun 20 14:03:13 2012
@@ -0,0 +1,42 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ant.antdsl;
+
+import org.apache.ant.antdsl.expr.AntExpression;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+public class AssignReferenceTask extends Task {
+
+    private String name;
+
+    private AntExpression value;
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setValue(AntExpression value) {
+        this.value = value;
+    }
+    
+    @Override
+    public void execute() throws BuildException {
+        getProject().addReference(name, value.eval());
+    }
+}

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AssignReferenceTask.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AssignReferenceTask.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/AssignReferenceTask.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/AddAntExpression.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/AddAntExpression.java?rev=1352110&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/AddAntExpression.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/AddAntExpression.java Wed Jun 20 14:03:13 2012
@@ -0,0 +1,104 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ant.antdsl.expr;
+
+public class AddAntExpression extends CommutativeAntExpression {
+
+    public AddAntExpression() {
+        super("add");
+    }
+
+    // Note : + is not commutative for String
+    // but since we don't support mixing Strings with numbers, it still works
+
+    @Override
+    protected Object eval(String v1, String v2) {
+        return v1 + v2;
+    }
+
+    @Override
+    protected Object eval(String v1, int v2) {
+        throw buildIncompatibleTypeException("String", "int");
+    }
+
+    @Override
+    protected Object eval(String v1, long v2) {
+        throw buildIncompatibleTypeException("String", "long");
+    }
+
+    @Override
+    protected Object eval(String v1, float v2) {
+        throw buildIncompatibleTypeException("String", "float");
+    }
+
+    @Override
+    protected Object eval(String v1, double v2) {
+        throw buildIncompatibleTypeException("String", "double");
+    }
+
+    @Override
+    protected Object eval(int v1, int v2) {
+        return v1 + v2;
+    }
+
+    @Override
+    protected Object eval(int v1, long v2) {
+        return v1 + v2;
+    }
+
+    @Override
+    protected Object eval(int v1, float v2) {
+        return v1 + v2;
+    }
+
+    @Override
+    protected Object eval(int v1, double v2) {
+        return v1 + v2;
+    }
+
+    @Override
+    protected Object eval(long v1, long v2) {
+        return v1 + v2;
+    }
+
+    @Override
+    protected Object eval(long v1, float v2) {
+        return v1 + v2;
+    }
+
+    @Override
+    protected Object eval(long v1, double v2) {
+        return v1 + v2;
+    }
+
+    @Override
+    protected Object eval(float v1, float v2) {
+        return v1 + v2;
+    }
+
+    @Override
+    protected Object eval(float v1, double v2) {
+        return v1 + v2;
+    }
+
+    @Override
+    protected Object eval(double v1, double v2) {
+        return v1 + v2;
+    }
+
+}

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/AddAntExpression.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/AddAntExpression.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/AddAntExpression.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/AntExpression.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/AntExpression.java?rev=1352110&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/AntExpression.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/AntExpression.java Wed Jun 20 14:03:13 2012
@@ -0,0 +1,36 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ant.antdsl.expr;
+
+import org.apache.tools.ant.Project;
+
+public abstract class AntExpression {
+
+    private Project project;
+
+    public void setProject(Project project) {
+        this.project = project;
+    }
+
+    public Project getProject() {
+        return project;
+    }
+
+    public abstract Object eval();
+
+}

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/AntExpression.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/AntExpression.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/AntExpression.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/CommutativeAntExpression.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/CommutativeAntExpression.java?rev=1352110&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/CommutativeAntExpression.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/CommutativeAntExpression.java Wed Jun 20 14:03:13 2012
@@ -0,0 +1,66 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ant.antdsl.expr;
+
+public abstract class CommutativeAntExpression extends MultiAntExpression {
+
+    public CommutativeAntExpression(String name) {
+        super(name);
+    }
+
+    protected final Object eval(int v1, String v2) {
+        return eval(v2, v1);
+    }
+
+    protected final Object eval(long v1, String v2) {
+        return eval(v2, v1);
+    }
+
+    protected final Object eval(long v1, int v2) {
+        return eval(v2, v1);
+    }
+
+    protected final Object eval(float v1, String v2) {
+        return eval(v2, v1);
+    }
+
+    protected final Object eval(float v1, int v2) {
+        return eval(v2, v1);
+    }
+
+    protected final Object eval(float v1, long v2) {
+        return eval(v2, v1);
+    }
+
+    protected final Object eval(double v1, String v2) {
+        return eval(v2, v1);
+    }
+
+    protected final Object eval(double v1, int v2) {
+        return eval(v2, v1);
+    }
+
+    protected final Object eval(double v1, long v2) {
+        return eval(v2, v1);
+    }
+
+    protected final Object eval(double v1, float v2) {
+        return eval(v2, v1);
+    }
+
+}

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/CommutativeAntExpression.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/CommutativeAntExpression.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/CommutativeAntExpression.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/CommutativeArithmeticAntExpression.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/CommutativeArithmeticAntExpression.java?rev=1352110&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/CommutativeArithmeticAntExpression.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/CommutativeArithmeticAntExpression.java Wed Jun 20 14:03:13 2012
@@ -0,0 +1,34 @@
+package org.apache.ant.antdsl.expr;
+
+public abstract class CommutativeArithmeticAntExpression extends CommutativeAntExpression {
+
+    public CommutativeArithmeticAntExpression(String name) {
+        super(name);
+    }
+
+    @Override
+    protected Object eval(String v1, String v2) {
+        throw buildIncompatibleTypeException("String", "String");
+    }
+
+    @Override
+    protected Object eval(String v1, int v2) {
+        throw buildIncompatibleTypeException("String", "int");
+    }
+
+    @Override
+    protected Object eval(String v1, long v2) {
+        throw buildIncompatibleTypeException("String", "long");
+    }
+
+    @Override
+    protected Object eval(String v1, float v2) {
+        throw buildIncompatibleTypeException("String", "float");
+    }
+
+    @Override
+    protected Object eval(String v1, double v2) {
+        throw buildIncompatibleTypeException("String", "double");
+    }
+
+}

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/CommutativeArithmeticAntExpression.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/CommutativeArithmeticAntExpression.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/CommutativeArithmeticAntExpression.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/FuncAntExpression.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/FuncAntExpression.java?rev=1352110&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/FuncAntExpression.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/FuncAntExpression.java Wed Jun 20 14:03:13 2012
@@ -0,0 +1,55 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ant.antdsl.expr;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.ant.antdsl.AbstractAntDslProjectHelper;
+import org.apache.ant.antdsl.expr.func.AntFunction;
+import org.apache.ant.antdsl.expr.func.FunctionRegistry;
+import org.apache.tools.ant.BuildException;
+
+public class FuncAntExpression extends AntExpression {
+
+    private String name;
+
+    private List<AntExpression> arguments = new ArrayList<AntExpression>();
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void addArgument(AntExpression expr) {
+        arguments.add(expr);
+    }
+
+    @Override
+    public Object eval() {
+        FunctionRegistry functionRegistry = (FunctionRegistry) getProject().getReference(AbstractAntDslProjectHelper.REFID_FUNCTION_REGISTRY);
+        AntFunction func = functionRegistry.getFunction(name);
+        if (func == null) {
+            throw new BuildException("Unknown function '" + name + "'");
+        }
+        List<Object> argValues = new ArrayList<Object>(arguments.size());
+        for (AntExpression arg : arguments) {
+            argValues.add(arg.eval());
+        }
+        return func.eval(getProject(), argValues);
+    }
+}

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/FuncAntExpression.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/FuncAntExpression.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/FuncAntExpression.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/MultiAntExpression.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/MultiAntExpression.java?rev=1352110&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/MultiAntExpression.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/MultiAntExpression.java Wed Jun 20 14:03:13 2012
@@ -0,0 +1,214 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ant.antdsl.expr;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tools.ant.BuildException;
+
+public abstract class MultiAntExpression extends AntExpression {
+
+    private List<AntExpression> children = new ArrayList<AntExpression>();
+
+    private final String name;
+
+    public MultiAntExpression(String name) {
+        this.name = name;
+    }
+
+    public void add(AntExpression expr) {
+        children.add(expr);
+    }
+
+    public List<AntExpression> getChildren() {
+        return children;
+    }
+
+    @Override
+    public Object eval() {
+        Object value = null;
+        for (AntExpression child : getChildren()) {
+            Object childValue = child.eval();
+            if (value == null) {
+                value = childValue;
+            } else if (value instanceof Integer) {
+                value = eval((Integer) value, childValue);
+            } else if (value instanceof Long) {
+                value = eval((Long) value, childValue);
+            } else if (value instanceof Float) {
+                value = eval((Float) value, childValue);
+            } else if (value instanceof Double) {
+                value = eval((Double) value, childValue);
+            } else {
+                value = eval(value.toString(), childValue);
+            }
+        }
+        return value;
+    }
+
+    protected BuildException buildIncompatibleTypeException(String t1, String t2) {
+        return new BuildException("incomptable type for operation " + name + ": '" + t1 + "' and '" + t2 + "'");
+    }
+
+    private Object eval(String v1, Object v2) {
+        if (v2 instanceof String) {
+            return eval(v1, ((String) v2));
+        }
+        if (v2 instanceof Integer) {
+            return eval(v1, ((Integer) v2).intValue());
+        }
+        if (v2 instanceof Long) {
+            return eval(v1, ((Long) v2).longValue());
+        }
+        if (v2 instanceof Float) {
+            return eval(v1, ((Float) v2).floatValue());
+        }
+        if (v2 instanceof Double) {
+            return eval(v1, ((Double) v2).doubleValue());
+        }
+        return eval(v1, v2.toString());
+    }
+
+    abstract protected Object eval(String v1, String v2);
+
+    abstract protected Object eval(String v1, int v2);
+
+    abstract protected Object eval(String v1, long v2);
+
+    abstract protected Object eval(String v1, float v2);
+
+    abstract protected Object eval(String v1, double v2);
+
+    private Object eval(Integer v1, Object v2) {
+        if (v2 instanceof String) {
+            return eval(v1.intValue(), ((String) v2));
+        }
+        if (v2 instanceof Integer) {
+            return eval(v1.intValue(), ((Integer) v2).intValue());
+        }
+        if (v2 instanceof Long) {
+            return eval(v1.intValue(), ((Long) v2).longValue());
+        }
+        if (v2 instanceof Float) {
+            return eval(v1.intValue(), ((Float) v2).floatValue());
+        }
+        if (v2 instanceof Double) {
+            return eval(v1.intValue(), ((Double) v2).doubleValue());
+        }
+        return eval(v1.intValue(), v2.toString());
+    }
+
+    abstract protected Object eval(int v1, String v2);
+
+    abstract protected Object eval(int v1, int v2);
+
+    abstract protected Object eval(int v1, long v2);
+
+    abstract protected Object eval(int v1, float v2);
+
+    abstract protected Object eval(int v1, double v2);
+
+    private Object eval(Long v1, Object v2) {
+        if (v2 instanceof String) {
+            return eval(v1.longValue(), ((String) v2));
+        }
+        if (v2 instanceof Integer) {
+            return eval(v1.longValue(), ((Integer) v2).intValue());
+        }
+        if (v2 instanceof Long) {
+            return eval(v1.longValue(), ((Long) v2).longValue());
+        }
+        if (v2 instanceof Float) {
+            return eval(v1.longValue(), ((Float) v2).floatValue());
+        }
+        if (v2 instanceof Double) {
+            return eval(v1.longValue(), ((Double) v2).doubleValue());
+        }
+        return eval(v1.longValue(), v2.toString());
+    }
+
+    abstract protected Object eval(long v1, String v2);
+
+    abstract protected Object eval(long v1, int v2);
+
+    abstract protected Object eval(long v1, long v2);
+
+    abstract protected Object eval(long v1, float v2);
+
+    abstract protected Object eval(long v1, double v2);
+
+    private Object eval(Float v1, Object v2) {
+        if (v2 instanceof String) {
+            return eval(v1.floatValue(), ((String) v2));
+        }
+        if (v2 instanceof Integer) {
+            return eval(v1.floatValue(), ((Integer) v2).intValue());
+        }
+        if (v2 instanceof Long) {
+            return eval(v1.floatValue(), ((Long) v2).longValue());
+        }
+        if (v2 instanceof Float) {
+            return eval(v1.floatValue(), ((Float) v2).floatValue());
+        }
+        if (v2 instanceof Double) {
+            return eval(v1.floatValue(), ((Double) v2).doubleValue());
+        }
+        return eval(v1.floatValue(), v2.toString());
+    }
+
+    abstract protected Object eval(float v1, String v2);
+
+    abstract protected Object eval(float v1, int v2);
+
+    abstract protected Object eval(float v1, long v2);
+
+    abstract protected Object eval(float v1, float v2);
+
+    abstract protected Object eval(float v1, double v2);
+
+    private Object eval(Double v1, Object v2) {
+        if (v2 instanceof String) {
+            return eval(v1.doubleValue(), ((String) v2));
+        }
+        if (v2 instanceof Integer) {
+            return eval(v1.doubleValue(), ((Integer) v2).intValue());
+        }
+        if (v2 instanceof Long) {
+            return eval(v1.doubleValue(), ((Long) v2).longValue());
+        }
+        if (v2 instanceof Float) {
+            return eval(v1.doubleValue(), ((Float) v2).floatValue());
+        }
+        if (v2 instanceof Double) {
+            return eval(v1.doubleValue(), ((Double) v2).doubleValue());
+        }
+        return eval(v1.doubleValue(), v2.toString());
+    }
+
+    abstract protected Object eval(double v1, String v2);
+
+    abstract protected Object eval(double v1, int v2);
+
+    abstract protected Object eval(double v1, long v2);
+
+    abstract protected Object eval(double v1, float v2);
+
+    abstract protected Object eval(double v1, double v2);
+
+}

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/MultiAntExpression.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/MultiAntExpression.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/MultiAntExpression.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/MultiplicationAntExpression.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/MultiplicationAntExpression.java?rev=1352110&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/MultiplicationAntExpression.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/MultiplicationAntExpression.java Wed Jun 20 14:03:13 2012
@@ -0,0 +1,75 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ant.antdsl.expr;
+
+public class MultiplicationAntExpression extends CommutativeArithmeticAntExpression {
+
+    public MultiplicationAntExpression() {
+        super("multiplication");
+    }
+
+    @Override
+    protected Object eval(int v1, int v2) {
+        return v1 * v2;
+    }
+
+    @Override
+    protected Object eval(int v1, long v2) {
+        return v1 * v2;
+    }
+
+    @Override
+    protected Object eval(int v1, float v2) {
+        return v1 * v2;
+    }
+
+    @Override
+    protected Object eval(int v1, double v2) {
+        return v1 * v2;
+    }
+
+    @Override
+    protected Object eval(long v1, long v2) {
+        return v1 * v2;
+    }
+
+    @Override
+    protected Object eval(long v1, float v2) {
+        return v1 * v2;
+    }
+
+    @Override
+    protected Object eval(long v1, double v2) {
+        return v1 * v2;
+    }
+
+    @Override
+    protected Object eval(float v1, float v2) {
+        return v1 * v2;
+    }
+
+    @Override
+    protected Object eval(float v1, double v2) {
+        return v1 * v2;
+    }
+
+    @Override
+    protected Object eval(double v1, double v2) {
+        return v1 * v2;
+    }
+}

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/MultiplicationAntExpression.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/MultiplicationAntExpression.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/MultiplicationAntExpression.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PrimaryAntExpression.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PrimaryAntExpression.java?rev=1352110&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PrimaryAntExpression.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PrimaryAntExpression.java Wed Jun 20 14:03:13 2012
@@ -0,0 +1,33 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ant.antdsl.expr;
+
+public class PrimaryAntExpression extends AntExpression {
+
+    private Object value;
+
+    public void setValue(Object value) {
+        this.value = value;
+    }
+
+    @Override
+    public Object eval() {
+        return value;
+    }
+
+}

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PrimaryAntExpression.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PrimaryAntExpression.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PrimaryAntExpression.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PropExpression.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PropExpression.java?rev=1352110&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PropExpression.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PropExpression.java Wed Jun 20 14:03:13 2012
@@ -0,0 +1,35 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ant.antdsl.expr;
+
+import org.apache.tools.ant.PropertyHelper;
+
+public class PropExpression extends AntExpression {
+
+    private String property;
+
+    public void setProperty(String property) {
+        this.property = property;
+    }
+
+    @Override
+    public Object eval() {
+        return PropertyHelper.getProperty(getProject(), property);
+    }
+
+}

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PropExpression.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PropExpression.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PropExpression.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/AntFunction.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/AntFunction.java?rev=1352110&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/AntFunction.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/AntFunction.java Wed Jun 20 14:03:13 2012
@@ -0,0 +1,88 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ant.antdsl.expr.func;
+
+import java.util.List;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+
+public abstract class AntFunction {
+
+    private final String name;
+
+    public AntFunction(String name) {
+        this.name = name;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    protected void checkArgumentSize(List<Object> arguments, Integer lower, Integer upper) {
+        if (upper == null) {
+            if (arguments.size() != lower.intValue()) {
+                throw new BuildException("The function '" + getName() + "' is expecting at least " + lower.intValue() + " argument"
+                        + (lower.intValue() > 1 ? "s" : "") + " but " + arguments.size() + " were found");
+            }
+            return;
+        }
+        if (lower == null || lower.intValue() == 0) {
+            if (arguments.size() > upper.intValue()) {
+                throw new BuildException("The function '" + getName() + "' is expecting up to " + upper.intValue() + " argument"
+                        + (upper.intValue() > 1 ? "s" : "") + " but " + arguments.size() + " were found");
+            }
+            return;
+        }
+        if (lower.intValue() == upper.intValue()) {
+            if (arguments.size() != lower.intValue()) {
+                throw new BuildException("The function '" + getName() + "' is expecting " + lower.intValue() + " argument"
+                        + (lower.intValue() > 1 ? "s" : "") + " but " + arguments.size() + " were found");
+            }
+            return;
+        }
+        if (arguments.size() < lower.intValue() || arguments.size() > upper.intValue()) {
+            throw new BuildException("The function '" + getName() + "' is expecting from " + lower.intValue() + " to " + upper.intValue()
+                    + " arguments but " + arguments.size() + " were found");
+        }
+    }
+
+    abstract public Object eval(Project project, List<Object> arguments);
+
+    protected int asInt(Object arg, int n) {
+        if (arg instanceof Integer) {
+            return ((Integer) arg).intValue();
+        }
+        if (arg instanceof Long) {
+            return ((Long) arg).intValue();
+        }
+        if (arg instanceof Float) {
+            return ((Float) arg).intValue();
+        }
+        if (arg instanceof Double) {
+            return ((Double) arg).intValue();
+        }
+        throw buildWrongTypeException("int", arg, n);
+    }
+
+    protected BuildException buildWrongTypeException(String type, Object arg, int n) {
+        return new BuildException("The function '" + name + "' is expecting a " + type + " as argument #" + n + " but " + arg.getClass().getName()
+                + " was found");
+    }
+
+}

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/AntFunction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/AntFunction.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/AntFunction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/EvalAntFunction.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/EvalAntFunction.java?rev=1352110&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/EvalAntFunction.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/EvalAntFunction.java Wed Jun 20 14:03:13 2012
@@ -0,0 +1,37 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ant.antdsl.expr.func;
+
+import java.util.List;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.PropertyHelper;
+
+public class EvalAntFunction extends AntFunction {
+
+    public EvalAntFunction() {
+        super("eval");
+    }
+
+    @Override
+    public Object eval(Project project, List<Object> arguments) {
+        checkArgumentSize(arguments, 1, 1);
+        return PropertyHelper.getPropertyHelper(project).parseProperties(arguments.get(0).toString());
+    }
+
+}

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/EvalAntFunction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/EvalAntFunction.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/EvalAntFunction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/FunctionRegistry.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/FunctionRegistry.java?rev=1352110&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/FunctionRegistry.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/FunctionRegistry.java Wed Jun 20 14:03:13 2012
@@ -0,0 +1,60 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ant.antdsl.expr.func;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tools.ant.BuildException;
+
+// TODO
+// we may want to make this registry more integrated with ant class loading, like typedef
+public class FunctionRegistry {
+
+    private Map<String, AntFunction> registry = new HashMap<String, AntFunction>();
+
+    public FunctionRegistry() {
+        // for now, let's hard code the available functions
+        register(new EvalAntFunction());
+        register(new SubStringAntFunction());
+        register(new IndexOfAntFunction());
+        register(new ParseIntAntFunction());
+        register(new ParseLongAntFunction());
+        register(new ParseFloatAntFunction());
+        register(new ParseDoubleAntFunction());
+    }
+
+    private void register(AntFunction func) {
+        registry.put(func.getName(), func);
+    }
+
+    public void register(String name, Class< ? extends AntFunction> c) {
+        AntFunction func;
+        try {
+            func = c.newInstance();
+        } catch (Exception e) {
+            throw new BuildException("Unable to register the function '" + name + "' with '" + c.getName() + "': " + e.getMessage() + "("
+                    + e.getClass().getName() + ")", e);
+        }
+        registry.put(name, func);
+    }
+
+    public AntFunction getFunction(String name) {
+        return registry.get(name);
+    }
+}

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/FunctionRegistry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/FunctionRegistry.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/FunctionRegistry.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/IndexOfAntFunction.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/IndexOfAntFunction.java?rev=1352110&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/IndexOfAntFunction.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/IndexOfAntFunction.java Wed Jun 20 14:03:13 2012
@@ -0,0 +1,41 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ant.antdsl.expr.func;
+
+import java.util.List;
+
+import org.apache.tools.ant.Project;
+
+public class IndexOfAntFunction extends AntFunction {
+
+    public IndexOfAntFunction() {
+        super("indexof");
+    }
+
+    @Override
+    public Object eval(Project project, List<Object> arguments) {
+        checkArgumentSize(arguments, 2, 3);
+        String s = arguments.get(0).toString();
+        String s2 = arguments.get(1).toString();
+        if (arguments.size() == 2) {
+            return s.indexOf(s2);
+        }
+        int fromIndex = asInt(arguments.get(2), 3);
+        return s.indexOf(s, fromIndex);
+    }
+}

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/IndexOfAntFunction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/IndexOfAntFunction.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/IndexOfAntFunction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseDoubleAntFunction.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseDoubleAntFunction.java?rev=1352110&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseDoubleAntFunction.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseDoubleAntFunction.java Wed Jun 20 14:03:13 2012
@@ -0,0 +1,36 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ant.antdsl.expr.func;
+
+import java.util.List;
+
+import org.apache.tools.ant.Project;
+
+public class ParseDoubleAntFunction extends AntFunction {
+
+    public ParseDoubleAntFunction() {
+        super("parseDouble");
+    }
+
+    @Override
+    public Object eval(Project project, List<Object> arguments) {
+        checkArgumentSize(arguments, 1, 1);
+        return Double.parseDouble(arguments.get(0).toString());
+    }
+
+}

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseDoubleAntFunction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseDoubleAntFunction.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseDoubleAntFunction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseFloatAntFunction.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseFloatAntFunction.java?rev=1352110&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseFloatAntFunction.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseFloatAntFunction.java Wed Jun 20 14:03:13 2012
@@ -0,0 +1,36 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ant.antdsl.expr.func;
+
+import java.util.List;
+
+import org.apache.tools.ant.Project;
+
+public class ParseFloatAntFunction extends AntFunction {
+
+    public ParseFloatAntFunction() {
+        super("parseFloat");
+    }
+
+    @Override
+    public Object eval(Project project, List<Object> arguments) {
+        checkArgumentSize(arguments, 1, 1);
+        return Float.parseFloat(arguments.get(0).toString());
+    }
+
+}

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseFloatAntFunction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseFloatAntFunction.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseFloatAntFunction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseIntAntFunction.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseIntAntFunction.java?rev=1352110&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseIntAntFunction.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseIntAntFunction.java Wed Jun 20 14:03:13 2012
@@ -0,0 +1,36 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ant.antdsl.expr.func;
+
+import java.util.List;
+
+import org.apache.tools.ant.Project;
+
+public class ParseIntAntFunction extends AntFunction {
+
+    public ParseIntAntFunction() {
+        super("parseInt");
+    }
+
+    @Override
+    public Object eval(Project project, List<Object> arguments) {
+        checkArgumentSize(arguments, 1, 1);
+        return Integer.parseInt(arguments.get(0).toString());
+    }
+
+}

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseIntAntFunction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseIntAntFunction.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseIntAntFunction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseLongAntFunction.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseLongAntFunction.java?rev=1352110&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseLongAntFunction.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseLongAntFunction.java Wed Jun 20 14:03:13 2012
@@ -0,0 +1,36 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ant.antdsl.expr.func;
+
+import java.util.List;
+
+import org.apache.tools.ant.Project;
+
+public class ParseLongAntFunction extends AntFunction {
+
+    public ParseLongAntFunction() {
+        super("parseLong");
+    }
+
+    @Override
+    public Object eval(Project project, List<Object> arguments) {
+        checkArgumentSize(arguments, 1, 1);
+        return Long.parseLong(arguments.get(0).toString());
+    }
+
+}

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseLongAntFunction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseLongAntFunction.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/ParseLongAntFunction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/SubStringAntFunction.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/SubStringAntFunction.java?rev=1352110&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/SubStringAntFunction.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/SubStringAntFunction.java Wed Jun 20 14:03:13 2012
@@ -0,0 +1,42 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ant.antdsl.expr.func;
+
+import java.util.List;
+
+import org.apache.tools.ant.Project;
+
+public class SubStringAntFunction extends AntFunction {
+
+    public SubStringAntFunction() {
+        super("substr");
+    }
+
+    @Override
+    public Object eval(Project project, List<Object> arguments) {
+        checkArgumentSize(arguments, 2, 3);
+        String s = arguments.get(0).toString();
+        int beginIndex = asInt(arguments.get(1), 2);
+        if (arguments.size() == 2) {
+            return s.substring(beginIndex);
+        }
+        int endIndex = asInt(arguments.get(2), 3);
+        return s.substring(beginIndex, endIndex);
+    }
+
+}

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/SubStringAntFunction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/SubStringAntFunction.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/func/SubStringAntFunction.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/AntDSL.xtext
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/AntDSL.xtext?rev=1352110&r1=1352109&r2=1352110&view=diff
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/AntDSL.xtext (original)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/AntDSL.xtext Wed Jun 20 14:03:13 2012
@@ -72,10 +72,10 @@ EAssignment:
     EPropertyAssignment | EReferenceAssignment;
 
 EPropertyAssignment:
-    'prop' name=NAME '=' value=STRING;
+    'prop' name=NAME '=' value=EExpr;
 
 EReferenceAssignment:
-    'ref' name=NAME '=' value=STRING;
+    'ref' name=NAME '=' value=EExpr;
 
 EBranch:
     if=EConditionedTasks ('else' elseif+=EConditionedTasks )* ('else' else=ETaskLists)?;
@@ -103,6 +103,30 @@ EBoolPrimaryExpr returns EBoolExpr:
 EBoolNotExpr returns EBoolNotExpr:
     '!' expr=EBoolExpr;
 
+EExpr:
+    EMultExpr;
+
+EMultExpr returns EExpr:
+    EAddExpr ({EMultExpr.left=current} '*' right=EAddExpr )*;
+
+EAddExpr returns EExpr:
+    EPrimaryExpr ({EAddExpr.left=current} '+' right=EPrimaryExpr)*;
+
+EPrimaryExpr returns EExpr:
+    EFuncExpr | ENumExpr | EStringExpr | EPropExpr;
+
+EFuncExpr returns EFuncExpr:
+    name=NAME '(' arguments+=EExpr (',' arguments+=EExpr)* ')';
+
+ENumExpr returns ENumExpr:
+    value=INT;
+
+EStringExpr returns EStringExpr:
+    value=STRING;
+
+EPropExpr returns EPropExpr:
+    property=PROPERTY;
+
 EMacrodef:
     description=DOC? 'macrodef' name=NAME '(' attributes=EAttributes? ')' tasks=ETaskLists;
 
@@ -128,4 +152,4 @@ terminal PROPERTY:
     '$' NAME;
 
 terminal DOC:
-    ( '%' !('\n'|'\r')* '\r'? '\n' )+;
\ No newline at end of file
+    ( '%' !('\n'|'\r')* '\r'? '\n' )+;

Modified: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/AntDslXTextProjectHelper.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/AntDslXTextProjectHelper.java?rev=1352110&r1=1352109&r2=1352110&view=diff
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/AntDslXTextProjectHelper.java (original)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/xtext/AntDslXTextProjectHelper.java Wed Jun 20 14:03:13 2012
@@ -26,11 +26,19 @@ import java.util.List;
 
 import org.apache.ant.antdsl.AbstractAntDslProjectHelper;
 import org.apache.ant.antdsl.AntDslContext;
+import org.apache.ant.antdsl.AssignPropertyTask;
 import org.apache.ant.antdsl.ExtensionPoint;
 import org.apache.ant.antdsl.IfTask;
 import org.apache.ant.antdsl.IfTask.ConditionnalSequential;
-import org.apache.ant.antdsl.RefTask;
+import org.apache.ant.antdsl.AssignReferenceTask;
 import org.apache.ant.antdsl.Target;
+import org.apache.ant.antdsl.expr.AddAntExpression;
+import org.apache.ant.antdsl.expr.AntExpression;
+import org.apache.ant.antdsl.expr.FuncAntExpression;
+import org.apache.ant.antdsl.expr.MultiplicationAntExpression;
+import org.apache.ant.antdsl.expr.PrimaryAntExpression;
+import org.apache.ant.antdsl.expr.PropExpression;
+import org.apache.ant.antdsl.xtext.antdsl.EAddExpr;
 import org.apache.ant.antdsl.xtext.antdsl.EArgAttribute;
 import org.apache.ant.antdsl.xtext.antdsl.EArgument;
 import org.apache.ant.antdsl.xtext.antdsl.EArguments;
@@ -44,14 +52,20 @@ import org.apache.ant.antdsl.xtext.antds
 import org.apache.ant.antdsl.xtext.antdsl.EBranch;
 import org.apache.ant.antdsl.xtext.antdsl.EConditionedTasks;
 import org.apache.ant.antdsl.xtext.antdsl.EElementAttribute;
+import org.apache.ant.antdsl.xtext.antdsl.EExpr;
 import org.apache.ant.antdsl.xtext.antdsl.EExtensionPoint;
+import org.apache.ant.antdsl.xtext.antdsl.EFuncExpr;
 import org.apache.ant.antdsl.xtext.antdsl.EInnerElement;
 import org.apache.ant.antdsl.xtext.antdsl.EInnerElements;
 import org.apache.ant.antdsl.xtext.antdsl.EMacrodef;
+import org.apache.ant.antdsl.xtext.antdsl.EMultExpr;
 import org.apache.ant.antdsl.xtext.antdsl.ENamespace;
+import org.apache.ant.antdsl.xtext.antdsl.ENumExpr;
 import org.apache.ant.antdsl.xtext.antdsl.EProject;
+import org.apache.ant.antdsl.xtext.antdsl.EPropExpr;
 import org.apache.ant.antdsl.xtext.antdsl.EPropertyAssignment;
 import org.apache.ant.antdsl.xtext.antdsl.EReferenceAssignment;
+import org.apache.ant.antdsl.xtext.antdsl.EStringExpr;
 import org.apache.ant.antdsl.xtext.antdsl.ETarget;
 import org.apache.ant.antdsl.xtext.antdsl.ETargetList;
 import org.apache.ant.antdsl.xtext.antdsl.ETask;
@@ -224,18 +238,18 @@ public class AntDslXTextProjectHelper ex
     private Task mapTask(Project project, AntDslContext context, ETask eTask) {
         if (eTask instanceof EPropertyAssignment) {
             EPropertyAssignment ePropertyAssignment = (EPropertyAssignment) eTask;
-            Property property = new Property();
+            AssignPropertyTask property = new AssignPropertyTask();
             mapCommonTask(project, context, property);
             property.setName(ePropertyAssignment.getName());
-            property.setValue(ePropertyAssignment.getValue());
+            property.setValue(mapExpr(project, context, ePropertyAssignment.getValue()));
             return property;
         }
         if (eTask instanceof EReferenceAssignment) {
             EReferenceAssignment eReferenceAssignment = (EReferenceAssignment) eTask;
-            RefTask ref = new RefTask();
+            AssignReferenceTask ref = new AssignReferenceTask();
             mapCommonTask(project, context, ref);
             ref.setName(eReferenceAssignment.getName());
-            ref.setValue(eReferenceAssignment.getValue());
+            ref.setValue(mapExpr(project, context, eReferenceAssignment.getValue()));
             return ref;
         }
         if (eTask instanceof EInnerElement) {
@@ -350,4 +364,55 @@ public class AntDslXTextProjectHelper ex
 
         return innerElement;
     }
+
+    private AntExpression mapExpr(Project project, AntDslContext context, EExpr eexpr) {
+        if (eexpr instanceof EAddExpr) {
+            EAddExpr eadd = (EAddExpr) eexpr;
+            AddAntExpression add = new AddAntExpression();
+            add.setProject(project);
+            add.add(mapExpr(project, context, eadd.getLeft()));
+            add.add(mapExpr(project, context, eadd.getRight()));
+            return add;
+        }
+        if (eexpr instanceof EMultExpr) {
+            EMultExpr emult = (EMultExpr) eexpr;
+            MultiplicationAntExpression mult = new MultiplicationAntExpression();
+            mult.setProject(project);
+            mult.add(mapExpr(project, context, emult.getLeft()));
+            mult.add(mapExpr(project, context, emult.getRight()));
+            return mult;
+        }
+        if (eexpr instanceof EFuncExpr) {
+            EFuncExpr efunc = (EFuncExpr) eexpr;
+            FuncAntExpression func = new FuncAntExpression();
+            func.setProject(project);
+            func.setName(efunc.getName());
+            for (EExpr arg : efunc.getArguments()) {
+                func.addArgument(mapExpr(project, context, arg));
+            }
+            return func;
+        }
+        if (eexpr instanceof ENumExpr) {
+            ENumExpr enumb = (ENumExpr) eexpr;
+            PrimaryAntExpression primary = new PrimaryAntExpression();
+            primary.setProject(project);
+            primary.setValue(enumb.getValue());
+            return primary;
+        }
+        if (eexpr instanceof EStringExpr) {
+            EStringExpr estring = (EStringExpr) eexpr;
+            PrimaryAntExpression primary = new PrimaryAntExpression();
+            primary.setProject(project);
+            primary.setValue(estring.getValue());
+            return primary;
+        }
+        if (eexpr instanceof EPropExpr) {
+            EPropExpr eprop = (EPropExpr) eexpr;
+            PropExpression prop = new PropExpression();
+            prop.setProject(project);
+            prop.setProperty(eprop.getProperty().substring(1));
+            return prop;
+        }
+        throw new IllegalArgumentException("Unsupported expression " + eexpr.getClass().getName());
+    }
 }