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/24 15:54:20 UTC
svn commit: r1353265 [2/3] - in /ant/sandbox/antdsl: doc/
org.apache.ant.antdsl/src/org/apache/ant/antdsl/
org.apache.ant.antdsl/src/org/apache/ant/antdsl/antlr/
org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/
org.apache.ant.antdsl/src/org/apache...
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/GTAntExpression.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/GTAntExpression.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/GTAntExpression.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/InclusiveOrAntExpression.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/InclusiveOrAntExpression.java?rev=1353265&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/InclusiveOrAntExpression.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/InclusiveOrAntExpression.java Sun Jun 24 13:54:17 2012
@@ -0,0 +1,46 @@
+/*
+ * 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 InclusiveOrAntExpression extends FixedArithmeticBinaryAntExpression {
+
+ public InclusiveOrAntExpression() {
+ super("|");
+ }
+
+ @Override
+ protected Object eval(byte v1, byte v2, String t1, String t2) {
+ return v1 | v2;
+ }
+
+ @Override
+ protected Object eval(short v1, short v2, String t1, String t2) {
+ return v1 | v2;
+ }
+
+ @Override
+ protected Object eval(int v1, int v2, String t1, String t2) {
+ return v1 | v2;
+ }
+
+ @Override
+ protected Object eval(long v1, long v2, String t1, String t2) {
+ return v1 | v2;
+ }
+
+}
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/InclusiveOrAntExpression.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/InclusiveOrAntExpression.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/InclusiveOrAntExpression.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/IncompatibleTypeException.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/IncompatibleTypeException.java?rev=1353265&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/IncompatibleTypeException.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/IncompatibleTypeException.java Sun Jun 24 13:54:17 2012
@@ -0,0 +1,40 @@
+/*
+ * 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.BuildException;
+
+public class IncompatibleTypeException extends BuildException {
+
+ private final String name;
+
+ private final String t1;
+
+ private final String t2;
+
+ public IncompatibleTypeException(String name, String t1, String t2) {
+ super("incomptable type for operation " + name + ": '" + t1 + "' and '" + t2 + "'");
+ this.name = name;
+ this.t1 = t1;
+ this.t2 = t2;
+ }
+
+ public IncompatibleTypeException switchTypes() {
+ return new IncompatibleTypeException(name, t2, t1);
+ }
+}
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/IncompatibleTypeException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/IncompatibleTypeException.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/IncompatibleTypeException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/InstanceofAntExpression.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/InstanceofAntExpression.java?rev=1353265&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/InstanceofAntExpression.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/InstanceofAntExpression.java Sun Jun 24 13:54:17 2012
@@ -0,0 +1,34 @@
+/*
+ * 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.BuildException;
+
+public class InstanceofAntExpression extends BinaryAntExpression {
+
+ @Override
+ protected Boolean eval(Object v1, Object v2) {
+ // FIXME ugly implementation
+ try {
+ return Class.forName(v2.toString()).isAssignableFrom(v1.getClass());
+ } catch (ClassNotFoundException e) {
+ throw new BuildException(e);
+ }
+ }
+
+}
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/InstanceofAntExpression.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/InstanceofAntExpression.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/InstanceofAntExpression.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/LEAntExpression.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/LEAntExpression.java?rev=1353265&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/LEAntExpression.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/LEAntExpression.java Sun Jun 24 13:54:17 2012
@@ -0,0 +1,56 @@
+/*
+ * 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 LEAntExpression extends ArithmeticBinaryAntExpression {
+
+ public LEAntExpression() {
+ super("<=");
+ }
+
+ @Override
+ protected Object eval(byte v1, byte v2, String t1, String t2) {
+ return v1 <= v2;
+ }
+
+ @Override
+ protected Object eval(short v1, short v2, String t1, String t2) {
+ return v1 <= v2;
+ }
+
+ @Override
+ protected Object eval(int v1, int v2, String t1, String t2) {
+ return v1 <= v2;
+ }
+
+ @Override
+ protected Object eval(long v1, long v2, String t1, String t2) {
+ return v1 <= v2;
+ }
+
+ @Override
+ protected Object eval(float v1, float v2, String t1, String t2) {
+ return v1 <= v2;
+ }
+
+ @Override
+ protected Object eval(double v1, double v2, String t1, String t2) {
+ return v1 <= v2;
+ }
+
+}
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/LEAntExpression.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/LEAntExpression.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/LEAntExpression.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/LTAntExpression.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/LTAntExpression.java?rev=1353265&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/LTAntExpression.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/LTAntExpression.java Sun Jun 24 13:54:17 2012
@@ -0,0 +1,56 @@
+/*
+ * 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 LTAntExpression extends ArithmeticBinaryAntExpression {
+
+ public LTAntExpression() {
+ super("<");
+ }
+
+ @Override
+ protected Object eval(byte v1, byte v2, String t1, String t2) {
+ return v1 < v2;
+ }
+
+ @Override
+ protected Object eval(short v1, short v2, String t1, String t2) {
+ return v1 < v2;
+ }
+
+ @Override
+ protected Object eval(int v1, int v2, String t1, String t2) {
+ return v1 < v2;
+ }
+
+ @Override
+ protected Object eval(long v1, long v2, String t1, String t2) {
+ return v1 < v2;
+ }
+
+ @Override
+ protected Object eval(float v1, float v2, String t1, String t2) {
+ return v1 < v2;
+ }
+
+ @Override
+ protected Object eval(double v1, double v2, String t1, String t2) {
+ return v1 < v2;
+ }
+
+}
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/LTAntExpression.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/LTAntExpression.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/LTAntExpression.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/LeftShiftAntExpression.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/LeftShiftAntExpression.java?rev=1353265&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/LeftShiftAntExpression.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/LeftShiftAntExpression.java Sun Jun 24 13:54:17 2012
@@ -0,0 +1,46 @@
+/*
+ * 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 LeftShiftAntExpression extends FixedArithmeticBinaryAntExpression {
+
+ public LeftShiftAntExpression() {
+ super("<<");
+ }
+
+ @Override
+ protected Object eval(byte v1, byte v2, String t1, String t2) {
+ return v1 << v2;
+ }
+
+ @Override
+ protected Object eval(short v1, short v2, String t1, String t2) {
+ return v1 << v2;
+ }
+
+ @Override
+ protected Object eval(int v1, int v2, String t1, String t2) {
+ return v1 << v2;
+ }
+
+ @Override
+ protected Object eval(long v1, long v2, String t1, String t2) {
+ return v1 << v2;
+ }
+
+}
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/LeftShiftAntExpression.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/LeftShiftAntExpression.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/LeftShiftAntExpression.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/LogicalRightShiftAntExpression.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/LogicalRightShiftAntExpression.java?rev=1353265&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/LogicalRightShiftAntExpression.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/LogicalRightShiftAntExpression.java Sun Jun 24 13:54:17 2012
@@ -0,0 +1,46 @@
+/*
+ * 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 LogicalRightShiftAntExpression extends FixedArithmeticBinaryAntExpression {
+
+ public LogicalRightShiftAntExpression() {
+ super(">>>");
+ }
+
+ @Override
+ protected Object eval(byte v1, byte v2, String t1, String t2) {
+ return v1 >>> v2;
+ }
+
+ @Override
+ protected Object eval(short v1, short v2, String t1, String t2) {
+ return v1 >>> v2;
+ }
+
+ @Override
+ protected Object eval(int v1, int v2, String t1, String t2) {
+ return v1 >>> v2;
+ }
+
+ @Override
+ protected Object eval(long v1, long v2, String t1, String t2) {
+ return v1 >>> v2;
+ }
+
+}
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/LogicalRightShiftAntExpression.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/LogicalRightShiftAntExpression.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/LogicalRightShiftAntExpression.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/MinusAntExpression.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/MinusAntExpression.java?rev=1353265&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/MinusAntExpression.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/MinusAntExpression.java Sun Jun 24 13:54:17 2012
@@ -0,0 +1,56 @@
+/*
+ * 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 MinusAntExpression extends ArithmeticBinaryAntExpression {
+
+ public MinusAntExpression() {
+ super("-");
+ }
+
+ @Override
+ protected Object eval(byte v1, byte v2, String t1, String t2) {
+ return v1 - v2;
+ }
+
+ @Override
+ protected Object eval(short v1, short v2, String t1, String t2) {
+ return v1 - v2;
+ }
+
+ @Override
+ protected Object eval(int v1, int v2, String t1, String t2) {
+ return v1 - v2;
+ }
+
+ @Override
+ protected Object eval(long v1, long v2, String t1, String t2) {
+ return v1 - v2;
+ }
+
+ @Override
+ protected Object eval(float v1, float v2, String t1, String t2) {
+ return v1 - v2;
+ }
+
+ @Override
+ protected Object eval(double v1, double v2, String t1, String t2) {
+ return v1 - v2;
+ }
+
+}
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/MinusAntExpression.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/MinusAntExpression.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/MinusAntExpression.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/ModuloAntExpression.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/ModuloAntExpression.java?rev=1353265&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/ModuloAntExpression.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/ModuloAntExpression.java Sun Jun 24 13:54:17 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;
+
+public class ModuloAntExpression extends ArithmeticBinaryAntExpression {
+
+ public ModuloAntExpression() {
+ super("%");
+ }
+
+ @Override
+ protected Object eval(byte v1, byte v2, String t1, String t2) {
+ return v1 % v2;
+ }
+
+ @Override
+ protected Object eval(short v1, short v2, String t1, String t2) {
+ return v1 % v2;
+ }
+
+ @Override
+ protected Object eval(int v1, int v2, String t1, String t2) {
+ return v1 % v2;
+ }
+
+ @Override
+ protected Object eval(long v1, long v2, String t1, String t2) {
+ return v1 % v2;
+ }
+
+ @Override
+ protected Object eval(float v1, float v2, String t1, String t2) {
+ return v1 % v2;
+ }
+
+ @Override
+ protected Object eval(double v1, double v2, String t1, String t2) {
+ return v1 % v2;
+ }
+}
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/ModuloAntExpression.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/ModuloAntExpression.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/ModuloAntExpression.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: 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=1353265&r1=1353264&r2=1353265&view=diff
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/MultiplicationAntExpression.java (original)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/MultiplicationAntExpression.java Sun Jun 24 13:54:17 2012
@@ -17,59 +17,39 @@
*/
package org.apache.ant.antdsl.expr;
-public class MultiplicationAntExpression extends CommutativeArithmeticAntExpression {
+public class MultiplicationAntExpression extends ArithmeticBinaryAntExpression {
public MultiplicationAntExpression() {
- super("multiplication");
+ super("*");
}
@Override
- protected Object eval(int v1, int v2) {
+ protected Object eval(byte v1, byte v2, String t1, String t2) {
return v1 * v2;
}
@Override
- protected Object eval(int v1, long v2) {
+ protected Object eval(short v1, short v2, String t1, String t2) {
return v1 * v2;
}
@Override
- protected Object eval(int v1, float v2) {
+ protected Object eval(int v1, int v2, String t1, String t2) {
return v1 * v2;
}
@Override
- protected Object eval(int v1, double v2) {
+ protected Object eval(long v1, long v2, String t1, String t2) {
return v1 * v2;
}
@Override
- protected Object eval(long v1, long v2) {
+ protected Object eval(float v1, float v2, String t1, String t2) {
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) {
+ protected Object eval(double v1, double v2, String t1, String t2) {
return v1 * v2;
}
}
Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/NegativeAntExpression.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/NegativeAntExpression.java?rev=1353265&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/NegativeAntExpression.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/NegativeAntExpression.java Sun Jun 24 13:54:17 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 class NegativeAntExpression extends UnaryAntExpression {
+
+ public NegativeAntExpression() {
+ super("-");
+ }
+
+ @Override
+ protected Object eval(String v) {
+ throw buildUnexpectedTypeException("String");
+ }
+
+ @Override
+ protected Object eval(boolean v) {
+ throw buildUnexpectedTypeException("boolean");
+ }
+
+ @Override
+ protected Object eval(byte v) {
+ return -v;
+ }
+
+ @Override
+ protected Object eval(short v) {
+ return -v;
+ }
+
+ @Override
+ protected Object eval(int v) {
+ return -v;
+ }
+
+ @Override
+ protected Object eval(long v) {
+ return -v;
+ }
+
+ @Override
+ protected Object eval(float v) {
+ return -v;
+ }
+
+ @Override
+ protected Object eval(double v) {
+ return -v;
+ }
+
+}
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/NegativeAntExpression.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/NegativeAntExpression.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/NegativeAntExpression.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/NotBitwiseAntExpression.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/NotBitwiseAntExpression.java?rev=1353265&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/NotBitwiseAntExpression.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/NotBitwiseAntExpression.java Sun Jun 24 13:54:17 2012
@@ -0,0 +1,65 @@
+/*
+ * 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 NotBitwiseAntExpression extends UnaryAntExpression {
+
+ public NotBitwiseAntExpression() {
+ super("~");
+ }
+
+ @Override
+ protected Object eval(String v) {
+ throw buildUnexpectedTypeException("String");
+ }
+
+ @Override
+ protected Object eval(boolean v) {
+ throw buildUnexpectedTypeException("boolean");
+ }
+
+ @Override
+ protected Object eval(byte v) {
+ return ~v;
+ }
+
+ @Override
+ protected Object eval(short v) {
+ return ~v;
+ }
+
+ @Override
+ protected Object eval(int v) {
+ return ~v;
+ }
+
+ @Override
+ protected Object eval(long v) {
+ return ~v;
+ }
+
+ @Override
+ protected Object eval(float v) {
+ throw buildUnexpectedTypeException("float");
+ }
+
+ @Override
+ protected Object eval(double v) {
+ throw buildUnexpectedTypeException("double");
+ }
+}
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/NotBitwiseAntExpression.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/NotBitwiseAntExpression.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/NotBitwiseAntExpression.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PositiveAntExpression.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PositiveAntExpression.java?rev=1353265&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PositiveAntExpression.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PositiveAntExpression.java Sun Jun 24 13:54:17 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 class PositiveAntExpression extends UnaryAntExpression {
+
+ public PositiveAntExpression() {
+ super("+");
+ }
+
+ @Override
+ protected Object eval(String v) {
+ throw buildUnexpectedTypeException("String");
+ }
+
+ @Override
+ protected Object eval(boolean v) {
+ throw buildUnexpectedTypeException("boolean");
+ }
+
+ @Override
+ protected Object eval(byte v) {
+ return +v;
+ }
+
+ @Override
+ protected Object eval(short v) {
+ return +v;
+ }
+
+ @Override
+ protected Object eval(int v) {
+ return +v;
+ }
+
+ @Override
+ protected Object eval(long v) {
+ return +v;
+ }
+
+ @Override
+ protected Object eval(float v) {
+ return +v;
+ }
+
+ @Override
+ protected Object eval(double v) {
+ return +v;
+ }
+
+}
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PositiveAntExpression.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PositiveAntExpression.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PositiveAntExpression.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PrimitiveBinaryAntExpression.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PrimitiveBinaryAntExpression.java?rev=1353265&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PrimitiveBinaryAntExpression.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PrimitiveBinaryAntExpression.java Sun Jun 24 13:54:17 2012
@@ -0,0 +1,409 @@
+/*
+ * 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.BuildException;
+
+public abstract class PrimitiveBinaryAntExpression extends BinaryAntExpression {
+
+ private final String name;
+
+ public PrimitiveBinaryAntExpression(String name) {
+ this.name = name;
+ }
+
+ protected BuildException buildIncompatibleTypeException(String t1, String t2) {
+ return new IncompatibleTypeException(name, t1, t2);
+ }
+
+ @Override
+ final protected Object eval(Object v1, Object v2) {
+ if (v1 instanceof String) {
+ return eval((String) v1, v2);
+ } else if (v1 instanceof Boolean) {
+ return eval((Boolean) v1, v2);
+ } else if (v1 instanceof Byte) {
+ return eval((Byte) v1, v2);
+ } else if (v1 instanceof Short) {
+ return eval((Short) v1, v2);
+ } else if (v1 instanceof Integer) {
+ return eval((Integer) v1, v2);
+ } else if (v1 instanceof Long) {
+ return eval((Long) v1, v2);
+ } else if (v1 instanceof Float) {
+ return eval((Float) v1, v2);
+ } else if (v1 instanceof Double) {
+ return eval((Double) v1, v2);
+ } else {
+ return eval(v1.toString(), v2);
+ }
+ }
+
+ private Object eval(String v1, Object v2) {
+ if (v2 instanceof String) {
+ return eval(v1, (String) v2);
+ }
+ if (v2 instanceof Boolean) {
+ return eval(v1, ((Boolean) v2).booleanValue());
+ }
+ if (v2 instanceof Byte) {
+ return eval(v1, ((Byte) v2).byteValue());
+ }
+ if (v2 instanceof Short) {
+ return eval(v1, ((Short) v2).shortValue());
+ }
+ 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, boolean v2);
+
+ abstract protected Object eval(String v1, byte v2);
+
+ abstract protected Object eval(String v1, short 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(Boolean v1, Object v2) {
+ if (v2 instanceof String) {
+ return eval(v1.booleanValue(), (String) v2);
+ }
+ if (v2 instanceof Boolean) {
+ return eval(v1.booleanValue(), ((Boolean) v2).booleanValue());
+ }
+ if (v2 instanceof Byte) {
+ return eval(v1.booleanValue(), ((Byte) v2).byteValue());
+ }
+ if (v2 instanceof Short) {
+ return eval(v1.booleanValue(), ((Short) v2).shortValue());
+ }
+ if (v2 instanceof Integer) {
+ return eval(v1.booleanValue(), ((Integer) v2).intValue());
+ }
+ if (v2 instanceof Long) {
+ return eval(v1.booleanValue(), ((Long) v2).longValue());
+ }
+ if (v2 instanceof Float) {
+ return eval(v1.booleanValue(), ((Float) v2).floatValue());
+ }
+ if (v2 instanceof Double) {
+ return eval(v1.booleanValue(), ((Double) v2).doubleValue());
+ }
+ return eval(v1.booleanValue(), v2.toString());
+ }
+
+ abstract protected Object eval(boolean v1, String v2);
+
+ abstract protected Object eval(boolean v1, boolean v2);
+
+ abstract protected Object eval(boolean v1, byte v2);
+
+ abstract protected Object eval(boolean v1, short v2);
+
+ abstract protected Object eval(boolean v1, int v2);
+
+ abstract protected Object eval(boolean v1, long v2);
+
+ abstract protected Object eval(boolean v1, float v2);
+
+ abstract protected Object eval(boolean v1, double v2);
+
+ private Object eval(Byte v1, Object v2) {
+ if (v2 instanceof String) {
+ return eval(v1.byteValue(), (String) v2);
+ }
+ if (v2 instanceof Boolean) {
+ return eval(v1.byteValue(), ((Boolean) v2).booleanValue());
+ }
+ if (v2 instanceof Byte) {
+ return eval(v1.byteValue(), ((Byte) v2).byteValue());
+ }
+ if (v2 instanceof Short) {
+ return eval(v1.byteValue(), ((Short) v2).shortValue());
+ }
+ if (v2 instanceof Integer) {
+ return eval(v1.byteValue(), ((Integer) v2).intValue());
+ }
+ if (v2 instanceof Long) {
+ return eval(v1.byteValue(), ((Long) v2).longValue());
+ }
+ if (v2 instanceof Float) {
+ return eval(v1.byteValue(), ((Float) v2).floatValue());
+ }
+ if (v2 instanceof Double) {
+ return eval(v1.byteValue(), ((Double) v2).doubleValue());
+ }
+ return eval(v1.byteValue(), v2.toString());
+ }
+
+ abstract protected Object eval(byte v1, String v2);
+
+ abstract protected Object eval(byte v1, boolean v2);
+
+ abstract protected Object eval(byte v1, byte v2);
+
+ abstract protected Object eval(byte v1, short v2);
+
+ abstract protected Object eval(byte v1, int v2);
+
+ abstract protected Object eval(byte v1, long v2);
+
+ abstract protected Object eval(byte v1, float v2);
+
+ abstract protected Object eval(byte v1, double v2);
+
+ private Object eval(Short v1, Object v2) {
+ if (v2 instanceof String) {
+ return eval(v1.shortValue(), (String) v2);
+ }
+ if (v2 instanceof Boolean) {
+ return eval(v1.shortValue(), ((Boolean) v2).booleanValue());
+ }
+ if (v2 instanceof Byte) {
+ return eval(v1.shortValue(), ((Byte) v2).byteValue());
+ }
+ if (v2 instanceof Short) {
+ return eval(v1.shortValue(), ((Short) v2).shortValue());
+ }
+ if (v2 instanceof Integer) {
+ return eval(v1.shortValue(), ((Integer) v2).intValue());
+ }
+ if (v2 instanceof Long) {
+ return eval(v1.shortValue(), ((Long) v2).longValue());
+ }
+ if (v2 instanceof Float) {
+ return eval(v1.shortValue(), ((Float) v2).floatValue());
+ }
+ if (v2 instanceof Double) {
+ return eval(v1.shortValue(), ((Double) v2).doubleValue());
+ }
+ return eval(v1.shortValue(), v2.toString());
+ }
+
+ abstract protected Object eval(short v1, String v2);
+
+ abstract protected Object eval(short v1, boolean v2);
+
+ abstract protected Object eval(short v1, byte v2);
+
+ abstract protected Object eval(short v1, short v2);
+
+ abstract protected Object eval(short v1, int v2);
+
+ abstract protected Object eval(short v1, long v2);
+
+ abstract protected Object eval(short v1, float v2);
+
+ abstract protected Object eval(short v1, double v2);
+
+ private Object eval(Integer v1, Object v2) {
+ if (v2 instanceof String) {
+ return eval(v1.intValue(), (String) v2);
+ }
+ if (v2 instanceof Boolean) {
+ return eval(v1.intValue(), ((Boolean) v2).booleanValue());
+ }
+ if (v2 instanceof Byte) {
+ return eval(v1.intValue(), ((Byte) v2).byteValue());
+ }
+ if (v2 instanceof Short) {
+ return eval(v1.intValue(), ((Short) v2).shortValue());
+ }
+ 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, boolean v2);
+
+ abstract protected Object eval(int v1, byte v2);
+
+ abstract protected Object eval(int v1, short 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 Boolean) {
+ return eval(v1.longValue(), ((Boolean) v2).booleanValue());
+ }
+ if (v2 instanceof Byte) {
+ return eval(v1.longValue(), ((Byte) v2).byteValue());
+ }
+ if (v2 instanceof Short) {
+ return eval(v1.longValue(), ((Short) v2).shortValue());
+ }
+ 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, boolean v2);
+
+ abstract protected Object eval(long v1, byte v2);
+
+ abstract protected Object eval(long v1, short 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 Boolean) {
+ return eval(v1.floatValue(), ((Boolean) v2).booleanValue());
+ }
+ if (v2 instanceof Byte) {
+ return eval(v1.floatValue(), ((Byte) v2).byteValue());
+ }
+ if (v2 instanceof Short) {
+ return eval(v1.floatValue(), ((Short) v2).shortValue());
+ }
+ 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, boolean v2);
+
+ abstract protected Object eval(float v1, byte v2);
+
+ abstract protected Object eval(float v1, short 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 Boolean) {
+ return eval(v1.doubleValue(), ((Boolean) v2).booleanValue());
+ }
+ if (v2 instanceof Byte) {
+ return eval(v1.doubleValue(), ((Byte) v2).byteValue());
+ }
+ if (v2 instanceof Short) {
+ return eval(v1.doubleValue(), ((Short) v2).shortValue());
+ }
+ 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, boolean v2);
+
+ abstract protected Object eval(double v1, byte v2);
+
+ abstract protected Object eval(double v1, short 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/PrimitiveBinaryAntExpression.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PrimitiveBinaryAntExpression.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/PrimitiveBinaryAntExpression.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/RightShiftAntExpression.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/RightShiftAntExpression.java?rev=1353265&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/RightShiftAntExpression.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/RightShiftAntExpression.java Sun Jun 24 13:54:17 2012
@@ -0,0 +1,46 @@
+/*
+ * 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 RightShiftAntExpression extends FixedArithmeticBinaryAntExpression {
+
+ public RightShiftAntExpression() {
+ super(">>");
+ }
+
+ @Override
+ protected Object eval(byte v1, byte v2, String t1, String t2) {
+ return v1 >> v2;
+ }
+
+ @Override
+ protected Object eval(short v1, short v2, String t1, String t2) {
+ return v1 >> v2;
+ }
+
+ @Override
+ protected Object eval(int v1, int v2, String t1, String t2) {
+ return v1 >> v2;
+ }
+
+ @Override
+ protected Object eval(long v1, long v2, String t1, String t2) {
+ return v1 >> v2;
+ }
+
+}
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/RightShiftAntExpression.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/RightShiftAntExpression.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/RightShiftAntExpression.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/TernaryAntExpression.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/TernaryAntExpression.java?rev=1353265&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/TernaryAntExpression.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/TernaryAntExpression.java Sun Jun 24 13:54:17 2012
@@ -0,0 +1,47 @@
+/*
+ * 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.taskdefs.condition.Condition;
+
+public class TernaryAntExpression extends AntExpression {
+
+ private Condition condition;
+
+ private AntExpression onTrue;
+
+ private AntExpression onFalse;
+
+ public void setCondition(Condition condition) {
+ this.condition = condition;
+ }
+
+ public void setOnTrue(AntExpression onTrue) {
+ this.onTrue = onTrue;
+ }
+
+ public void setOnFalse(AntExpression onFalse) {
+ this.onFalse = onFalse;
+ }
+
+ @Override
+ public Object eval() {
+ return condition.eval() ? onTrue.eval() : onFalse.eval();
+ }
+
+}
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/TernaryAntExpression.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/TernaryAntExpression.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/TernaryAntExpression.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/UnaryAntExpression.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/UnaryAntExpression.java?rev=1353265&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/UnaryAntExpression.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/UnaryAntExpression.java Sun Jun 24 13:54:17 2012
@@ -0,0 +1,89 @@
+/*
+ * 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.BuildException;
+
+public abstract class UnaryAntExpression extends AntExpression {
+
+ private final String name;
+
+ private AntExpression expr;
+
+ public UnaryAntExpression(String name) {
+ this.name = name;
+ }
+
+ public void setExpr(AntExpression expr) {
+ this.expr = expr;
+ }
+
+ protected BuildException buildUnexpectedTypeException(String type) {
+ return new BuildException("unexpected type for operation " + name + ": '" + type + "'");
+ }
+
+ @Override
+ final public Object eval() {
+ return eval(expr.eval());
+ }
+
+ private Object eval(Object v) {
+ if (v instanceof String) {
+ return eval((String) v);
+ }
+ if (v instanceof Boolean) {
+ return eval(((Boolean) v).booleanValue());
+ }
+ if (v instanceof Byte) {
+ return eval(((Byte) v).byteValue());
+ }
+ if (v instanceof Short) {
+ return eval(((Short) v).shortValue());
+ }
+ if (v instanceof Integer) {
+ return eval(((Integer) v).intValue());
+ }
+ if (v instanceof Long) {
+ return eval(((Long) v).longValue());
+ }
+ if (v instanceof Float) {
+ return eval(((Float) v).floatValue());
+ }
+ if (v instanceof Double) {
+ return eval(((Double) v).doubleValue());
+ }
+ return eval(v.toString());
+ }
+
+ abstract protected Object eval(String v);
+
+ abstract protected Object eval(boolean v);
+
+ abstract protected Object eval(byte v);
+
+ abstract protected Object eval(short v);
+
+ abstract protected Object eval(int v);
+
+ abstract protected Object eval(long v);
+
+ abstract protected Object eval(float v);
+
+ abstract protected Object eval(double v);
+
+}
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/UnaryAntExpression.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/UnaryAntExpression.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/UnaryAntExpression.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/VariableAntExpression.java
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/VariableAntExpression.java?rev=1353265&view=auto
==============================================================================
--- ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/VariableAntExpression.java (added)
+++ ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/VariableAntExpression.java Sun Jun 24 13:54:17 2012
@@ -0,0 +1,47 @@
+/*
+ * 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;
+import org.apache.tools.ant.property.LocalProperties;
+
+public class VariableAntExpression extends AntExpression {
+
+ private String name;
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public Object eval() {
+ Object value = LocalProperties.get(getProject()).evaluate(name, PropertyHelper.getPropertyHelper(getProject()));
+ if (value == null) {
+ value = PropertyHelper.getProperty(getProject(), name);
+ if (value == null) {
+ value = getProject().getReference(name);
+ }
+ }
+ return value;
+ }
+
+}
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/VariableAntExpression.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/VariableAntExpression.java
------------------------------------------------------------------------------
svn:keywords = Date Revision Author HeadURL Id
Propchange: ant/sandbox/antdsl/org.apache.ant.antdsl/src/org/apache/ant/antdsl/expr/VariableAntExpression.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=1353265&r1=1353264&r2=1353265&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 Sun Jun 24 13:54:17 2012
@@ -15,32 +15,34 @@
* limitations under the License.
*
*/
-grammar org.apache.ant.antdsl.xtext.AntDSL with org.eclipse.xtext.common.Terminals
+grammar org.apache.ant.antdsl.xtext.AntDSL hidden(WS, ML_COMMENT, SL_COMMENT)
+
+import "http://www.eclipse.org/emf/2002/Ecore" as ecore
generate antdsl "http://www.apache.org/ant/AntDSL"
EProject:
{EProject}
(
- ('name' ':' name=NAME)?
- & ('default' ':' default=NAME)?
- & ('basedir' ':' basedir=STRING)?
+ ('name' ':' name=Identifier)?
+ & ('default' ':' default=Identifier)?
+ & ('basedir' ':' basedir=StringLiteral)?
)
('namespaces' '{' namespaces+=ENamespace* '}')?
tasks=ETaskLists?
(targets+=ETarget | extensionPoints+=EExtensionPoint | macrodDefs+=EMacrodef)*;
ENamespace:
- name=NAME ':' uri=STRING;
+ name=Identifier ':' uri=StringLiteral;
EExtensionPoint:
- description=DOC? 'extension-point' name=NAME (('extensionOf' extensionsOf=ETargetList ('onMiss' onMissingExtensionPoint=STRING)? )?
- & ('depends' depends=ETargetList)? & ('if' if=EBoolExpr)? & ('unless' unless=EBoolExpr)?
+ description=DOC? 'extension-point' name=Identifier (('extensionOf' extensionsOf=ETargetList ('onMiss' onMissingExtensionPoint=StringLiteral)? )?
+ & ('depends' depends=ETargetList)? & ('if' if=EExpr)? & ('unless' unless=EExpr)?
);
ETarget:
- description=DOC? 'target' name=NAME (('extensionOf' extensionsOf=ETargetList ('onMiss' onMissingExtensionPoint=STRING)? )?
- & ('depends' depends=ETargetList)? & ('if' if=EBoolExpr)? & ('unless' unless=EBoolExpr)?
+ description=DOC? 'target' name=Identifier (('extensionOf' extensionsOf=ETargetList ('onMiss' onMissingExtensionPoint=StringLiteral)? )?
+ & ('depends' depends=ETargetList)? & ('if' if=EExpr)? & ('unless' unless=EExpr)?
) tasks=ETaskLists?;
ETaskLists:
@@ -48,19 +50,19 @@ ETaskLists:
'{' tasks+=ETask* '}';
ETargetList:
- names+=NAME (',' names+=NAME)*;
+ names+=Identifier (',' names+=Identifier)*;
ETask:
EAssignment | EInnerElement | EBranch;
ENSName:
- (namespace=NAME ':')? name=NAME;
+ (namespace=Identifier ':')? name=Identifier;
EArguments:
arguments+=EArgument (',' arguments+=EArgument)*;
EArgument:
- name=NAME '=' value=STRING;
+ name=Identifier '=' value=StringLiteral;
EInnerElements:
'{' elements+=EInnerElement+ '}';
@@ -72,66 +74,26 @@ EAssignment:
EPropertyAssignment | EReferenceAssignment | ELocalAssignment;
EPropertyAssignment:
- 'prop' name=NAME '=' value=EExpr;
+ 'prop' name=Identifier '=' value=EExpr;
EReferenceAssignment:
- 'ref' name=NAME '=' value=EExpr;
+ 'ref' name=Identifier '=' value=EExpr;
ELocalAssignment:
- 'local' name=NAME '=' value=EExpr;
+ 'local' name=Identifier '=' value=EExpr;
EBranch:
if=EConditionedTasks ('else' elseif+=EConditionedTasks )* ('else' else=ETaskLists)?;
EConditionedTasks:
- 'if' '(' condition=EBoolExpr ')' tasks=ETaskLists;
-
-EBoolExpr:
- EBoolXorExpr;
-
-EBoolXorExpr returns EBoolExpr:
- EBoolOrExpr ({EBoolXorExpr.left=current} '^^' right=EBoolOrExpr)*;
-
-EBoolOrExpr returns EBoolExpr:
- EBoolAndExpr ({EBoolOrExpr.left=current} '||' right=EBoolAndExpr)*;
-
-EBoolAndExpr returns EBoolExpr:
- EBoolPrimaryExpr ({EBoolAndExpr.left=current} '&&' right=EBoolPrimaryExpr)*;
-
-EBoolPrimaryExpr returns EBoolExpr:
- EInnerElement
- | '(' EBoolExpr ')'
- | EBoolNotExpr;
+ 'if' '(' condition=EExpr ')' tasks=ETaskLists;
-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 | EVariableExpr;
-
-EFuncExpr returns EFuncExpr:
- name=NAME '(' arguments+=EExpr (',' arguments+=EExpr)* ')';
-
-ENumExpr returns ENumExpr:
- value=INT;
-
-EStringExpr returns EStringExpr:
- value=STRING;
-
-EVariableExpr returns EVariableExpr:
- name=VARIABLE;
+////////////////
+// Macro
+////////////////
EMacrodef:
- description=DOC? 'macrodef' name=NAME '(' attributes=EAttributes? ')' tasks=ETaskLists;
+ description=DOC? 'macrodef' name=Identifier '(' attributes=EAttributes? ')' tasks=ETaskLists;
EAttributes:
attributes+=EAttribute (',' attributes+=EAttribute)*;
@@ -140,19 +102,281 @@ EAttribute:
EArgAttribute | ETextAttribute | EElementAttribute;
EArgAttribute:
- 'arg' name=NAME ('=' default=STRING)?;
+ 'arg' name=Identifier ('=' default=StringLiteral)?;
ETextAttribute:
- (optional ?= 'optional')? (trimmed ?= 'trimmed')? 'text' name=NAME;
+ (optional ?= 'optional')? (trimmed ?= 'trimmed')? 'text' name=Identifier;
EElementAttribute:
- (optional ?= 'optional')? (implicit ?= 'implicit')? 'element' name=NAME;
+ (optional ?= 'optional')? (implicit ?= 'implicit')? 'element' name=Identifier;
+
+////////////////
+// Expression
+////////////////
-terminal NAME:
- ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'-'|'.'|'0'..'9')*;
+// an expression is actually a lot like a java one
+// highly inspired by http://www.antlr.org/grammar/1152141644268/Java.g
+EExpr:
+ ETernaryExpr
+;
+
+ETernaryExpr returns EExpr:
+ EConditionnalInclusiveOrExpr ({ETernaryExpr.condition=current} '?' onTrue=EExpr ':' onFalse=EExpr)?
+;
+
+EConditionnalInclusiveOrExpr returns EExpr:
+ EConditionnalExclusiveOrExpr ({EConditionnalInclusiveOrExpr.children+=current} '||' children+=EConditionnalExclusiveOrExpr)*
+;
+
+EConditionnalExclusiveOrExpr returns EExpr:
+ // not a real java operator, but nice to have
+ EConditionnalAndExpr ({EConditionnalExclusiveOrExpr.children+=current} '^^' children+=EConditionnalAndExpr)*
+;
+
+EConditionnalAndExpr returns EExpr:
+ EInclusiveOrExpr ({EConditionnalAndExpr.children+=current} '&&' children+=EInclusiveOrExpr)*
+;
+
+EInclusiveOrExpr returns EExpr:
+ EExclusiveOrExpr ({EInclusiveOrExpr.children+=current} '|' children+=EExclusiveOrExpr)*
+;
+
+EExclusiveOrExpr returns EExpr:
+ EAndExpr ({EExclusiveOrExpr.children+=current} '^' children+=EAndExpr)*
+;
+
+EAndExpr returns EExpr:
+ EEqualityExpr ({EAndExpr.children+=current} '&' children+=EEqualityExpr)*
+;
+
+EEqualityExpr returns EExpr:
+ EInstanceOfExpr ({EEqualityExpr.children+=current} '==' children+=EInstanceOfExpr)*
+;
+
+EInstanceOfExpr returns EExpr:
+ ERelationalExpr ({EInstanceOfExpr.children+=current} 'instanceof' children+=ERelationalExpr)*
+;
+
+ERelationalExpr returns EExpr:
+ EShiftExpr ({ERelationalExpr.children+=current} operators+=ERelationalOp children+=EShiftExpr)*
+;
+
+ERelationalOp:
+// java spec authorize '<=' and '>=' to be split by spaces or tabs
+// for sake of simplicity, we won't here
+ '<=' | '>=' | '<' | '>'
+;
+
+EShiftExpr returns EExpr:
+ EAdditiveExpr ({EShiftExpr.children+=current} operators+=EShiftOp children+=EAdditiveExpr)*
+;
+
+EShiftOp:
+// idem as ERelationalOp, not authorized space
+ '<<' | '>>>' | '>>'
+;
+
+EAdditiveExpr returns EExpr:
+ EMultiplicativeExpr ({EAdditiveExpr.children+=current} operators+=('+' | '-') children+=EMultiplicativeExpr)*
+;
+
+EMultiplicativeExpr returns EExpr:
+ EUnaryExpr ({EMultiplicativeExpr.children+=current} operators+=('*' | '/' | '%') children+=EUnaryExpr)*
+;
+
+EUnaryExpr returns EExpr:
+ {EUnaryExpr} op='+' expr=EUnaryExpr
+ | {EUnaryExpr} op='-' expr=EUnaryExpr
+// | {EUnaryExpr} op='++' expr=EUnaryExpr
+// | {EUnaryExpr} op='--' expr=EUnaryExpr
+ | EUnaryExprNotPlusMinus
+;
+
+EUnaryExprNotPlusMinus returns EExpr:
+ {EUnaryExpr} op='~' expr=EUnaryExpr
+ | {EUnaryExpr} op='!' expr=EUnaryExpr
+// no need for cast, we are are not staticly typed
+// | ECastExpr
+// | EPrimaryExpr selector* ('++'|'--')?
+ | EPrimaryExpr
+;
+
+EPrimaryExpr returns EExpr:
+ '(' EExpr ')'
+ | EVariableExpr
+ | EFuncExpr
+ | EInnerElement
+ | ELiteralExpr
+;
+
+EFuncExpr:
+ name=Identifier '(' arguments+=EExpr (',' arguments+=EExpr)* ')'
+;
+
+EVariableExpr:
+ name=VARIABLE
+;
+
+ELiteralExpr:
+ EHexLiteralExpr
+ | EOctalLiteralExpr
+ | EDecimalLiteralExpr
+ | EFloatingPointLiteralExpr
+ | ECharacterLiteralExpr
+ | EStringLiteralExpr
+ | EBooleanLiteralExpr
+ | ENullExpr
+;
+
+ENullExpr:
+ value='null'
+;
+
+EHexLiteralExpr:
+ value=HexLiteral
+;
+
+EOctalLiteralExpr:
+ value=OctalLiteral
+;
+
+EDecimalLiteralExpr:
+ value=DecimalLiteral
+;
+
+EFloatingPointLiteralExpr:
+ value=FloatingPointLiteral
+;
+
+ECharacterLiteralExpr:
+ value=CharacterLiteral
+;
+
+EStringLiteralExpr:
+ value=StringLiteral
+;
+
+EBooleanLiteralExpr:
+ value='true'
+ | value='false'
+;
+
+terminal HexLiteral:
+ '0' ('x'|'X') HexDigit+ IntegerTypeSuffix?
+;
+
+terminal DecimalLiteral:
+ ('0' | '1'..'9' '0'..'9'*) IntegerTypeSuffix?
+;
+
+terminal OctalLiteral:
+ '0' ('0'..'7')+ IntegerTypeSuffix?
+;
+
+terminal fragment HexDigit:
+ ('0'..'9'|'a'..'f'|'A'..'F')
+;
+
+terminal fragment IntegerTypeSuffix:
+ ('l'|'L')
+;
+
+terminal FloatingPointLiteral:
+ ('0'..'9')+ '.' ('0'..'9')* Exponent? FloatTypeSuffix?
+ | '.' ('0'..'9')+ Exponent? FloatTypeSuffix?
+ | ('0'..'9')+ Exponent FloatTypeSuffix?
+ | ('0'..'9')+ FloatTypeSuffix
+;
+
+terminal fragment Exponent:
+ ('e'|'E') ('+'|'-')? ('0'..'9')+
+;
+
+terminal fragment FloatTypeSuffix:
+ ('f'|'F'|'d'|'D')
+;
+
+terminal CharacterLiteral:
+ '\'' ( EscapeSequence | !('\''|'\\') ) '\''
+;
+
+terminal StringLiteral:
+ '"' ( EscapeSequence | !('\\'|'"') )* '"'
+;
+
+terminal fragment EscapeSequence:
+ '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\')
+ | UnicodeEscape
+ | OctalEscape
+;
+
+terminal fragment OctalEscape:
+ '\\' ('0'..'3') ('0'..'7') ('0'..'7')
+ | '\\' ('0'..'7') ('0'..'7')
+ | '\\' ('0'..'7')
+;
+
+terminal fragment UnicodeEscape:
+ '\\' 'u' HexDigit HexDigit HexDigit HexDigit
+;
+
+terminal Identifier:
+ Letter (Letter|JavaIDDigit)*
+ | '`' !('`')+ '`'
+;
+
+terminal fragment Letter:
+ '\u0024'
+ | '\u0041'..'\u005a'
+ | '\u005f'
+ | '\u0061'..'\u007a'
+ | '\u00c0'..'\u00d6'
+ | '\u00d8'..'\u00f6'
+ | '\u00f8'..'\u00ff'
+ | '\u0100'..'\u1fff'
+ | '\u3040'..'\u318f'
+ | '\u3300'..'\u337f'
+ | '\u3400'..'\u3d2d'
+ | '\u4e00'..'\u9fff'
+ | '\uf900'..'\ufaff'
+;
+
+terminal fragment JavaIDDigit:
+ '\u0030'..'\u0039'
+ | '\u0660'..'\u0669'
+ | '\u06f0'..'\u06f9'
+ | '\u0966'..'\u096f'
+ | '\u09e6'..'\u09ef'
+ | '\u0a66'..'\u0a6f'
+ | '\u0ae6'..'\u0aef'
+ | '\u0b66'..'\u0b6f'
+ | '\u0be7'..'\u0bef'
+ | '\u0c66'..'\u0c6f'
+ | '\u0ce6'..'\u0cef'
+ | '\u0d66'..'\u0d6f'
+ | '\u0e50'..'\u0e59'
+ | '\u0ed0'..'\u0ed9'
+ | '\u1040'..'\u1049'
+;
+
+//// End of copy of Java grammar
terminal VARIABLE:
- '$' ( NAME | '{' !('}')+ '}');
+ '$' ( Identifier | '{' !('}')+ '}' )
+;
terminal DOC:
- ( '%' !('\n'|'\r')* '\r'? '\n' )+;
+ ( '@' !('\n'|'\r')* '\r'? '\n' )+
+;
+
+terminal ML_COMMENT:
+ '/*' -> '*/'
+;
+
+terminal SL_COMMENT:
+ '//' !('\n'|'\r')* ('\r'? '\n')?
+;
+
+terminal WS:
+ (' '|'\t'|'\r'|'\n')+
+;