[jboss-svn-commits] JBL Code SVN: r10542 - in labs/jbossrules/trunk: drools-clips and 24 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Mar 26 18:20:56 EDT 2007


Author: mark.proctor at jboss.com
Date: 2007-03-26 18:20:56 -0400 (Mon, 26 Mar 2007)
New Revision: 10542

Added:
   labs/jbossrules/trunk/drools-clips/
   labs/jbossrules/trunk/drools-clips/.classpath
   labs/jbossrules/trunk/drools-clips/.project
   labs/jbossrules/trunk/drools-clips/build.properties
   labs/jbossrules/trunk/drools-clips/pom.xml
   labs/jbossrules/trunk/drools-clips/src/
   labs/jbossrules/trunk/drools-clips/src/main/
   labs/jbossrules/trunk/drools-clips/src/main/java/
   labs/jbossrules/trunk/drools-clips/src/main/java/org/
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/BlockExecutionEngine.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/BuiltinFunctions.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPEval.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPFactory.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPLexer.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPParser.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPPredicate.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPReturnValue.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/Deffunction.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/ExecutionBuildContext.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/ExecutionContext.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/ExecutionEngine.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/ExpressionExecutionEngine.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/Function.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/FunctionDelegator.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/FunctionRegistry.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/GeneralParseException.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/LispData.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/LispForm.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/LispList.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/ValueHandler.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/VariableValueHandler.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/AddFunction.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/BaseFunction.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/BindFunction.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/CreateListFunction.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/ForeachFunction.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/IfFunction.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/LessThanFunction.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/ModifyFunction.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/MultiplyFunction.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/SwitchCaseFunction.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/SwitchFunction.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/WhileFunction.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/BaseValueHandler.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/BooleanValueHandler.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/CLPGlobalVariable.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/CLPLocalDeclarationVariable.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/CLPPreviousDeclarationVariable.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/DoubleValueHandler.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/FunctionCaller.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/ListValueHandler.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/LocalVariableValue.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/LongValueHandler.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/ObjectValueHandler.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/TempTokenVariable.java
   labs/jbossrules/trunk/drools-clips/src/main/resources/
   labs/jbossrules/trunk/drools-clips/src/main/resources/org/
   labs/jbossrules/trunk/drools-clips/src/main/resources/org/drools/
   labs/jbossrules/trunk/drools-clips/src/main/resources/org/drools/clp/
   labs/jbossrules/trunk/drools-clips/src/main/resources/org/drools/clp/CLP.g
   labs/jbossrules/trunk/drools-clips/src/main/resources/org/drools/clp/functions.conf
   labs/jbossrules/trunk/drools-clips/src/test/
   labs/jbossrules/trunk/drools-clips/src/test/java/
   labs/jbossrules/trunk/drools-clips/src/test/java/org/
   labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/
   labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/
   labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/AddFunctionTest.java
   labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/BlockExecutionTest.java
   labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/ClpParserTest.java
   labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/CompiledParserTest.java
   labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/DeffunctionTest.java
   labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/FunctionFactoryTest.java
   labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/ModifyFunctionTest.java
   labs/jbossrules/trunk/drools-clips/src/test/resources/
   labs/jbossrules/trunk/drools-clips/src/test/resources/org/
   labs/jbossrules/trunk/drools-clips/src/test/resources/org/drools/
   labs/jbossrules/trunk/drools-clips/src/test/resources/org/drools/clp/
Removed:
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/AddFunction.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/BindFunction.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/LessThanFunction.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/ModifyFunction.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/MultiplyFunction.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/BaseValueHandler.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/BooleanValueHandler.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/CLPGlobalVariable.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/CLPLocalDeclarationVariable.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/CLPPreviousDeclarationVariable.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/DoubleValueHandler.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/FunctionCaller.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/ListValueHandler.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/LocalVariableValue.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/LongValueHandler.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/ObjectValueHandler.java
   labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/TempTokenVariable.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/
   labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/clp/
   labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/clp/
Modified:
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ValueType.java
Log:
-JBRULES-720 Clips Parser
-Refactored clips to its own module, drools-clips

Added: labs/jbossrules/trunk/drools-clips/.classpath
===================================================================
--- labs/jbossrules/trunk/drools-clips/.classpath	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/.classpath	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry kind="src" path="src/main/resources"/>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="var" path="M2_REPO/janino/janino/2.5.5/janino-2.5.5.jar"/>
+	<classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar"/>
+	<classpathentry kind="var" path="M2_REPO/xstream/xstream/1.1.3/xstream-1.1.3.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/eclipse/jdt/core/3.2.1.v_677_R32x/core-3.2.1.v_677_R32x.jar"/>
+	<classpathentry kind="var" path="M2_REPO/xpp3/xpp3/1.1.3.4.O/xpp3-1.1.3.4.O.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/mvel/mvel14/1.2beta13/mvel14-1.2beta13.jar"/>
+	<classpathentry kind="var" path="M2_REPO/antlr/antlr/2.7.7/antlr-2.7.7.jar"/>
+	<classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
+	<classpathentry kind="var" path="M2_REPO/antlr/stringtemplate/3.0/stringtemplate-3.0.jar"/>
+	<classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.4.0/xercesImpl-2.4.0.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/antlr/antlr/3.0b5/antlr-3.0b5.jar"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/drools-compiler"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/drools-core"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

Added: labs/jbossrules/trunk/drools-clips/.project
===================================================================
--- labs/jbossrules/trunk/drools-clips/.project	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/.project	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,14 @@
+<projectDescription>
+  <name>drools-clips</name>
+  <comment>A rule production system</comment>
+  <projects/>
+  <buildSpec>
+    <buildCommand>
+      <name>org.eclipse.jdt.core.javabuilder</name>
+      <arguments/>
+    </buildCommand>
+  </buildSpec>
+  <natures>
+    <nature>org.eclipse.jdt.core.javanature</nature>
+  </natures>
+</projectDescription>
\ No newline at end of file

Added: labs/jbossrules/trunk/drools-clips/build.properties
===================================================================
--- labs/jbossrules/trunk/drools-clips/build.properties	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/build.properties	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,19 @@
+bin.includes = META-INF/,\
+               icons/,\
+               lib/,\
+               drools-compiler.jar
+src.includes = META-INF/,\
+               build.properties,\
+               .classpath,\
+               .project,\
+               icons/
+jars.compile.order = drools-compiler.jar
+source.drools-compiler.jar = src/main/java/
+output.drools-compiler.jar = target/classes/
+jars.extra.classpath = lib/antlr-2.7.6.jar,\
+                       lib/antlr3-3.0ea7.jar,\
+                       lib/commons-lang-2.1.jar,\
+                       lib/commons-logging-api-1.0.4.jar,\
+                       lib/jci-SNAPSHOT-378493.jar,\
+                       lib/jdtcore-3.1.0.jar,\
+                       lib/stringtemplate-2.2-20060301.jar

Added: labs/jbossrules/trunk/drools-clips/pom.xml
===================================================================
--- labs/jbossrules/trunk/drools-clips/pom.xml	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/pom.xml	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <artifactId>drools</artifactId>
+    <groupId>org.drools</groupId>
+	  <version>3.1.0-M1</version>
+  </parent>
+
+  <artifactId>drools-clips</artifactId>
+  <packaging>jar</packaging>
+  <name>Drools :: Clips</name>
+
+  <repositories>
+    <repository>
+      <id>basedir</id>
+      <url>file://${basedir}/../repository</url>
+    </repository>
+  </repositories>
+
+  <build/>
+
+  <dependencies>
+    <!-- Internal dependencies -->
+    <dependency>
+      <groupId>org.drools</groupId>
+      <artifactId>drools-compiler</artifactId>
+    </dependency>      
+  </dependencies>
+
+</project>

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/BlockExecutionEngine.java (from rev 10524, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/BlockExecutionEngine.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/BlockExecutionEngine.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/BlockExecutionEngine.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,85 @@
+package org.drools.clp;
+
+import java.util.Map;
+
+import org.drools.WorkingMemory;
+import org.drools.clp.valuehandlers.FunctionCaller;
+import org.drools.common.InternalWorkingMemory;
+import org.drools.reteoo.ReteTuple;
+import org.drools.spi.Consequence;
+import org.drools.spi.KnowledgeHelper;
+
+public class BlockExecutionEngine
+    implements
+    Consequence,
+    ExecutionEngine {
+    //private Map variableMap = new HashMap();
+
+    private FunctionCaller[] functions;
+
+    private int              index;
+
+    public void addFunction(FunctionCaller function) {
+        if ( this.functions == null ) {
+            this.functions = new FunctionCaller[]{function};
+        } else {
+            FunctionCaller[] temp = new FunctionCaller[functions.length + 1];
+            System.arraycopy( this.functions,
+                              0,
+                              temp,
+                              0,
+                              this.functions.length );
+            temp[temp.length - 1] = function;
+            this.functions = temp;
+        }
+    }
+
+    public FunctionCaller[] getFunctions() {
+        return this.functions;
+    }
+
+    public int getNextIndex() {
+        return this.index++;
+    }
+
+    public void execute(InternalWorkingMemory workingMemory,
+                        ReteTuple tuple,
+                        Object object) {
+        execute( new ExecutionContext( workingMemory,
+                                       tuple,
+                                       object,
+                                       this.index - 1 ) );
+    }
+
+    public void execute(InternalWorkingMemory workingMemory,
+                        ReteTuple tuple) {
+        execute( new ExecutionContext( workingMemory,
+                                       tuple,
+                                       this.index - 1 ) );
+    }
+
+    public void execute(ExecutionContext context) {
+        if ( this.functions == null ) {
+            return;
+        }
+
+        for ( int i = 0, length = functions.length; i < length; i++ ) {
+            this.functions[i].getValue( context );
+        }
+    }
+
+    public void evaluate(KnowledgeHelper knowledgeHelper,
+                         WorkingMemory workingMemory) throws Exception {
+        ExecutionContext context = new ExecutionContext( (InternalWorkingMemory) workingMemory,
+                                                         (ReteTuple) knowledgeHelper.getTuple(),
+                                                         this.index - 1 );
+        execute( context );
+    }
+
+    public void replaceTempTokens(Map variables) {
+        for ( int i = 0, length = functions.length; i < length; i++ ) {
+            this.functions[i].replaceTempTokens( variables );
+        }
+    }
+
+}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/BuiltinFunctions.java (from rev 10524, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/BuiltinFunctions.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/BuiltinFunctions.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/BuiltinFunctions.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,57 @@
+package org.drools.clp;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.HashMap;
+import java.util.Map;
+
+public class BuiltinFunctions {
+    public static final BuiltinFunctions instance = new BuiltinFunctions();
+
+    public static BuiltinFunctions getInstance() {
+        return instance;
+    }
+
+    public Map functions;
+
+    private BuiltinFunctions() {
+        this.functions = new HashMap();
+
+        try {
+            loadFunctions();
+        } catch ( IOException e ) {
+            throw new RuntimeException( e );
+        } catch ( ClassNotFoundException e ) {
+            throw new RuntimeException( e );
+        }
+    }
+
+    public void loadFunctions() throws IOException,
+                               ClassNotFoundException {
+        BufferedReader reader = new BufferedReader( new InputStreamReader( getClass().getResourceAsStream( "functions.conf" ) ) );
+        loadFunctions( reader );
+    }
+
+    public void loadFunctions(BufferedReader reader) throws IOException,
+                                                    ClassNotFoundException {
+        String line = null;
+
+        try {
+            while ( (line = reader.readLine()) != null ) {
+                Class clazz = getClass().getClassLoader().loadClass( line );
+                Function function = (Function) clazz.newInstance();
+                this.functions.put( function.getName(),
+                                    function );
+            }
+        } catch ( IllegalAccessException e ) {
+            throw new RuntimeException( e );
+        } catch ( InstantiationException e ) {
+            throw new RuntimeException( e );
+        }
+    }
+
+    public Function getFunction(String name) {
+        return (Function) this.functions.get( name );
+    }
+}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPEval.java (from rev 10524, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/CLPEval.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPEval.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPEval.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,60 @@
+/**
+ * 
+ */
+package org.drools.clp;
+
+import java.util.Map;
+
+import org.drools.WorkingMemory;
+import org.drools.clp.valuehandlers.FunctionCaller;
+import org.drools.common.InternalWorkingMemory;
+import org.drools.reteoo.ReteTuple;
+import org.drools.rule.Declaration;
+import org.drools.spi.EvalExpression;
+import org.drools.spi.Tuple;
+
+public class CLPEval
+    implements
+    EvalExpression,
+    ExecutionEngine {
+    private FunctionCaller function;
+    private int            index;
+
+    public CLPEval() {
+
+    }
+
+    public CLPEval(FunctionCaller function) {
+        this.function = function;
+    }
+
+    public void setFunction(FunctionCaller function) {
+        this.function = function;
+    }
+
+    public void addFunction(FunctionCaller function) {
+        setFunction( function );
+    }
+
+    public FunctionCaller[] getFunctions() {
+        return new FunctionCaller[]{this.function};
+    }
+
+    public int getNextIndex() {
+        return this.index++;
+    }
+
+    public boolean evaluate(Tuple tuple,
+                            Declaration[] requiredDeclarations,
+                            WorkingMemory workingMemory) throws Exception {
+        ExecutionContext context = new ExecutionContext( (InternalWorkingMemory) workingMemory,
+                                                         (ReteTuple) tuple,
+                                                         this.index - 1 );
+        return this.function.getBooleanValue( context );
+    }
+
+    public void replaceTempTokens(Map variables) {
+        this.function.replaceTempTokens( variables );
+    }
+
+}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPFactory.java (from rev 10519, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/CLPFactory.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPFactory.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPFactory.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,138 @@
+package org.drools.clp;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.drools.WorkingMemory;
+import org.drools.base.ValueType;
+import org.drools.clp.valuehandlers.CLPGlobalVariable;
+import org.drools.clp.valuehandlers.CLPLocalDeclarationVariable;
+import org.drools.clp.valuehandlers.CLPPreviousDeclarationVariable;
+import org.drools.rule.Declaration;
+import org.drools.spi.Tuple;
+import org.mvel.integration.VariableResolver;
+
+public class CLPFactory {
+    private Tuple         tuple;
+    private Object        object;
+    private Map           localDeclarations;
+    private Map           previousDeclarations;
+    private Map           globals;
+
+    private Map           resolvers;
+    //private
+    private WorkingMemory workingMemory;
+
+    public CLPFactory() {
+        this.resolvers = Collections.EMPTY_MAP;
+    }
+
+    public CLPFactory(Map previousDeclarations,
+                      Map localDeclarations,
+                      Map globals) {
+
+    }
+
+    public void setPreviousDeclarationMap(Map declarations) {
+        this.previousDeclarations = declarations;
+    }
+
+    public void setLocalDeclarationMap(Map declarations) {
+        this.localDeclarations = declarations;
+    }
+
+    public void setGlobalsMap(Map globals) {
+        this.globals = globals;
+    }
+
+    public Object getObject() {
+        return this.object;
+    }
+
+    public void setContext(Tuple tuple,
+                           Object object,
+                           WorkingMemory workingMemory) {
+        this.tuple = tuple;
+        this.object = object;
+        this.workingMemory = workingMemory;
+    }
+
+    public Object getValue(Declaration declaration) {
+        return tuple.get( declaration ).getObject();
+    }
+
+    public Object getValue(String identifier) {
+        return this.workingMemory.getGlobal( identifier );
+    }
+
+    public VariableResolver createVariable(String name,
+                                           Object value) {
+        throw new UnsupportedOperationException( "Variables cannot be created here" );
+    }
+
+    //    public ValueHandler getVariableResolver(String name) {
+    //        return (ValueHandler) this.resolvers.get( name );
+    //    }
+
+    public ValueHandler getVariableResolver(String name) {
+        //return this.declarations.containsKey( name ) || this.globals.containsKey( name );
+        if ( this.resolvers == Collections.EMPTY_MAP ) {
+            this.resolvers = new HashMap();
+        }
+
+        ValueHandler resolver = (ValueHandler) this.resolvers.get( name );
+
+        if ( resolver != null ) {
+            return null;
+        }
+
+        if ( this.previousDeclarations != null && this.previousDeclarations.containsKey( name ) ) {
+            resolver = new CLPPreviousDeclarationVariable( (Declaration) this.previousDeclarations.get( name ) );
+        } else if ( this.localDeclarations != null && this.localDeclarations.containsKey( name ) ) {
+            resolver = new CLPLocalDeclarationVariable( (Declaration) this.localDeclarations.get( name ) );
+        } else {
+            Class clazz = (Class) this.globals.get( name );
+            resolver = new CLPGlobalVariable( name,
+                                              clazz,
+                                              ValueType.determineValueType( clazz ).getSimpleType(),
+                                              this );
+        }
+
+        if ( resolver != null ) {
+            this.resolvers.put( name,
+                                resolver );
+            return resolver;
+        } else {
+            return null;
+        }
+    }
+
+    //    public boolean isTarget(String name) {
+    //        return this.resolvers.containsKey( name );
+    //    }
+
+    //    public ValueHandler createExternalVariable(String identifier) {        
+    //        registerExternalVariable( identifier );
+    //        ValueHandler variable;
+    //        if ( this.declarations.containsKey( identifier )) {
+    //            variable = new DroolsMVELDeclarationVariable( (Declaration) this.declarations.get( identifier ), this );
+    //        } else {
+    //            variable = new DroolsMVELGlobalVariable( identifier, (Class) this.globals.get( identifier ), this );
+    //        }
+    //        return variable;
+    //    	return null;
+    //    }
+    //
+    //    public boolean isValidVariable(String identifier) {        
+    //        return this.declarations.containsKey( identifier );
+    //    }   
+    //    
+    //    public Declaration[] getRequiredDeclarations()  {
+    //        List list = new ArrayList();
+    //        for (int i  = 0, length  = this.requiredVariables.length; i < length; i++) {
+    //            list.add( this.declarations.get( this.requiredVariables[i] ) );
+    //        }
+    //        return (Declaration[]) list.toArray( new Declaration[list.size()  ]  );
+    //    }
+}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPLexer.java (from rev 10524, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/CLPLexer.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPLexer.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPLexer.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,2580 @@
+// $ANTLR 3.0b7 C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g 2007-03-24 20:05:52
+
+package org.drools.clp;
+
+import java.util.HashMap;
+
+import org.antlr.runtime.BaseRecognizer;
+import org.antlr.runtime.CharStream;
+import org.antlr.runtime.DFA;
+import org.antlr.runtime.EarlyExitException;
+import org.antlr.runtime.Lexer;
+import org.antlr.runtime.MismatchedSetException;
+import org.antlr.runtime.NoViableAltException;
+import org.antlr.runtime.RecognitionException;
+import org.antlr.runtime.Token;
+
+public class CLPLexer extends Lexer {
+    public static final int EXISTS                       = 14;
+    public static final int LEFT_PAREN                   = 4;
+    public static final int RIGHT_CURLY                  = 39;
+    public static final int BOOL                         = 24;
+    public static final int DEFRULE                      = 5;
+    public static final int HexDigit                     = 30;
+    public static final int WS                           = 27;
+    public static final int STRING                       = 7;
+    public static final int FLOAT                        = 23;
+    public static final int TILDE                        = 20;
+    public static final int OR                           = 12;
+    public static final int PIPE                         = 19;
+    public static final int EQUALS                       = 22;
+    public static final int VAR                          = 16;
+    public static final int ASSIGN_OP                    = 17;
+    public static final int AND                          = 11;
+    public static final int UnicodeEscape                = 31;
+    public static final int EscapeSequence               = 29;
+    public static final int INT                          = 10;
+    public static final int EOF                          = -1;
+    public static final int NULL                         = 25;
+    public static final int EOL                          = 26;
+    public static final int SYMBOL                       = 33;
+    public static final int LEFT_SQUARE                  = 36;
+    public static final int Tokens                       = 42;
+    public static final int COLON                        = 21;
+    public static final int SALIENCE                     = 9;
+    public static final int OctalEscape                  = 32;
+    public static final int SH_STYLE_SINGLE_LINE_COMMENT = 34;
+    public static final int MULTI_LINE_COMMENT           = 40;
+    public static final int AMPERSAND                    = 18;
+    public static final int TEST                         = 15;
+    public static final int NAME                         = 6;
+    public static final int T41                          = 41;
+    public static final int NOT                          = 13;
+    public static final int RIGHT_PAREN                  = 8;
+    public static final int DECLARE                      = 28;
+    public static final int LEFT_CURLY                   = 38;
+    public static final int RIGHT_SQUARE                 = 37;
+    public static final int C_STYLE_SINGLE_LINE_COMMENT  = 35;
+
+    public CLPLexer() {
+        ;
+    }
+
+    public CLPLexer(CharStream input) {
+        super( input );
+        ruleMemo = new HashMap[40 + 1];
+    }
+
+    public String getGrammarFileName() {
+        return "C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g";
+    }
+
+    // $ANTLR start T41
+    public void mT41() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = T41;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:6:7: ( '=>' )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:6:7: '=>'
+            {
+                match( "=>" );
+                if ( failed ) return;
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end T41
+
+    // $ANTLR start WS
+    public void mWS() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = WS;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:554:17: ( ( ' ' | '\\t' | '\\f' | EOL ) )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:554:17: ( ' ' | '\\t' | '\\f' | EOL )
+            {
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:554:17: ( ' ' | '\\t' | '\\f' | EOL )
+                int alt1 = 4;
+                switch ( input.LA( 1 ) ) {
+                    case ' ' :
+                        alt1 = 1;
+                        break;
+                    case '\t' :
+                        alt1 = 2;
+                        break;
+                    case '\f' :
+                        alt1 = 3;
+                        break;
+                    case '\n' :
+                    case '\r' :
+                        alt1 = 4;
+                        break;
+                    default :
+                        if ( backtracking > 0 ) {
+                            failed = true;
+                            return;
+                        }
+                        NoViableAltException nvae = new NoViableAltException( "554:17: ( ' ' | '\\t' | '\\f' | EOL )",
+                                                                              1,
+                                                                              0,
+                                                                              input );
+
+                        throw nvae;
+                }
+
+                switch ( alt1 ) {
+                    case 1 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:554:19: ' '
+                    {
+                        match( ' ' );
+                        if ( failed ) return;
+
+                    }
+                        break;
+                    case 2 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:555:19: '\\t'
+                    {
+                        match( '\t' );
+                        if ( failed ) return;
+
+                    }
+                        break;
+                    case 3 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:556:19: '\\f'
+                    {
+                        match( '\f' );
+                        if ( failed ) return;
+
+                    }
+                        break;
+                    case 4 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:557:19: EOL
+                    {
+                        mEOL();
+                        if ( failed ) return;
+
+                    }
+                        break;
+
+                }
+
+                if ( backtracking == 0 ) {
+                    _channel = HIDDEN;
+                }
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end WS
+
+    // $ANTLR start DEFRULE
+    public void mDEFRULE() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = DEFRULE;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:562:11: ( 'defrule' )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:562:11: 'defrule'
+            {
+                match( "defrule" );
+                if ( failed ) return;
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end DEFRULE
+
+    // $ANTLR start OR
+    public void mOR() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = OR;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:563:7: ( 'or' )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:563:7: 'or'
+            {
+                match( "or" );
+                if ( failed ) return;
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end OR
+
+    // $ANTLR start AND
+    public void mAND() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = AND;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:564:8: ( 'and' )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:564:8: 'and'
+            {
+                match( "and" );
+                if ( failed ) return;
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end AND
+
+    // $ANTLR start NOT
+    public void mNOT() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = NOT;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:565:8: ( 'not' )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:565:8: 'not'
+            {
+                match( "not" );
+                if ( failed ) return;
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end NOT
+
+    // $ANTLR start EXISTS
+    public void mEXISTS() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = EXISTS;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:566:11: ( 'exists' )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:566:11: 'exists'
+            {
+                match( "exists" );
+                if ( failed ) return;
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end EXISTS
+
+    // $ANTLR start TEST
+    public void mTEST() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = TEST;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:567:9: ( 'test' )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:567:9: 'test'
+            {
+                match( "test" );
+                if ( failed ) return;
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end TEST
+
+    // $ANTLR start NULL
+    public void mNULL() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = NULL;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:569:8: ( 'null' )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:569:8: 'null'
+            {
+                match( "null" );
+                if ( failed ) return;
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end NULL
+
+    // $ANTLR start DECLARE
+    public void mDECLARE() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = DECLARE;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:571:11: ( 'declare' )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:571:11: 'declare'
+            {
+                match( "declare" );
+                if ( failed ) return;
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end DECLARE
+
+    // $ANTLR start SALIENCE
+    public void mSALIENCE() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = SALIENCE;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:573:11: ( 'salience' )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:573:11: 'salience'
+            {
+                match( "salience" );
+                if ( failed ) return;
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end SALIENCE
+
+    // $ANTLR start EOL
+    public void mEOL() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:579:6: ( ( ( '\\r\\n' )=> '\\r\\n' | '\\r' | '\\n' ) )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:579:6: ( ( '\\r\\n' )=> '\\r\\n' | '\\r' | '\\n' )
+            {
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:579:6: ( ( '\\r\\n' )=> '\\r\\n' | '\\r' | '\\n' )
+                int alt2 = 3;
+                int LA2_0 = input.LA( 1 );
+                if ( (LA2_0 == '\r') ) {
+                    int LA2_1 = input.LA( 2 );
+                    if ( (LA2_1 == '\n') ) {
+                        alt2 = 1;
+                    } else {
+                        alt2 = 2;
+                    }
+                } else if ( (LA2_0 == '\n') ) {
+                    alt2 = 3;
+                } else {
+                    if ( backtracking > 0 ) {
+                        failed = true;
+                        return;
+                    }
+                    NoViableAltException nvae = new NoViableAltException( "579:6: ( ( '\\r\\n' )=> '\\r\\n' | '\\r' | '\\n' )",
+                                                                          2,
+                                                                          0,
+                                                                          input );
+
+                    throw nvae;
+                }
+                switch ( alt2 ) {
+                    case 1 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:579:14: ( '\\r\\n' )=> '\\r\\n'
+                    {
+                        match( "\r\n" );
+                        if ( failed ) return;
+
+                    }
+                        break;
+                    case 2 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:580:25: '\\r'
+                    {
+                        match( '\r' );
+                        if ( failed ) return;
+
+                    }
+                        break;
+                    case 3 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:581:25: '\\n'
+                    {
+                        match( '\n' );
+                        if ( failed ) return;
+
+                    }
+                        break;
+
+                }
+
+            }
+
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end EOL
+
+    // $ANTLR start INT
+    public void mINT() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = INT;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:586:4: ( ( '-' )? ( '0' .. '9' )+ )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:586:4: ( '-' )? ( '0' .. '9' )+
+            {
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:586:4: ( '-' )?
+                int alt3 = 2;
+                int LA3_0 = input.LA( 1 );
+                if ( (LA3_0 == '-') ) {
+                    alt3 = 1;
+                }
+                switch ( alt3 ) {
+                    case 1 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:586:5: '-'
+                    {
+                        match( '-' );
+                        if ( failed ) return;
+
+                    }
+                        break;
+
+                }
+
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:586:10: ( '0' .. '9' )+
+                int cnt4 = 0;
+                loop4 : do {
+                    int alt4 = 2;
+                    int LA4_0 = input.LA( 1 );
+                    if ( ((LA4_0 >= '0' && LA4_0 <= '9')) ) {
+                        alt4 = 1;
+                    }
+
+                    switch ( alt4 ) {
+                        case 1 :
+                            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:586:11: '0' .. '9'
+                        {
+                            matchRange( '0',
+                                        '9' );
+                            if ( failed ) return;
+
+                        }
+                            break;
+
+                        default :
+                            if ( cnt4 >= 1 ) break loop4;
+                            if ( backtracking > 0 ) {
+                                failed = true;
+                                return;
+                            }
+                            EarlyExitException eee = new EarlyExitException( 4,
+                                                                             input );
+                            throw eee;
+                    }
+                    cnt4++;
+                } while ( true );
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end INT
+
+    // $ANTLR start FLOAT
+    public void mFLOAT() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = FLOAT;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:590:4: ( ( '-' )? ( '0' .. '9' )+ '.' ( '0' .. '9' )+ )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:590:4: ( '-' )? ( '0' .. '9' )+ '.' ( '0' .. '9' )+
+            {
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:590:4: ( '-' )?
+                int alt5 = 2;
+                int LA5_0 = input.LA( 1 );
+                if ( (LA5_0 == '-') ) {
+                    alt5 = 1;
+                }
+                switch ( alt5 ) {
+                    case 1 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:590:5: '-'
+                    {
+                        match( '-' );
+                        if ( failed ) return;
+
+                    }
+                        break;
+
+                }
+
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:590:10: ( '0' .. '9' )+
+                int cnt6 = 0;
+                loop6 : do {
+                    int alt6 = 2;
+                    int LA6_0 = input.LA( 1 );
+                    if ( ((LA6_0 >= '0' && LA6_0 <= '9')) ) {
+                        alt6 = 1;
+                    }
+
+                    switch ( alt6 ) {
+                        case 1 :
+                            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:590:11: '0' .. '9'
+                        {
+                            matchRange( '0',
+                                        '9' );
+                            if ( failed ) return;
+
+                        }
+                            break;
+
+                        default :
+                            if ( cnt6 >= 1 ) break loop6;
+                            if ( backtracking > 0 ) {
+                                failed = true;
+                                return;
+                            }
+                            EarlyExitException eee = new EarlyExitException( 6,
+                                                                             input );
+                            throw eee;
+                    }
+                    cnt6++;
+                } while ( true );
+
+                match( '.' );
+                if ( failed ) return;
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:590:26: ( '0' .. '9' )+
+                int cnt7 = 0;
+                loop7 : do {
+                    int alt7 = 2;
+                    int LA7_0 = input.LA( 1 );
+                    if ( ((LA7_0 >= '0' && LA7_0 <= '9')) ) {
+                        alt7 = 1;
+                    }
+
+                    switch ( alt7 ) {
+                        case 1 :
+                            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:590:27: '0' .. '9'
+                        {
+                            matchRange( '0',
+                                        '9' );
+                            if ( failed ) return;
+
+                        }
+                            break;
+
+                        default :
+                            if ( cnt7 >= 1 ) break loop7;
+                            if ( backtracking > 0 ) {
+                                failed = true;
+                                return;
+                            }
+                            EarlyExitException eee = new EarlyExitException( 7,
+                                                                             input );
+                            throw eee;
+                    }
+                    cnt7++;
+                } while ( true );
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end FLOAT
+
+    // $ANTLR start STRING
+    public void mSTRING() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = STRING;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:594:8: ( ( '\"' ( EscapeSequence | ~ ('\\\\'|'\"'))* '\"' ) | ( '\\'' ( EscapeSequence | ~ ('\\\\'|'\\''))* '\\'' ) )
+            int alt10 = 2;
+            int LA10_0 = input.LA( 1 );
+            if ( (LA10_0 == '\"') ) {
+                alt10 = 1;
+            } else if ( (LA10_0 == '\'') ) {
+                alt10 = 2;
+            } else {
+                if ( backtracking > 0 ) {
+                    failed = true;
+                    return;
+                }
+                NoViableAltException nvae = new NoViableAltException( "593:1: STRING : ( ( '\"' ( EscapeSequence | ~ ('\\\\'|'\"'))* '\"' ) | ( '\\'' ( EscapeSequence | ~ ('\\\\'|'\\''))* '\\'' ) );",
+                                                                      10,
+                                                                      0,
+                                                                      input );
+
+                throw nvae;
+            }
+            switch ( alt10 ) {
+                case 1 :
+                    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:594:8: ( '\"' ( EscapeSequence | ~ ('\\\\'|'\"'))* '\"' )
+                {
+                    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:594:8: ( '\"' ( EscapeSequence | ~ ('\\\\'|'\"'))* '\"' )
+                    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:594:9: '\"' ( EscapeSequence | ~ ('\\\\'|'\"'))* '\"'
+                    {
+                        match( '\"' );
+                        if ( failed ) return;
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:594:13: ( EscapeSequence | ~ ('\\\\'|'\"'))*
+                        loop8 : do {
+                            int alt8 = 3;
+                            int LA8_0 = input.LA( 1 );
+                            if ( (LA8_0 == '\\') ) {
+                                alt8 = 1;
+                            } else if ( ((LA8_0 >= '\u0000' && LA8_0 <= '!') || (LA8_0 >= '#' && LA8_0 <= '[') || (LA8_0 >= ']' && LA8_0 <= '\uFFFE')) ) {
+                                alt8 = 2;
+                            }
+
+                            switch ( alt8 ) {
+                                case 1 :
+                                    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:594:15: EscapeSequence
+                                {
+                                    mEscapeSequence();
+                                    if ( failed ) return;
+
+                                }
+                                    break;
+                                case 2 :
+                                    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:594:32: ~ ('\\\\'|'\"')
+                                {
+                                    if ( (input.LA( 1 ) >= '\u0000' && input.LA( 1 ) <= '!') || (input.LA( 1 ) >= '#' && input.LA( 1 ) <= '[') || (input.LA( 1 ) >= ']' && input.LA( 1 ) <= '\uFFFE') ) {
+                                        input.consume();
+                                        failed = false;
+                                    } else {
+                                        if ( backtracking > 0 ) {
+                                            failed = true;
+                                            return;
+                                        }
+                                        MismatchedSetException mse = new MismatchedSetException( null,
+                                                                                                 input );
+                                        recover( mse );
+                                        throw mse;
+                                    }
+
+                                }
+                                    break;
+
+                                default :
+                                    break loop8;
+                            }
+                        } while ( true );
+
+                        match( '\"' );
+                        if ( failed ) return;
+
+                    }
+
+                }
+                    break;
+                case 2 :
+                    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:595:8: ( '\\'' ( EscapeSequence | ~ ('\\\\'|'\\''))* '\\'' )
+                {
+                    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:595:8: ( '\\'' ( EscapeSequence | ~ ('\\\\'|'\\''))* '\\'' )
+                    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:595:9: '\\'' ( EscapeSequence | ~ ('\\\\'|'\\''))* '\\''
+                    {
+                        match( '\'' );
+                        if ( failed ) return;
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:595:14: ( EscapeSequence | ~ ('\\\\'|'\\''))*
+                        loop9 : do {
+                            int alt9 = 3;
+                            int LA9_0 = input.LA( 1 );
+                            if ( (LA9_0 == '\\') ) {
+                                alt9 = 1;
+                            } else if ( ((LA9_0 >= '\u0000' && LA9_0 <= '&') || (LA9_0 >= '(' && LA9_0 <= '[') || (LA9_0 >= ']' && LA9_0 <= '\uFFFE')) ) {
+                                alt9 = 2;
+                            }
+
+                            switch ( alt9 ) {
+                                case 1 :
+                                    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:595:16: EscapeSequence
+                                {
+                                    mEscapeSequence();
+                                    if ( failed ) return;
+
+                                }
+                                    break;
+                                case 2 :
+                                    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:595:33: ~ ('\\\\'|'\\'')
+                                {
+                                    if ( (input.LA( 1 ) >= '\u0000' && input.LA( 1 ) <= '&') || (input.LA( 1 ) >= '(' && input.LA( 1 ) <= '[') || (input.LA( 1 ) >= ']' && input.LA( 1 ) <= '\uFFFE') ) {
+                                        input.consume();
+                                        failed = false;
+                                    } else {
+                                        if ( backtracking > 0 ) {
+                                            failed = true;
+                                            return;
+                                        }
+                                        MismatchedSetException mse = new MismatchedSetException( null,
+                                                                                                 input );
+                                        recover( mse );
+                                        throw mse;
+                                    }
+
+                                }
+                                    break;
+
+                                default :
+                                    break loop9;
+                            }
+                        } while ( true );
+
+                        match( '\'' );
+                        if ( failed ) return;
+
+                    }
+
+                }
+                    break;
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end STRING
+
+    // $ANTLR start HexDigit
+    public void mHexDigit() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:599:12: ( ('0'..'9'|'a'..'f'|'A'..'F'))
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:599:12: ('0'..'9'|'a'..'f'|'A'..'F')
+            {
+                if ( (input.LA( 1 ) >= '0' && input.LA( 1 ) <= '9') || (input.LA( 1 ) >= 'A' && input.LA( 1 ) <= 'F') || (input.LA( 1 ) >= 'a' && input.LA( 1 ) <= 'f') ) {
+                    input.consume();
+                    failed = false;
+                } else {
+                    if ( backtracking > 0 ) {
+                        failed = true;
+                        return;
+                    }
+                    MismatchedSetException mse = new MismatchedSetException( null,
+                                                                             input );
+                    recover( mse );
+                    throw mse;
+                }
+
+            }
+
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end HexDigit
+
+    // $ANTLR start EscapeSequence
+    public void mEscapeSequence() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:603:9: ( '\\\\' ('b'|'t'|'n'|'f'|'r'|'\\\"'|'\\''|'\\\\') | UnicodeEscape | OctalEscape )
+            int alt11 = 3;
+            int LA11_0 = input.LA( 1 );
+            if ( (LA11_0 == '\\') ) {
+                switch ( input.LA( 2 ) ) {
+                    case 'u' :
+                        alt11 = 2;
+                        break;
+                    case '\"' :
+                    case '\'' :
+                    case '\\' :
+                    case 'b' :
+                    case 'f' :
+                    case 'n' :
+                    case 'r' :
+                    case 't' :
+                        alt11 = 1;
+                        break;
+                    case '0' :
+                    case '1' :
+                    case '2' :
+                    case '3' :
+                    case '4' :
+                    case '5' :
+                    case '6' :
+                    case '7' :
+                        alt11 = 3;
+                        break;
+                    default :
+                        if ( backtracking > 0 ) {
+                            failed = true;
+                            return;
+                        }
+                        NoViableAltException nvae = new NoViableAltException( "601:1: fragment EscapeSequence : ( '\\\\' ('b'|'t'|'n'|'f'|'r'|'\\\"'|'\\''|'\\\\') | UnicodeEscape | OctalEscape );",
+                                                                              11,
+                                                                              1,
+                                                                              input );
+
+                        throw nvae;
+                }
+
+            } else {
+                if ( backtracking > 0 ) {
+                    failed = true;
+                    return;
+                }
+                NoViableAltException nvae = new NoViableAltException( "601:1: fragment EscapeSequence : ( '\\\\' ('b'|'t'|'n'|'f'|'r'|'\\\"'|'\\''|'\\\\') | UnicodeEscape | OctalEscape );",
+                                                                      11,
+                                                                      0,
+                                                                      input );
+
+                throw nvae;
+            }
+            switch ( alt11 ) {
+                case 1 :
+                    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:603:9: '\\\\' ('b'|'t'|'n'|'f'|'r'|'\\\"'|'\\''|'\\\\')
+                {
+                    match( '\\' );
+                    if ( failed ) return;
+                    if ( input.LA( 1 ) == '\"' || input.LA( 1 ) == '\'' || input.LA( 1 ) == '\\' || input.LA( 1 ) == 'b' || input.LA( 1 ) == 'f' || input.LA( 1 ) == 'n' || input.LA( 1 ) == 'r' || input.LA( 1 ) == 't' ) {
+                        input.consume();
+                        failed = false;
+                    } else {
+                        if ( backtracking > 0 ) {
+                            failed = true;
+                            return;
+                        }
+                        MismatchedSetException mse = new MismatchedSetException( null,
+                                                                                 input );
+                        recover( mse );
+                        throw mse;
+                    }
+
+                }
+                    break;
+                case 2 :
+                    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:604:9: UnicodeEscape
+                {
+                    mUnicodeEscape();
+                    if ( failed ) return;
+
+                }
+                    break;
+                case 3 :
+                    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:605:9: OctalEscape
+                {
+                    mOctalEscape();
+                    if ( failed ) return;
+
+                }
+                    break;
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end EscapeSequence
+
+    // $ANTLR start OctalEscape
+    public void mOctalEscape() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:610:9: ( '\\\\' ( '0' .. '3' ) ( '0' .. '7' ) ( '0' .. '7' ) | '\\\\' ( '0' .. '7' ) ( '0' .. '7' ) | '\\\\' ( '0' .. '7' ) )
+            int alt12 = 3;
+            int LA12_0 = input.LA( 1 );
+            if ( (LA12_0 == '\\') ) {
+                int LA12_1 = input.LA( 2 );
+                if ( ((LA12_1 >= '0' && LA12_1 <= '3')) ) {
+                    int LA12_2 = input.LA( 3 );
+                    if ( ((LA12_2 >= '0' && LA12_2 <= '7')) ) {
+                        int LA12_5 = input.LA( 4 );
+                        if ( ((LA12_5 >= '0' && LA12_5 <= '7')) ) {
+                            alt12 = 1;
+                        } else {
+                            alt12 = 2;
+                        }
+                    } else {
+                        alt12 = 3;
+                    }
+                } else if ( ((LA12_1 >= '4' && LA12_1 <= '7')) ) {
+                    int LA12_3 = input.LA( 3 );
+                    if ( ((LA12_3 >= '0' && LA12_3 <= '7')) ) {
+                        alt12 = 2;
+                    } else {
+                        alt12 = 3;
+                    }
+                } else {
+                    if ( backtracking > 0 ) {
+                        failed = true;
+                        return;
+                    }
+                    NoViableAltException nvae = new NoViableAltException( "608:1: fragment OctalEscape : ( '\\\\' ( '0' .. '3' ) ( '0' .. '7' ) ( '0' .. '7' ) | '\\\\' ( '0' .. '7' ) ( '0' .. '7' ) | '\\\\' ( '0' .. '7' ) );",
+                                                                          12,
+                                                                          1,
+                                                                          input );
+
+                    throw nvae;
+                }
+            } else {
+                if ( backtracking > 0 ) {
+                    failed = true;
+                    return;
+                }
+                NoViableAltException nvae = new NoViableAltException( "608:1: fragment OctalEscape : ( '\\\\' ( '0' .. '3' ) ( '0' .. '7' ) ( '0' .. '7' ) | '\\\\' ( '0' .. '7' ) ( '0' .. '7' ) | '\\\\' ( '0' .. '7' ) );",
+                                                                      12,
+                                                                      0,
+                                                                      input );
+
+                throw nvae;
+            }
+            switch ( alt12 ) {
+                case 1 :
+                    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:610:9: '\\\\' ( '0' .. '3' ) ( '0' .. '7' ) ( '0' .. '7' )
+                {
+                    match( '\\' );
+                    if ( failed ) return;
+                    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:610:14: ( '0' .. '3' )
+                    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:610:15: '0' .. '3'
+                    {
+                        matchRange( '0',
+                                    '3' );
+                        if ( failed ) return;
+
+                    }
+
+                    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:610:25: ( '0' .. '7' )
+                    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:610:26: '0' .. '7'
+                    {
+                        matchRange( '0',
+                                    '7' );
+                        if ( failed ) return;
+
+                    }
+
+                    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:610:36: ( '0' .. '7' )
+                    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:610:37: '0' .. '7'
+                    {
+                        matchRange( '0',
+                                    '7' );
+                        if ( failed ) return;
+
+                    }
+
+                }
+                    break;
+                case 2 :
+                    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:611:9: '\\\\' ( '0' .. '7' ) ( '0' .. '7' )
+                {
+                    match( '\\' );
+                    if ( failed ) return;
+                    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:611:14: ( '0' .. '7' )
+                    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:611:15: '0' .. '7'
+                    {
+                        matchRange( '0',
+                                    '7' );
+                        if ( failed ) return;
+
+                    }
+
+                    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:611:25: ( '0' .. '7' )
+                    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:611:26: '0' .. '7'
+                    {
+                        matchRange( '0',
+                                    '7' );
+                        if ( failed ) return;
+
+                    }
+
+                }
+                    break;
+                case 3 :
+                    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:612:9: '\\\\' ( '0' .. '7' )
+                {
+                    match( '\\' );
+                    if ( failed ) return;
+                    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:612:14: ( '0' .. '7' )
+                    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:612:15: '0' .. '7'
+                    {
+                        matchRange( '0',
+                                    '7' );
+                        if ( failed ) return;
+
+                    }
+
+                }
+                    break;
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end OctalEscape
+
+    // $ANTLR start UnicodeEscape
+    public void mUnicodeEscape() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:617:9: ( '\\\\' 'u' HexDigit HexDigit HexDigit HexDigit )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:617:9: '\\\\' 'u' HexDigit HexDigit HexDigit HexDigit
+            {
+                match( '\\' );
+                if ( failed ) return;
+                match( 'u' );
+                if ( failed ) return;
+                mHexDigit();
+                if ( failed ) return;
+                mHexDigit();
+                if ( failed ) return;
+                mHexDigit();
+                if ( failed ) return;
+                mHexDigit();
+                if ( failed ) return;
+
+            }
+
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end UnicodeEscape
+
+    // $ANTLR start BOOL
+    public void mBOOL() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = BOOL;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:621:4: ( ( 'true' | 'false' ) )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:621:4: ( 'true' | 'false' )
+            {
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:621:4: ( 'true' | 'false' )
+                int alt13 = 2;
+                int LA13_0 = input.LA( 1 );
+                if ( (LA13_0 == 't') ) {
+                    alt13 = 1;
+                } else if ( (LA13_0 == 'f') ) {
+                    alt13 = 2;
+                } else {
+                    if ( backtracking > 0 ) {
+                        failed = true;
+                        return;
+                    }
+                    NoViableAltException nvae = new NoViableAltException( "621:4: ( 'true' | 'false' )",
+                                                                          13,
+                                                                          0,
+                                                                          input );
+
+                    throw nvae;
+                }
+                switch ( alt13 ) {
+                    case 1 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:621:5: 'true'
+                    {
+                        match( "true" );
+                        if ( failed ) return;
+
+                    }
+                        break;
+                    case 2 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:621:12: 'false'
+                    {
+                        match( "false" );
+                        if ( failed ) return;
+
+                    }
+                        break;
+
+                }
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end BOOL
+
+    // $ANTLR start VAR
+    public void mVAR() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = VAR;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:624:8: ( '?' ('a'..'z'|'A'..'Z'|'_'|'$') ( SYMBOL )* )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:624:8: '?' ('a'..'z'|'A'..'Z'|'_'|'$') ( SYMBOL )*
+            {
+                match( '?' );
+                if ( failed ) return;
+                if ( input.LA( 1 ) == '$' || (input.LA( 1 ) >= 'A' && input.LA( 1 ) <= 'Z') || input.LA( 1 ) == '_' || (input.LA( 1 ) >= 'a' && input.LA( 1 ) <= 'z') ) {
+                    input.consume();
+                    failed = false;
+                } else {
+                    if ( backtracking > 0 ) {
+                        failed = true;
+                        return;
+                    }
+                    MismatchedSetException mse = new MismatchedSetException( null,
+                                                                             input );
+                    recover( mse );
+                    throw mse;
+                }
+
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:624:38: ( SYMBOL )*
+                loop14 : do {
+                    int alt14 = 2;
+                    int LA14_0 = input.LA( 1 );
+                    if ( ((LA14_0 >= '\u0000' && LA14_0 <= '\b') || (LA14_0 >= '\u000B' && LA14_0 <= '\f') || (LA14_0 >= '\u000E' && LA14_0 <= '\u001F') || LA14_0 == '!' || (LA14_0 >= '#' && LA14_0 <= '%') || LA14_0 == '\''
+                          || (LA14_0 >= '*' && LA14_0 <= ':') || (LA14_0 >= '<' && LA14_0 <= '>') || (LA14_0 >= '@' && LA14_0 <= '{') || LA14_0 == '}' || (LA14_0 >= '\u007F' && LA14_0 <= '\uFFFE')) ) {
+                        alt14 = 1;
+                    }
+
+                    switch ( alt14 ) {
+                        case 1 :
+                            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:624:38: SYMBOL
+                        {
+                            mSYMBOL();
+                            if ( failed ) return;
+
+                        }
+                            break;
+
+                        default :
+                            break loop14;
+                    }
+                } while ( true );
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end VAR
+
+    // $ANTLR start SH_STYLE_SINGLE_LINE_COMMENT
+    public void mSH_STYLE_SINGLE_LINE_COMMENT() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = SH_STYLE_SINGLE_LINE_COMMENT;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:628:4: ( '#' ( options {greedy=false; } : . )* EOL )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:628:4: '#' ( options {greedy=false; } : . )* EOL
+            {
+                match( '#' );
+                if ( failed ) return;
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:628:8: ( options {greedy=false; } : . )*
+                loop15 : do {
+                    int alt15 = 2;
+                    int LA15_0 = input.LA( 1 );
+                    if ( (LA15_0 == '\r') ) {
+                        alt15 = 2;
+                    } else if ( (LA15_0 == '\n') ) {
+                        alt15 = 2;
+                    } else if ( ((LA15_0 >= '\u0000' && LA15_0 <= '\t') || (LA15_0 >= '\u000B' && LA15_0 <= '\f') || (LA15_0 >= '\u000E' && LA15_0 <= '\uFFFE')) ) {
+                        alt15 = 1;
+                    }
+
+                    switch ( alt15 ) {
+                        case 1 :
+                            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:628:35: .
+                        {
+                            matchAny();
+                            if ( failed ) return;
+
+                        }
+                            break;
+
+                        default :
+                            break loop15;
+                    }
+                } while ( true );
+
+                mEOL();
+                if ( failed ) return;
+                if ( backtracking == 0 ) {
+                    _channel = HIDDEN;
+                }
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end SH_STYLE_SINGLE_LINE_COMMENT
+
+    // $ANTLR start C_STYLE_SINGLE_LINE_COMMENT
+    public void mC_STYLE_SINGLE_LINE_COMMENT() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = C_STYLE_SINGLE_LINE_COMMENT;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:634:4: ( '//' ( options {greedy=false; } : . )* EOL )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:634:4: '//' ( options {greedy=false; } : . )* EOL
+            {
+                match( "//" );
+                if ( failed ) return;
+
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:634:9: ( options {greedy=false; } : . )*
+                loop16 : do {
+                    int alt16 = 2;
+                    int LA16_0 = input.LA( 1 );
+                    if ( (LA16_0 == '\r') ) {
+                        alt16 = 2;
+                    } else if ( (LA16_0 == '\n') ) {
+                        alt16 = 2;
+                    } else if ( ((LA16_0 >= '\u0000' && LA16_0 <= '\t') || (LA16_0 >= '\u000B' && LA16_0 <= '\f') || (LA16_0 >= '\u000E' && LA16_0 <= '\uFFFE')) ) {
+                        alt16 = 1;
+                    }
+
+                    switch ( alt16 ) {
+                        case 1 :
+                            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:634:36: .
+                        {
+                            matchAny();
+                            if ( failed ) return;
+
+                        }
+                            break;
+
+                        default :
+                            break loop16;
+                    }
+                } while ( true );
+
+                mEOL();
+                if ( failed ) return;
+                if ( backtracking == 0 ) {
+                    _channel = HIDDEN;
+                }
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end C_STYLE_SINGLE_LINE_COMMENT
+
+    // $ANTLR start LEFT_PAREN
+    public void mLEFT_PAREN() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = LEFT_PAREN;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:640:4: ( '(' )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:640:4: '('
+            {
+                match( '(' );
+                if ( failed ) return;
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end LEFT_PAREN
+
+    // $ANTLR start RIGHT_PAREN
+    public void mRIGHT_PAREN() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = RIGHT_PAREN;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:644:4: ( ')' )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:644:4: ')'
+            {
+                match( ')' );
+                if ( failed ) return;
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end RIGHT_PAREN
+
+    // $ANTLR start LEFT_SQUARE
+    public void mLEFT_SQUARE() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = LEFT_SQUARE;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:648:4: ( '[' )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:648:4: '['
+            {
+                match( '[' );
+                if ( failed ) return;
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end LEFT_SQUARE
+
+    // $ANTLR start RIGHT_SQUARE
+    public void mRIGHT_SQUARE() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = RIGHT_SQUARE;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:652:4: ( ']' )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:652:4: ']'
+            {
+                match( ']' );
+                if ( failed ) return;
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end RIGHT_SQUARE
+
+    // $ANTLR start LEFT_CURLY
+    public void mLEFT_CURLY() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = LEFT_CURLY;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:656:4: ( '{' )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:656:4: '{'
+            {
+                match( '{' );
+                if ( failed ) return;
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end LEFT_CURLY
+
+    // $ANTLR start RIGHT_CURLY
+    public void mRIGHT_CURLY() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = RIGHT_CURLY;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:660:4: ( '}' )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:660:4: '}'
+            {
+                match( '}' );
+                if ( failed ) return;
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end RIGHT_CURLY
+
+    // $ANTLR start TILDE
+    public void mTILDE() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = TILDE;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:663:9: ( '~' )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:663:9: '~'
+            {
+                match( '~' );
+                if ( failed ) return;
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end TILDE
+
+    // $ANTLR start AMPERSAND
+    public void mAMPERSAND() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = AMPERSAND;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:667:4: ( '&' )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:667:4: '&'
+            {
+                match( '&' );
+                if ( failed ) return;
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end AMPERSAND
+
+    // $ANTLR start PIPE
+    public void mPIPE() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = PIPE;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:671:4: ( '|' )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:671:4: '|'
+            {
+                match( '|' );
+                if ( failed ) return;
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end PIPE
+
+    // $ANTLR start ASSIGN_OP
+    public void mASSIGN_OP() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = ASSIGN_OP;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:675:4: ( '<-' )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:675:4: '<-'
+            {
+                match( "<-" );
+                if ( failed ) return;
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end ASSIGN_OP
+
+    // $ANTLR start COLON
+    public void mCOLON() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = COLON;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:678:9: ( ':' )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:678:9: ':'
+            {
+                match( ':' );
+                if ( failed ) return;
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end COLON
+
+    // $ANTLR start EQUALS
+    public void mEQUALS() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = EQUALS;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:680:10: ( '=' )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:680:10: '='
+            {
+                match( '=' );
+                if ( failed ) return;
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end EQUALS
+
+    // $ANTLR start MULTI_LINE_COMMENT
+    public void mMULTI_LINE_COMMENT() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = MULTI_LINE_COMMENT;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:683:4: ( '/*' ( options {greedy=false; } : . )* '*/' )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:683:4: '/*' ( options {greedy=false; } : . )* '*/'
+            {
+                match( "/*" );
+                if ( failed ) return;
+
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:683:9: ( options {greedy=false; } : . )*
+                loop17 : do {
+                    int alt17 = 2;
+                    int LA17_0 = input.LA( 1 );
+                    if ( (LA17_0 == '*') ) {
+                        int LA17_1 = input.LA( 2 );
+                        if ( (LA17_1 == '/') ) {
+                            alt17 = 2;
+                        } else if ( ((LA17_1 >= '\u0000' && LA17_1 <= '.') || (LA17_1 >= '0' && LA17_1 <= '\uFFFE')) ) {
+                            alt17 = 1;
+                        }
+
+                    } else if ( ((LA17_0 >= '\u0000' && LA17_0 <= ')') || (LA17_0 >= '+' && LA17_0 <= '\uFFFE')) ) {
+                        alt17 = 1;
+                    }
+
+                    switch ( alt17 ) {
+                        case 1 :
+                            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:683:35: .
+                        {
+                            matchAny();
+                            if ( failed ) return;
+
+                        }
+                            break;
+
+                        default :
+                            break loop17;
+                    }
+                } while ( true );
+
+                match( "*/" );
+                if ( failed ) return;
+
+                if ( backtracking == 0 ) {
+                    _channel = HIDDEN;
+                }
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end MULTI_LINE_COMMENT
+
+    // $ANTLR start NAME
+    public void mNAME() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            int _type = NAME;
+            int _start = getCharIndex();
+            int _line = getLine();
+            int _charPosition = getCharPositionInLine();
+            int _channel = Token.DEFAULT_CHANNEL;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:687:8: ( SYMBOL )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:687:8: SYMBOL
+            {
+                mSYMBOL();
+                if ( failed ) return;
+
+            }
+
+            if ( backtracking == 0 ) {
+
+                if ( token == null && ruleNestingLevel == 1 ) {
+                    emit( _type,
+                          _line,
+                          _charPosition,
+                          _channel,
+                          _start,
+                          getCharIndex() - 1 );
+                }
+
+            }
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end NAME
+
+    // $ANTLR start SYMBOL
+    public void mSYMBOL() throws RecognitionException {
+        try {
+            ruleNestingLevel++;
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:691:4: ( ( (~ (' '|'\\t'|'\\n'|'\\r'|'\"'|'('|')'|';'|'&'|'|'|'~'|'?'|'$')) | ( '$' ~ ('?'|' '|'\\t'|'\\n'|'\\r'|'\"'|'('|')'|';'|'&'|'|'|'~'|'<')) ) (~ (' '|'\\t'|'\\n'|'\\r'|'\"'|'('|')'|';'|'&'|'|'|'~'|'<'|'?'))* )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:691:4: ( (~ (' '|'\\t'|'\\n'|'\\r'|'\"'|'('|')'|';'|'&'|'|'|'~'|'?'|'$')) | ( '$' ~ ('?'|' '|'\\t'|'\\n'|'\\r'|'\"'|'('|')'|';'|'&'|'|'|'~'|'<')) ) (~ (' '|'\\t'|'\\n'|'\\r'|'\"'|'('|')'|';'|'&'|'|'|'~'|'<'|'?'))*
+            {
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:691:4: ( (~ (' '|'\\t'|'\\n'|'\\r'|'\"'|'('|')'|';'|'&'|'|'|'~'|'?'|'$')) | ( '$' ~ ('?'|' '|'\\t'|'\\n'|'\\r'|'\"'|'('|')'|';'|'&'|'|'|'~'|'<')) )
+                int alt18 = 2;
+                int LA18_0 = input.LA( 1 );
+                if ( ((LA18_0 >= '\u0000' && LA18_0 <= '\b') || (LA18_0 >= '\u000B' && LA18_0 <= '\f') || (LA18_0 >= '\u000E' && LA18_0 <= '\u001F') || LA18_0 == '!' || LA18_0 == '#' || LA18_0 == '%' || LA18_0 == '\''
+                      || (LA18_0 >= '*' && LA18_0 <= ':') || (LA18_0 >= '<' && LA18_0 <= '>') || (LA18_0 >= '@' && LA18_0 <= '{') || LA18_0 == '}' || (LA18_0 >= '\u007F' && LA18_0 <= '\uFFFE')) ) {
+                    alt18 = 1;
+                } else if ( (LA18_0 == '$') ) {
+                    alt18 = 2;
+                } else {
+                    if ( backtracking > 0 ) {
+                        failed = true;
+                        return;
+                    }
+                    NoViableAltException nvae = new NoViableAltException( "691:4: ( (~ (' '|'\\t'|'\\n'|'\\r'|'\"'|'('|')'|';'|'&'|'|'|'~'|'?'|'$')) | ( '$' ~ ('?'|' '|'\\t'|'\\n'|'\\r'|'\"'|'('|')'|';'|'&'|'|'|'~'|'<')) )",
+                                                                          18,
+                                                                          0,
+                                                                          input );
+
+                    throw nvae;
+                }
+                switch ( alt18 ) {
+                    case 1 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:691:5: (~ (' '|'\\t'|'\\n'|'\\r'|'\"'|'('|')'|';'|'&'|'|'|'~'|'?'|'$'))
+                    {
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:691:5: (~ (' '|'\\t'|'\\n'|'\\r'|'\"'|'('|')'|';'|'&'|'|'|'~'|'?'|'$'))
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:691:6: ~ (' '|'\\t'|'\\n'|'\\r'|'\"'|'('|')'|';'|'&'|'|'|'~'|'?'|'$')
+                        {
+                            if ( (input.LA( 1 ) >= '\u0000' && input.LA( 1 ) <= '\b') || (input.LA( 1 ) >= '\u000B' && input.LA( 1 ) <= '\f') || (input.LA( 1 ) >= '\u000E' && input.LA( 1 ) <= '\u001F') || input.LA( 1 ) == '!' || input.LA( 1 ) == '#'
+                                 || input.LA( 1 ) == '%' || input.LA( 1 ) == '\'' || (input.LA( 1 ) >= '*' && input.LA( 1 ) <= ':') || (input.LA( 1 ) >= '<' && input.LA( 1 ) <= '>') || (input.LA( 1 ) >= '@' && input.LA( 1 ) <= '{')
+                                 || input.LA( 1 ) == '}' || (input.LA( 1 ) >= '\u007F' && input.LA( 1 ) <= '\uFFFE') ) {
+                                input.consume();
+                                failed = false;
+                            } else {
+                                if ( backtracking > 0 ) {
+                                    failed = true;
+                                    return;
+                                }
+                                MismatchedSetException mse = new MismatchedSetException( null,
+                                                                                         input );
+                                recover( mse );
+                                throw mse;
+                            }
+
+                        }
+
+                    }
+                        break;
+                    case 2 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:691:65: ( '$' ~ ('?'|' '|'\\t'|'\\n'|'\\r'|'\"'|'('|')'|';'|'&'|'|'|'~'|'<'))
+                    {
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:691:65: ( '$' ~ ('?'|' '|'\\t'|'\\n'|'\\r'|'\"'|'('|')'|';'|'&'|'|'|'~'|'<'))
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:691:66: '$' ~ ('?'|' '|'\\t'|'\\n'|'\\r'|'\"'|'('|')'|';'|'&'|'|'|'~'|'<')
+                        {
+                            match( '$' );
+                            if ( failed ) return;
+                            if ( (input.LA( 1 ) >= '\u0000' && input.LA( 1 ) <= '\b') || (input.LA( 1 ) >= '\u000B' && input.LA( 1 ) <= '\f') || (input.LA( 1 ) >= '\u000E' && input.LA( 1 ) <= '\u001F') || input.LA( 1 ) == '!'
+                                 || (input.LA( 1 ) >= '#' && input.LA( 1 ) <= '%') || input.LA( 1 ) == '\'' || (input.LA( 1 ) >= '*' && input.LA( 1 ) <= ':') || (input.LA( 1 ) >= '=' && input.LA( 1 ) <= '>')
+                                 || (input.LA( 1 ) >= '@' && input.LA( 1 ) <= '{') || input.LA( 1 ) == '}' || (input.LA( 1 ) >= '\u007F' && input.LA( 1 ) <= '\uFFFE') ) {
+                                input.consume();
+                                failed = false;
+                            } else {
+                                if ( backtracking > 0 ) {
+                                    failed = true;
+                                    return;
+                                }
+                                MismatchedSetException mse = new MismatchedSetException( null,
+                                                                                         input );
+                                recover( mse );
+                                throw mse;
+                            }
+
+                        }
+
+                    }
+                        break;
+
+                }
+
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:692:11: (~ (' '|'\\t'|'\\n'|'\\r'|'\"'|'('|')'|';'|'&'|'|'|'~'|'<'|'?'))*
+                loop19 : do {
+                    int alt19 = 2;
+                    int LA19_0 = input.LA( 1 );
+                    if ( ((LA19_0 >= '\u0000' && LA19_0 <= '\b') || (LA19_0 >= '\u000B' && LA19_0 <= '\f') || (LA19_0 >= '\u000E' && LA19_0 <= '\u001F') || LA19_0 == '!' || (LA19_0 >= '#' && LA19_0 <= '%') || LA19_0 == '\''
+                          || (LA19_0 >= '*' && LA19_0 <= ':') || (LA19_0 >= '=' && LA19_0 <= '>') || (LA19_0 >= '@' && LA19_0 <= '{') || LA19_0 == '}' || (LA19_0 >= '\u007F' && LA19_0 <= '\uFFFE')) ) {
+                        alt19 = 1;
+                    }
+
+                    switch ( alt19 ) {
+                        case 1 :
+                            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:692:12: ~ (' '|'\\t'|'\\n'|'\\r'|'\"'|'('|')'|';'|'&'|'|'|'~'|'<'|'?')
+                        {
+                            if ( (input.LA( 1 ) >= '\u0000' && input.LA( 1 ) <= '\b') || (input.LA( 1 ) >= '\u000B' && input.LA( 1 ) <= '\f') || (input.LA( 1 ) >= '\u000E' && input.LA( 1 ) <= '\u001F') || input.LA( 1 ) == '!'
+                                 || (input.LA( 1 ) >= '#' && input.LA( 1 ) <= '%') || input.LA( 1 ) == '\'' || (input.LA( 1 ) >= '*' && input.LA( 1 ) <= ':') || (input.LA( 1 ) >= '=' && input.LA( 1 ) <= '>')
+                                 || (input.LA( 1 ) >= '@' && input.LA( 1 ) <= '{') || input.LA( 1 ) == '}' || (input.LA( 1 ) >= '\u007F' && input.LA( 1 ) <= '\uFFFE') ) {
+                                input.consume();
+                                failed = false;
+                            } else {
+                                if ( backtracking > 0 ) {
+                                    failed = true;
+                                    return;
+                                }
+                                MismatchedSetException mse = new MismatchedSetException( null,
+                                                                                         input );
+                                recover( mse );
+                                throw mse;
+                            }
+
+                        }
+                            break;
+
+                        default :
+                            break loop19;
+                    }
+                } while ( true );
+
+            }
+
+        } finally {
+            ruleNestingLevel--;
+        }
+    }
+
+    // $ANTLR end SYMBOL
+
+    public void mTokens() throws RecognitionException {
+        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:10: ( T41 | WS | DEFRULE | OR | AND | NOT | EXISTS | TEST | NULL | DECLARE | SALIENCE | INT | FLOAT | STRING | BOOL | VAR | SH_STYLE_SINGLE_LINE_COMMENT | C_STYLE_SINGLE_LINE_COMMENT | LEFT_PAREN | RIGHT_PAREN | LEFT_SQUARE | RIGHT_SQUARE | LEFT_CURLY | RIGHT_CURLY | TILDE | AMPERSAND | PIPE | ASSIGN_OP | COLON | EQUALS | MULTI_LINE_COMMENT | NAME )
+        int alt20 = 32;
+        alt20 = dfa20.predict( input );
+        switch ( alt20 ) {
+            case 1 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:10: T41
+            {
+                mT41();
+                if ( failed ) return;
+
+            }
+                break;
+            case 2 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:14: WS
+            {
+                mWS();
+                if ( failed ) return;
+
+            }
+                break;
+            case 3 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:17: DEFRULE
+            {
+                mDEFRULE();
+                if ( failed ) return;
+
+            }
+                break;
+            case 4 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:25: OR
+            {
+                mOR();
+                if ( failed ) return;
+
+            }
+                break;
+            case 5 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:28: AND
+            {
+                mAND();
+                if ( failed ) return;
+
+            }
+                break;
+            case 6 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:32: NOT
+            {
+                mNOT();
+                if ( failed ) return;
+
+            }
+                break;
+            case 7 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:36: EXISTS
+            {
+                mEXISTS();
+                if ( failed ) return;
+
+            }
+                break;
+            case 8 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:43: TEST
+            {
+                mTEST();
+                if ( failed ) return;
+
+            }
+                break;
+            case 9 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:48: NULL
+            {
+                mNULL();
+                if ( failed ) return;
+
+            }
+                break;
+            case 10 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:53: DECLARE
+            {
+                mDECLARE();
+                if ( failed ) return;
+
+            }
+                break;
+            case 11 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:61: SALIENCE
+            {
+                mSALIENCE();
+                if ( failed ) return;
+
+            }
+                break;
+            case 12 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:70: INT
+            {
+                mINT();
+                if ( failed ) return;
+
+            }
+                break;
+            case 13 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:74: FLOAT
+            {
+                mFLOAT();
+                if ( failed ) return;
+
+            }
+                break;
+            case 14 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:80: STRING
+            {
+                mSTRING();
+                if ( failed ) return;
+
+            }
+                break;
+            case 15 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:87: BOOL
+            {
+                mBOOL();
+                if ( failed ) return;
+
+            }
+                break;
+            case 16 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:92: VAR
+            {
+                mVAR();
+                if ( failed ) return;
+
+            }
+                break;
+            case 17 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:96: SH_STYLE_SINGLE_LINE_COMMENT
+            {
+                mSH_STYLE_SINGLE_LINE_COMMENT();
+                if ( failed ) return;
+
+            }
+                break;
+            case 18 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:125: C_STYLE_SINGLE_LINE_COMMENT
+            {
+                mC_STYLE_SINGLE_LINE_COMMENT();
+                if ( failed ) return;
+
+            }
+                break;
+            case 19 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:153: LEFT_PAREN
+            {
+                mLEFT_PAREN();
+                if ( failed ) return;
+
+            }
+                break;
+            case 20 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:164: RIGHT_PAREN
+            {
+                mRIGHT_PAREN();
+                if ( failed ) return;
+
+            }
+                break;
+            case 21 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:176: LEFT_SQUARE
+            {
+                mLEFT_SQUARE();
+                if ( failed ) return;
+
+            }
+                break;
+            case 22 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:188: RIGHT_SQUARE
+            {
+                mRIGHT_SQUARE();
+                if ( failed ) return;
+
+            }
+                break;
+            case 23 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:201: LEFT_CURLY
+            {
+                mLEFT_CURLY();
+                if ( failed ) return;
+
+            }
+                break;
+            case 24 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:212: RIGHT_CURLY
+            {
+                mRIGHT_CURLY();
+                if ( failed ) return;
+
+            }
+                break;
+            case 25 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:224: TILDE
+            {
+                mTILDE();
+                if ( failed ) return;
+
+            }
+                break;
+            case 26 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:230: AMPERSAND
+            {
+                mAMPERSAND();
+                if ( failed ) return;
+
+            }
+                break;
+            case 27 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:240: PIPE
+            {
+                mPIPE();
+                if ( failed ) return;
+
+            }
+                break;
+            case 28 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:245: ASSIGN_OP
+            {
+                mASSIGN_OP();
+                if ( failed ) return;
+
+            }
+                break;
+            case 29 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:255: COLON
+            {
+                mCOLON();
+                if ( failed ) return;
+
+            }
+                break;
+            case 30 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:261: EQUALS
+            {
+                mEQUALS();
+                if ( failed ) return;
+
+            }
+                break;
+            case 31 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:268: MULTI_LINE_COMMENT
+            {
+                mMULTI_LINE_COMMENT();
+                if ( failed ) return;
+
+            }
+                break;
+            case 32 :
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:1:287: NAME
+            {
+                mNAME();
+                if ( failed ) return;
+
+            }
+                break;
+
+        }
+
+    }
+
+    protected DFA20              dfa20            = new DFA20( this );
+    public static final String   DFA20_eotS       = "\1\uffff\1\40\1\uffff\1\2\10\36\1\54\1\uffff\2\36\1\uffff\2\36\2" + "\uffff\1\65\1\66\1\67\1\70\3\uffff\1\36\1\72\1\uffff\1\73\1\uffff"
+                                                    + "\1\36\1\76\7\36\1\54\1\36\1\uffff\2\36\1\15\1\36\1\uffff\3\36\4" + "\uffff\1\121\2\uffff\2\36\1\uffff\1\124\1\125\5\36\1\133\7\36\1"
+                                                    + "\uffff\1\36\2\uffff\2\36\2\uffff\1\143\1\36\1\145\1\146\1\36\1\uffff" + "\4\36\1\116\2\36\1\uffff\1\36\2\uffff\3\36\1\145\2\36\1\162\2\36" + "\1\165\1\166\1\uffff\2\36\2\uffff\1\170\1\uffff";
+    public static final String   DFA20_eofS       = "\171\uffff";
+    public static final String   DFA20_minS       = "\2\0\1\uffff\1\0\1\145\1\162\1\156\1\157\1\170\1\145\1\141\1\60" + "\1\0\1\uffff\1\0\1\141\1\uffff\1\0\1\52\2\uffff\4\0\3\uffff\1\55"
+                                                    + "\1\0\1\uffff\1\0\1\uffff\1\143\1\0\1\144\1\164\1\154\1\151\1\165" + "\1\163\1\154\1\0\1\60\1\uffff\1\42\2\0\1\154\1\uffff\3\0\4\uffff"
+                                                    + "\1\0\2\uffff\1\154\1\162\1\uffff\2\0\1\154\1\163\1\145\1\164\1\151" + "\2\0\1\60\2\0\1\163\2\0\1\uffff\1\0\2\uffff\1\141\1\165\2\uffff"
+                                                    + "\1\0\1\164\2\0\1\145\1\uffff\1\60\2\0\1\145\1\0\1\162\1\154\1\uffff" + "\1\163\2\uffff\1\156\1\60\2\0\2\145\1\0\1\143\1\60\2\0\1\uffff\1" + "\145\1\0\2\uffff\1\0\1\uffff";
+    public static final String   DFA20_maxS       = "\2\ufffe\1\uffff\1\ufffe\1\145\1\162\1\156\1\165\1\170\1\162\1\141" + "\1\71\1\ufffe\1\uffff\1\ufffe\1\141\1\uffff\1\ufffe\1\57\2\uffff"
+                                                    + "\4\ufffe\3\uffff\1\55\1\ufffe\1\uffff\1\ufffe\1\uffff\1\146\1\ufffe" + "\1\144\1\164\1\154\1\151\1\165\1\163\1\154\1\ufffe\1\71\1\uffff"
+                                                    + "\1\165\2\ufffe\1\154\1\uffff\3\ufffe\4\uffff\1\ufffe\2\uffff\1\154" + "\1\162\1\uffff\2\ufffe\1\154\1\163\1\145\1\164\1\151\2\ufffe\1\146"
+                                                    + "\2\ufffe\1\163\2\ufffe\1\uffff\1\ufffe\2\uffff\1\141\1\165\2\uffff" + "\1\ufffe\1\164\2\ufffe\1\145\1\uffff\1\146\2\ufffe\1\145\1\ufffe"
+                                                    + "\1\162\1\154\1\uffff\1\163\2\uffff\1\156\1\146\2\ufffe\2\145\1\ufffe" + "\1\143\1\146\2\ufffe\1\uffff\1\145\1\ufffe\2\uffff\1\ufffe\1\uffff";
+    public static final String   DFA20_acceptS    = "\2\uffff\1\2\12\uffff\1\16\2\uffff\1\20\2\uffff\1\23\1\24\4\uffff" + "\1\31\1\32\1\33\2\uffff\1\40\1\uffff\1\36\13\uffff\1\14\4\uffff"
+                                                    + "\1\21\3\uffff\1\25\1\26\1\27\1\30\1\uffff\1\35\1\1\2\uffff\1\4\17" + "\uffff\1\37\1\uffff\1\22\1\34\2\uffff\1\5\1\6\5\uffff\1\15\7\uffff"
+                                                    + "\1\11\1\uffff\1\17\1\10\13\uffff\1\7\2\uffff\1\12\1\3\1\uffff\1" + "\13";
+    public static final String   DFA20_specialS   = "\171\uffff}>";
+    public static final String[] DFA20_transition = {
+            "\11\36\2\2\1\36\1\3\1\2\22\36\1\2\1\36\1\15\1\21\2\36\1\32\1\16" + "\1\23\1\24\3\36\1\13\1\36\1\22\12\14\1\35\1\uffff\1\34\1\1\1\36" + "\1\20\33\36\1\25\1\36\1\26\3\36\1\6\2\36\1\4\1\10\1\17\7\36\1\7"
+                    + "\1\5\3\36\1\12\1\11\6\36\1\27\1\33\1\30\1\31\uff80\36", "\11\36\2\uffff\2\36\1\uffff\22\36\1\uffff\1\36\1\uffff\3\36\1\uffff" + "\1\36\2\uffff\21\36\2\uffff\1\36\1\37\1\uffff\74\36\1\uffff\1\36" + "\1\uffff\uff80\36", "",
+            "\11\36\2\uffff\2\36\1\uffff\22\36\1\uffff\1\36\1\uffff\3\36\1\uffff" + "\1\36\2\uffff\21\36\2\uffff\2\36\1\uffff\74\36\1\uffff\1\36\1\uffff" + "\uff80\36", "\1\41", "\1\42", "\1\43", "\1\44\5\uffff\1\45", "\1\46", "\1\50\14\uffff\1\47",
+            "\1\51", "\12\52", "\11\36\2\uffff\2\36\1\uffff\22\36\1\uffff\1\36\1\uffff\3\36\1\uffff" + "\1\36\2\uffff\4\36\1\53\1\36\12\52\1\36\2\uffff\2\36\1\uffff\74" + "\36\1\uffff\1\36\1\uffff\uff80\36", "",
+            "\11\56\2\15\2\56\1\15\22\56\1\15\1\56\1\15\3\56\1\15\1\57\2\15\21" + "\56\2\15\2\56\1\15\34\56\1\55\37\56\1\15\1\56\1\15\uff80\56", "\1\60", "",
+            "\11\62\2\61\2\62\1\61\22\62\1\61\1\62\1\61\3\62\1\61\1\62\2\61\21" + "\62\2\61\2\62\1\61\74\62\1\61\1\62\1\61\uff80\62", "\1\63\4\uffff\1\64", "", "",
+            "\11\36\2\uffff\2\36\1\uffff\22\36\1\uffff\1\36\1\uffff\3\36\1\uffff" + "\1\36\2\uffff\21\36\2\uffff\2\36\1\uffff\74\36\1\uffff\1\36\1\uffff" + "\uff80\36",
+            "\11\36\2\uffff\2\36\1\uffff\22\36\1\uffff\1\36\1\uffff\3\36\1\uffff" + "\1\36\2\uffff\21\36\2\uffff\2\36\1\uffff\74\36\1\uffff\1\36\1\uffff" + "\uff80\36",
+            "\11\36\2\uffff\2\36\1\uffff\22\36\1\uffff\1\36\1\uffff\3\36\1\uffff" + "\1\36\2\uffff\21\36\2\uffff\2\36\1\uffff\74\36\1\uffff\1\36\1\uffff" + "\uff80\36",
+            "\11\36\2\uffff\2\36\1\uffff\22\36\1\uffff\1\36\1\uffff\3\36\1\uffff" + "\1\36\2\uffff\21\36\2\uffff\2\36\1\uffff\74\36\1\uffff\1\36\1\uffff" + "\uff80\36", "", "", "", "\1\71",
+            "\11\36\2\uffff\2\36\1\uffff\22\36\1\uffff\1\36\1\uffff\3\36\1\uffff" + "\1\36\2\uffff\21\36\2\uffff\2\36\1\uffff\74\36\1\uffff\1\36\1\uffff" + "\uff80\36", "",
+            "\11\36\2\uffff\2\36\1\uffff\22\36\1\uffff\1\36\1\uffff\3\36\1\uffff" + "\1\36\2\uffff\21\36\2\uffff\2\36\1\uffff\74\36\1\uffff\1\36\1\uffff" + "\uff80\36", "", "\1\74\2\uffff\1\75",
+            "\11\36\2\uffff\2\36\1\uffff\22\36\1\uffff\1\36\1\uffff\3\36\1\uffff" + "\1\36\2\uffff\21\36\2\uffff\2\36\1\uffff\74\36\1\uffff\1\36\1\uffff" + "\uff80\36", "\1\77", "\1\100", "\1\101", "\1\102", "\1\103", "\1\104", "\1\105",
+            "\11\36\2\uffff\2\36\1\uffff\22\36\1\uffff\1\36\1\uffff\3\36\1\uffff" + "\1\36\2\uffff\4\36\1\53\1\36\12\52\1\36\2\uffff\2\36\1\uffff\74" + "\36\1\uffff\1\36\1\uffff\uff80\36", "\12\106", "",
+            "\1\15\4\uffff\1\107\10\uffff\4\111\4\112\44\uffff\1\107\5\uffff" + "\1\107\3\uffff\1\107\7\uffff\1\107\3\uffff\1\107\1\uffff\1\107\1" + "\110",
+            "\11\56\2\15\2\56\1\15\22\56\1\15\1\56\1\15\3\56\1\15\1\57\2\15\21" + "\56\2\15\2\56\1\15\34\56\1\55\37\56\1\15\1\56\1\15\uff80\56",
+            "\11\36\2\uffff\2\36\1\uffff\22\36\1\uffff\1\36\1\uffff\3\36\1\uffff" + "\1\36\2\uffff\21\36\2\uffff\2\36\1\uffff\74\36\1\uffff\1\36\1\uffff" + "\uff80\36", "\1\113", "",
+            "\11\62\2\61\2\62\1\61\22\62\1\61\1\62\1\61\3\62\1\61\1\62\2\61\21" + "\62\2\61\2\62\1\61\74\62\1\61\1\62\1\61\uff80\62",
+            "\11\115\2\116\2\115\1\116\22\115\1\116\1\115\1\116\3\115\1\116\1" + "\115\2\116\1\114\20\115\2\116\2\115\1\116\74\115\1\116\1\115\1\116" + "\uff80\115",
+            "\11\117\2\120\2\117\1\120\22\117\1\120\1\117\1\120\3\117\1\120\1" + "\117\2\120\21\117\2\120\2\117\1\120\74\117\1\120\1\117\1\120\uff80" + "\117", "", "", "", "",
+            "\11\36\2\uffff\2\36\1\uffff\22\36\1\uffff\1\36\1\uffff\3\36\1\uffff" + "\1\36\2\uffff\21\36\2\uffff\2\36\1\uffff\74\36\1\uffff\1\36\1\uffff" + "\uff80\36", "", "", "\1\122", "\1\123", "",
+            "\11\36\2\uffff\2\36\1\uffff\22\36\1\uffff\1\36\1\uffff\3\36\1\uffff" + "\1\36\2\uffff\21\36\2\uffff\2\36\1\uffff\74\36\1\uffff\1\36\1\uffff" + "\uff80\36",
+            "\11\36\2\uffff\2\36\1\uffff\22\36\1\uffff\1\36\1\uffff\3\36\1\uffff" + "\1\36\2\uffff\21\36\2\uffff\2\36\1\uffff\74\36\1\uffff\1\36\1\uffff" + "\uff80\36", "\1\126", "\1\127", "\1\130", "\1\131", "\1\132",
+            "\11\36\2\uffff\2\36\1\uffff\22\36\1\uffff\1\36\1\uffff\3\36\1\uffff" + "\1\36\2\uffff\6\36\12\106\1\36\2\uffff\2\36\1\uffff\74\36\1\uffff" + "\1\36\1\uffff\uff80\36",
+            "\11\56\2\15\2\56\1\15\22\56\1\15\1\56\1\15\3\56\1\15\1\57\2\15\21" + "\56\2\15\2\56\1\15\34\56\1\55\37\56\1\15\1\56\1\15\uff80\56", "\12\134\7\uffff\6\134\32\uffff\6\134",
+            "\11\56\2\15\2\56\1\15\22\56\1\15\1\56\1\15\3\56\1\15\1\57\2\15\6" + "\56\10\135\3\56\2\15\2\56\1\15\34\56\1\55\37\56\1\15\1\56\1\15\uff80" + "\56",
+            "\11\56\2\15\2\56\1\15\22\56\1\15\1\56\1\15\3\56\1\15\1\57\2\15\6" + "\56\10\136\3\56\2\15\2\56\1\15\34\56\1\55\37\56\1\15\1\56\1\15\uff80" + "\56", "\1\137",
+            "\11\115\2\116\2\115\1\116\22\115\1\116\1\115\1\116\3\115\1\116\1" + "\115\2\116\1\114\4\115\1\140\13\115\2\116\2\115\1\116\74\115\1\116" + "\1\115\1\116\uff80\115",
+            "\11\115\2\116\2\115\1\116\22\115\1\116\1\115\1\116\3\115\1\116\1" + "\115\2\116\1\114\20\115\2\116\2\115\1\116\74\115\1\116\1\115\1\116" + "\uff80\115", "",
+            "\11\117\2\120\2\117\1\120\22\117\1\120\1\117\1\120\3\117\1\120\1" + "\117\2\120\21\117\2\120\2\117\1\120\74\117\1\120\1\117\1\120\uff80" + "\117", "", "", "\1\141", "\1\142", "", "",
+            "\11\36\2\uffff\2\36\1\uffff\22\36\1\uffff\1\36\1\uffff\3\36\1\uffff" + "\1\36\2\uffff\21\36\2\uffff\2\36\1\uffff\74\36\1\uffff\1\36\1\uffff" + "\uff80\36", "\1\144",
+            "\11\36\2\uffff\2\36\1\uffff\22\36\1\uffff\1\36\1\uffff\3\36\1\uffff" + "\1\36\2\uffff\21\36\2\uffff\2\36\1\uffff\74\36\1\uffff\1\36\1\uffff" + "\uff80\36",
+            "\11\36\2\uffff\2\36\1\uffff\22\36\1\uffff\1\36\1\uffff\3\36\1\uffff" + "\1\36\2\uffff\21\36\2\uffff\2\36\1\uffff\74\36\1\uffff\1\36\1\uffff" + "\uff80\36", "\1\147", "", "\12\150\7\uffff\6\150\32\uffff\6\150",
+            "\11\56\2\15\2\56\1\15\22\56\1\15\1\56\1\15\3\56\1\15\1\57\2\15\6" + "\56\10\151\3\56\2\15\2\56\1\15\34\56\1\55\37\56\1\15\1\56\1\15\uff80" + "\56",
+            "\11\56\2\15\2\56\1\15\22\56\1\15\1\56\1\15\3\56\1\15\1\57\2\15\21" + "\56\2\15\2\56\1\15\34\56\1\55\37\56\1\15\1\56\1\15\uff80\56", "\1\152",
+            "\11\115\2\uffff\2\115\1\uffff\22\115\1\uffff\1\115\1\uffff\3\115" + "\1\uffff\1\115\2\uffff\1\114\20\115\2\uffff\2\115\1\uffff\74\115" + "\1\uffff\1\115\1\uffff\uff80\115", "\1\153", "\1\154", "", "\1\155", "", "", "\1\156",
+            "\12\157\7\uffff\6\157\32\uffff\6\157", "\11\56\2\15\2\56\1\15\22\56\1\15\1\56\1\15\3\56\1\15\1\57\2\15\21" + "\56\2\15\2\56\1\15\34\56\1\55\37\56\1\15\1\56\1\15\uff80\56",
+            "\11\36\2\uffff\2\36\1\uffff\22\36\1\uffff\1\36\1\uffff\3\36\1\uffff" + "\1\36\2\uffff\21\36\2\uffff\2\36\1\uffff\74\36\1\uffff\1\36\1\uffff" + "\uff80\36", "\1\160", "\1\161",
+            "\11\36\2\uffff\2\36\1\uffff\22\36\1\uffff\1\36\1\uffff\3\36\1\uffff" + "\1\36\2\uffff\21\36\2\uffff\2\36\1\uffff\74\36\1\uffff\1\36\1\uffff" + "\uff80\36", "\1\163", "\12\164\7\uffff\6\164\32\uffff\6\164",
+            "\11\36\2\uffff\2\36\1\uffff\22\36\1\uffff\1\36\1\uffff\3\36\1\uffff" + "\1\36\2\uffff\21\36\2\uffff\2\36\1\uffff\74\36\1\uffff\1\36\1\uffff" + "\uff80\36",
+            "\11\36\2\uffff\2\36\1\uffff\22\36\1\uffff\1\36\1\uffff\3\36\1\uffff" + "\1\36\2\uffff\21\36\2\uffff\2\36\1\uffff\74\36\1\uffff\1\36\1\uffff" + "\uff80\36", "", "\1\167",
+            "\11\56\2\15\2\56\1\15\22\56\1\15\1\56\1\15\3\56\1\15\1\57\2\15\21" + "\56\2\15\2\56\1\15\34\56\1\55\37\56\1\15\1\56\1\15\uff80\56", "", "",
+            "\11\36\2\uffff\2\36\1\uffff\22\36\1\uffff\1\36\1\uffff\3\36\1\uffff" + "\1\36\2\uffff\21\36\2\uffff\2\36\1\uffff\74\36\1\uffff\1\36\1\uffff" + "\uff80\36", ""};
+
+    class DFA20 extends DFA {
+        public DFA20(BaseRecognizer recognizer) {
+            this.recognizer = recognizer;
+            this.decisionNumber = 20;
+            this.eot = DFA.unpackEncodedString( DFA20_eotS );
+            this.eof = DFA.unpackEncodedString( DFA20_eofS );
+            this.min = DFA.unpackEncodedStringToUnsignedChars( DFA20_minS );
+            this.max = DFA.unpackEncodedStringToUnsignedChars( DFA20_maxS );
+            this.accept = DFA.unpackEncodedString( DFA20_acceptS );
+            this.special = DFA.unpackEncodedString( DFA20_specialS );
+            int numStates = DFA20_transition.length;
+            this.transition = new short[numStates][];
+            for ( int i = 0; i < numStates; i++ ) {
+                transition[i] = DFA.unpackEncodedString( DFA20_transition[i] );
+            }
+        }
+
+        public String getDescription() {
+            return "1:1: Tokens : ( T41 | WS | DEFRULE | OR | AND | NOT | EXISTS | TEST | NULL | DECLARE | SALIENCE | INT | FLOAT | STRING | BOOL | VAR | SH_STYLE_SINGLE_LINE_COMMENT | C_STYLE_SINGLE_LINE_COMMENT | LEFT_PAREN | RIGHT_PAREN | LEFT_SQUARE | RIGHT_SQUARE | LEFT_CURLY | RIGHT_CURLY | TILDE | AMPERSAND | PIPE | ASSIGN_OP | COLON | EQUALS | MULTI_LINE_COMMENT | NAME );";
+        }
+    }
+
+}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPParser.java (from rev 10524, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/CLPParser.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPParser.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPParser.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,1888 @@
+// $ANTLR 3.0b7 C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g 2007-03-24 20:05:52
+
+package org.drools.clp;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.antlr.runtime.BitSet;
+import org.antlr.runtime.CommonToken;
+import org.antlr.runtime.EarlyExitException;
+import org.antlr.runtime.FailedPredicateException;
+import org.antlr.runtime.MismatchedNotSetException;
+import org.antlr.runtime.MismatchedSetException;
+import org.antlr.runtime.MismatchedTokenException;
+import org.antlr.runtime.MismatchedTreeNodeException;
+import org.antlr.runtime.NoViableAltException;
+import org.antlr.runtime.Parser;
+import org.antlr.runtime.RecognitionException;
+import org.antlr.runtime.Token;
+import org.antlr.runtime.TokenStream;
+import org.drools.clp.valuehandlers.BooleanValueHandler;
+import org.drools.clp.valuehandlers.DoubleValueHandler;
+import org.drools.clp.valuehandlers.FunctionCaller;
+import org.drools.clp.valuehandlers.LongValueHandler;
+import org.drools.clp.valuehandlers.ObjectValueHandler;
+import org.drools.lang.descr.AndDescr;
+import org.drools.lang.descr.AttributeDescr;
+import org.drools.lang.descr.ColumnDescr;
+import org.drools.lang.descr.ConditionalElementDescr;
+import org.drools.lang.descr.DescrFactory;
+import org.drools.lang.descr.EvalDescr;
+import org.drools.lang.descr.ExistsDescr;
+import org.drools.lang.descr.FieldBindingDescr;
+import org.drools.lang.descr.FieldConstraintDescr;
+import org.drools.lang.descr.LiteralRestrictionDescr;
+import org.drools.lang.descr.NotDescr;
+import org.drools.lang.descr.OrDescr;
+import org.drools.lang.descr.PackageDescr;
+import org.drools.lang.descr.PredicateDescr;
+import org.drools.lang.descr.RestrictionConnectiveDescr;
+import org.drools.lang.descr.ReturnValueRestrictionDescr;
+import org.drools.lang.descr.RuleDescr;
+import org.drools.lang.descr.VariableRestrictionDescr;
+
+public class CLPParser extends Parser {
+    public static final String[] tokenNames                   = new String[]{"<invalid>", "<EOR>", "<DOWN>", "<UP>", "LEFT_PAREN", "DEFRULE", "NAME", "STRING", "RIGHT_PAREN", "SALIENCE", "INT", "AND", "OR", "NOT", "EXISTS", "TEST", "VAR",
+            "ASSIGN_OP", "AMPERSAND", "PIPE", "TILDE", "COLON", "EQUALS", "FLOAT", "BOOL", "NULL", "EOL", "WS", "DECLARE", "EscapeSequence", "HexDigit", "UnicodeEscape", "OctalEscape", "SYMBOL", "SH_STYLE_SINGLE_LINE_COMMENT",
+            "C_STYLE_SINGLE_LINE_COMMENT", "LEFT_SQUARE", "RIGHT_SQUARE", "LEFT_CURLY", "RIGHT_CURLY", "MULTI_LINE_COMMENT", "'=>'"};
+    public static final int      EXISTS                       = 14;
+    public static final int      LEFT_PAREN                   = 4;
+    public static final int      RIGHT_CURLY                  = 39;
+    public static final int      BOOL                         = 24;
+    public static final int      DEFRULE                      = 5;
+    public static final int      HexDigit                     = 30;
+    public static final int      WS                           = 27;
+    public static final int      STRING                       = 7;
+    public static final int      FLOAT                        = 23;
+    public static final int      TILDE                        = 20;
+    public static final int      OR                           = 12;
+    public static final int      PIPE                         = 19;
+    public static final int      EQUALS                       = 22;
+    public static final int      VAR                          = 16;
+    public static final int      ASSIGN_OP                    = 17;
+    public static final int      UnicodeEscape                = 31;
+    public static final int      AND                          = 11;
+    public static final int      EscapeSequence               = 29;
+    public static final int      INT                          = 10;
+    public static final int      EOF                          = -1;
+    public static final int      EOL                          = 26;
+    public static final int      NULL                         = 25;
+    public static final int      SYMBOL                       = 33;
+    public static final int      LEFT_SQUARE                  = 36;
+    public static final int      COLON                        = 21;
+    public static final int      SH_STYLE_SINGLE_LINE_COMMENT = 34;
+    public static final int      OctalEscape                  = 32;
+    public static final int      SALIENCE                     = 9;
+    public static final int      MULTI_LINE_COMMENT           = 40;
+    public static final int      TEST                         = 15;
+    public static final int      AMPERSAND                    = 18;
+    public static final int      NAME                         = 6;
+    public static final int      DECLARE                      = 28;
+    public static final int      RIGHT_PAREN                  = 8;
+    public static final int      NOT                          = 13;
+    public static final int      LEFT_CURLY                   = 38;
+    public static final int      RIGHT_SQUARE                 = 37;
+    public static final int      C_STYLE_SINGLE_LINE_COMMENT  = 35;
+
+    public CLPParser(TokenStream input) {
+        super( input );
+    }
+
+    public String[] getTokenNames() {
+        return tokenNames;
+    }
+
+    public String getGrammarFileName() {
+        return "C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g";
+    }
+
+    private PackageDescr     packageDescr;
+    private List             errors      = new ArrayList();
+    private String           source      = "unknown";
+    private int              lineOffset  = 0;
+    private DescrFactory     factory     = new DescrFactory();
+    private boolean          parserDebug = false;
+    private FunctionRegistry functionRegistry;
+
+    FunctionRegistry         factoryRegistry;
+
+    public void setFunctionRegistry(FunctionRegistry functionRegistry) {
+        this.functionRegistry = functionRegistry;
+    }
+
+    public void setParserDebug(boolean parserDebug) {
+        this.parserDebug = parserDebug;
+    }
+
+    public void debug(String message) {
+        if ( parserDebug ) System.err.println( "drl parser: " + message );
+    }
+
+    public void setSource(String source) {
+        this.source = source;
+    }
+
+    public DescrFactory getFactory() {
+        return factory;
+    }
+
+    public String getSource() {
+        return this.source;
+    }
+
+    public PackageDescr getPackageDescr() {
+        return packageDescr;
+    }
+
+    private int offset(int line) {
+        return line + lineOffset;
+    }
+
+    /**
+     * This will set the offset to record when reparsing. Normally is zero of course 
+     */
+    public void setLineOffset(int i) {
+        this.lineOffset = i;
+    }
+
+    private String getString(Token token) {
+        String orig = token.getText();
+        return orig.substring( 1,
+                               orig.length() - 1 );
+    }
+
+    public void reportError(RecognitionException ex) {
+        // if we've already reported an error and have not matched a token
+        // yet successfully, don't report any errors.
+        if ( errorRecovery ) {
+            return;
+        }
+        errorRecovery = true;
+
+        ex.line = offset( ex.line ); //add the offset if there is one
+        errors.add( ex );
+    }
+
+    /** return the raw RecognitionException errors */
+    public List getErrors() {
+        return errors;
+    }
+
+    /** Return a list of pretty strings summarising the errors */
+    public List getErrorMessages() {
+        List messages = new ArrayList();
+        for ( Iterator errorIter = errors.iterator(); errorIter.hasNext(); ) {
+            messages.add( createErrorMessage( (RecognitionException) errorIter.next() ) );
+        }
+        return messages;
+    }
+
+    /** return true if any parser errors were accumulated */
+    public boolean hasErrors() {
+        return !errors.isEmpty();
+    }
+
+    /** This will take a RecognitionException, and create a sensible error message out of it */
+    public String createErrorMessage(RecognitionException e) {
+        StringBuffer message = new StringBuffer();
+        message.append( source + ":" + e.line + ":" + e.charPositionInLine + " " );
+        if ( e instanceof MismatchedTokenException ) {
+            MismatchedTokenException mte = (MismatchedTokenException) e;
+            message.append( "mismatched token: " + e.token + "; expecting type " + tokenNames[mte.expecting] );
+        } else if ( e instanceof MismatchedTreeNodeException ) {
+            MismatchedTreeNodeException mtne = (MismatchedTreeNodeException) e;
+            message.append( "mismatched tree node: " + mtne.foundNode + "; expecting type " + tokenNames[mtne.expecting] );
+        } else if ( e instanceof NoViableAltException ) {
+            NoViableAltException nvae = (NoViableAltException) e;
+            message.append( "Unexpected token '" + e.token.getText() + "'" );
+            /*
+             message.append("decision=<<"+nvae.grammarDecisionDescription+">>"+
+             " state "+nvae.stateNumber+
+             " (decision="+nvae.decisionNumber+
+             ") no viable alt; token="+
+             e.token);
+             */
+        } else if ( e instanceof EarlyExitException ) {
+            EarlyExitException eee = (EarlyExitException) e;
+            message.append( "required (...)+ loop (decision=" + eee.decisionNumber + ") did not match anything; token=" + e.token );
+        } else if ( e instanceof MismatchedSetException ) {
+            MismatchedSetException mse = (MismatchedSetException) e;
+            message.append( "mismatched token '" + e.token + "' expecting set " + mse.expecting );
+        } else if ( e instanceof MismatchedNotSetException ) {
+            MismatchedNotSetException mse = (MismatchedNotSetException) e;
+            message.append( "mismatched token '" + e.token + "' expecting set " + mse.expecting );
+        } else if ( e instanceof FailedPredicateException ) {
+            FailedPredicateException fpe = (FailedPredicateException) e;
+            message.append( "rule " + fpe.ruleName + " failed predicate: {" + fpe.predicateText + "}?" );
+        } else if ( e instanceof GeneralParseException ) {
+            message.append( " " + e.getMessage() );
+        }
+        return message.toString();
+    }
+
+    void checkTrailingSemicolon(String text,
+                                int line) {
+        if ( text.trim().endsWith( ";" ) ) {
+            this.errors.add( new GeneralParseException( "Trailing semi-colon not allowed",
+                                                        offset( line ) ) );
+        }
+    }
+
+    // $ANTLR start deffunction
+    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:225:1: deffunction : ;
+    public void deffunction() throws RecognitionException {
+        try {
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:227:2: ()
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:227:2: 
+            {
+            }
+
+        } finally {
+        }
+        return;
+    }
+
+    // $ANTLR end deffunction
+
+    // $ANTLR start defrule
+    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:229:1: defrule returns [RuleDescr rule] : loc= LEFT_PAREN DEFRULE ruleName= NAME documentation= STRING ruleAttribute[rule] ( ce[lhs] )* '=>' engine= rhs RIGHT_PAREN ;
+    public RuleDescr defrule() throws RecognitionException {
+        RuleDescr rule = null;
+
+        Token loc = null;
+        Token ruleName = null;
+        Token documentation = null;
+        ExecutionEngine engine = null;
+
+        rule = null;
+        AndDescr lhs = null;
+        ColumnDescr colum = null;
+        AttributeDescr module = null;
+
+        try {
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:236:4: (loc= LEFT_PAREN DEFRULE ruleName= NAME documentation= STRING ruleAttribute[rule] ( ce[lhs] )* '=>' engine= rhs RIGHT_PAREN )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:236:4: loc= LEFT_PAREN DEFRULE ruleName= NAME documentation= STRING ruleAttribute[rule] ( ce[lhs] )* '=>' engine= rhs RIGHT_PAREN
+            {
+                loc = (Token) input.LT( 1 );
+                match( input,
+                       LEFT_PAREN,
+                       FOLLOW_LEFT_PAREN_in_defrule68 );
+                match( input,
+                       DEFRULE,
+                       FOLLOW_DEFRULE_in_defrule76 );
+                ruleName = (Token) input.LT( 1 );
+                match( input,
+                       NAME,
+                       FOLLOW_NAME_in_defrule80 );
+
+                debug( "start rule: " + ruleName.getText() );
+                String ruleStr = ruleName.getText();
+
+                if ( ruleStr.indexOf( "::" ) >= 0 ) {
+                    String mod = ruleStr.substring( 0,
+                                                    ruleStr.indexOf( "::" ) );
+                    ruleStr = ruleStr.substring( ruleStr.indexOf( "::" ) + 2 );
+                    module = new AttributeDescr( "agenda-group",
+                                                 mod );
+                    module.setLocation( offset( ruleName.getLine() ),
+                                        ruleName.getCharPositionInLine() );
+                    module.setStartCharacter( ((CommonToken) ruleName).getStartIndex() );
+                    module.setEndCharacter( ((CommonToken) ruleName).getStopIndex() );
+                }
+
+                rule = new RuleDescr( ruleStr,
+                                      null );
+                if ( module != null ) {
+                    rule.addAttribute( module );
+                }
+
+                rule.setLocation( offset( loc.getLine() ),
+                                  loc.getCharPositionInLine() );
+                rule.setStartCharacter( ((CommonToken) loc).getStartIndex() );
+
+                // not sure how you define where a LHS starts in clips, so just putting it here for now
+                lhs = new AndDescr();
+                rule.setLhs( lhs );
+                lhs.setLocation( offset( loc.getLine() ),
+                                 loc.getCharPositionInLine() );
+                lhs.setStartCharacter( ((CommonToken) loc).getStartIndex() );
+
+                documentation = (Token) input.LT( 1 );
+                match( input,
+                       STRING,
+                       FOLLOW_STRING_in_defrule92 );
+
+                // do nothing here for now
+
+                pushFollow( FOLLOW_ruleAttribute_in_defrule98 );
+                ruleAttribute( rule );
+                _fsp--;
+
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:271:3: ( ce[lhs] )*
+                loop1 : do {
+                    int alt1 = 2;
+                    int LA1_0 = input.LA( 1 );
+                    if ( (LA1_0 == LEFT_PAREN || LA1_0 == VAR) ) {
+                        alt1 = 1;
+                    }
+
+                    switch ( alt1 ) {
+                        case 1 :
+                            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:271:3: ce[lhs]
+                        {
+                            pushFollow( FOLLOW_ce_in_defrule106 );
+                            ce( lhs );
+                            _fsp--;
+
+                        }
+                            break;
+
+                        default :
+                            break loop1;
+                    }
+                } while ( true );
+
+                match( input,
+                       41,
+                       FOLLOW_41_in_defrule115 );
+                pushFollow( FOLLOW_rhs_in_defrule124 );
+                engine = rhs();
+                _fsp--;
+
+                rule.setConsequence( engine );
+                match( input,
+                       RIGHT_PAREN,
+                       FOLLOW_RIGHT_PAREN_in_defrule133 );
+
+            }
+
+        } catch ( RecognitionException re ) {
+            reportError( re );
+            recover( input,
+                     re );
+        } finally {
+        }
+        return rule;
+    }
+
+    // $ANTLR end defrule
+
+    // $ANTLR start ruleAttribute
+    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:281:1: ruleAttribute[RuleDescr rule] : ( LEFT_PAREN 'declare' ( LEFT_PAREN d= salience RIGHT_PAREN )? RIGHT_PAREN )? ;
+    public void ruleAttribute(RuleDescr rule) throws RecognitionException {
+        AttributeDescr d = null;
+
+        try {
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:283:3: ( ( LEFT_PAREN 'declare' ( LEFT_PAREN d= salience RIGHT_PAREN )? RIGHT_PAREN )? )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:283:3: ( LEFT_PAREN 'declare' ( LEFT_PAREN d= salience RIGHT_PAREN )? RIGHT_PAREN )?
+            {
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:283:3: ( LEFT_PAREN 'declare' ( LEFT_PAREN d= salience RIGHT_PAREN )? RIGHT_PAREN )?
+                int alt3 = 2;
+                int LA3_0 = input.LA( 1 );
+                if ( (LA3_0 == LEFT_PAREN) ) {
+                    int LA3_1 = input.LA( 2 );
+                    if ( (LA3_1 == DECLARE) ) {
+                        alt3 = 1;
+                    }
+                }
+                switch ( alt3 ) {
+                    case 1 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:283:5: LEFT_PAREN 'declare' ( LEFT_PAREN d= salience RIGHT_PAREN )? RIGHT_PAREN
+                    {
+                        match( input,
+                               LEFT_PAREN,
+                               FOLLOW_LEFT_PAREN_in_ruleAttribute150 );
+                        match( input,
+                               DECLARE,
+                               FOLLOW_DECLARE_in_ruleAttribute152 );
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:284:4: ( LEFT_PAREN d= salience RIGHT_PAREN )?
+                        int alt2 = 2;
+                        int LA2_0 = input.LA( 1 );
+                        if ( (LA2_0 == LEFT_PAREN) ) {
+                            alt2 = 1;
+                        }
+                        switch ( alt2 ) {
+                            case 1 :
+                                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:284:6: LEFT_PAREN d= salience RIGHT_PAREN
+                            {
+                                match( input,
+                                       LEFT_PAREN,
+                                       FOLLOW_LEFT_PAREN_in_ruleAttribute159 );
+                                pushFollow( FOLLOW_salience_in_ruleAttribute163 );
+                                d = salience();
+                                _fsp--;
+
+                                rule.addAttribute( d );
+                                match( input,
+                                       RIGHT_PAREN,
+                                       FOLLOW_RIGHT_PAREN_in_ruleAttribute167 );
+
+                            }
+                                break;
+
+                        }
+
+                        match( input,
+                               RIGHT_PAREN,
+                               FOLLOW_RIGHT_PAREN_in_ruleAttribute174 );
+
+                    }
+                        break;
+
+                }
+
+            }
+
+        } catch ( RecognitionException re ) {
+            reportError( re );
+            recover( input,
+                     re );
+        } finally {
+        }
+        return;
+    }
+
+    // $ANTLR end ruleAttribute
+
+    // $ANTLR start salience
+    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:288:1: salience returns [AttributeDescr d ] : loc= SALIENCE i= INT ;
+    public AttributeDescr salience() throws RecognitionException {
+        AttributeDescr d = null;
+
+        Token loc = null;
+        Token i = null;
+
+        d = null;
+
+        try {
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:293:3: (loc= SALIENCE i= INT )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:293:3: loc= SALIENCE i= INT
+            {
+                loc = (Token) input.LT( 1 );
+                match( input,
+                       SALIENCE,
+                       FOLLOW_SALIENCE_in_salience204 );
+                i = (Token) input.LT( 1 );
+                match( input,
+                       INT,
+                       FOLLOW_INT_in_salience208 );
+
+                d = new AttributeDescr( "salience",
+                                        i.getText() );
+                d.setLocation( offset( loc.getLine() ),
+                               loc.getCharPositionInLine() );
+                d.setStartCharacter( ((CommonToken) loc).getStartIndex() );
+                d.setEndCharacter( ((CommonToken) i).getStopIndex() );
+
+            }
+
+        } catch ( RecognitionException re ) {
+            reportError( re );
+            recover( input,
+                     re );
+        } finally {
+        }
+        return d;
+    }
+
+    // $ANTLR end salience
+
+    // $ANTLR start ce
+    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:303:1: ce[ConditionalElementDescr in_ce] : ( and_ce[in_ce] | or_ce[in_ce] | not_ce[in_ce] | exists_ce[in_ce] | eval_ce[in_ce] | normal_pattern[in_ce] | bound_pattern[in_ce] ) ;
+    public void ce(ConditionalElementDescr in_ce) throws RecognitionException {
+        try {
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:304:4: ( ( and_ce[in_ce] | or_ce[in_ce] | not_ce[in_ce] | exists_ce[in_ce] | eval_ce[in_ce] | normal_pattern[in_ce] | bound_pattern[in_ce] ) )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:304:4: ( and_ce[in_ce] | or_ce[in_ce] | not_ce[in_ce] | exists_ce[in_ce] | eval_ce[in_ce] | normal_pattern[in_ce] | bound_pattern[in_ce] )
+            {
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:304:4: ( and_ce[in_ce] | or_ce[in_ce] | not_ce[in_ce] | exists_ce[in_ce] | eval_ce[in_ce] | normal_pattern[in_ce] | bound_pattern[in_ce] )
+                int alt4 = 7;
+                int LA4_0 = input.LA( 1 );
+                if ( (LA4_0 == LEFT_PAREN) ) {
+                    switch ( input.LA( 2 ) ) {
+                        case NAME :
+                            alt4 = 6;
+                            break;
+                        case AND :
+                            alt4 = 1;
+                            break;
+                        case OR :
+                            alt4 = 2;
+                            break;
+                        case EXISTS :
+                            alt4 = 4;
+                            break;
+                        case NOT :
+                            alt4 = 3;
+                            break;
+                        case TEST :
+                            alt4 = 5;
+                            break;
+                        default :
+                            NoViableAltException nvae = new NoViableAltException( "304:4: ( and_ce[in_ce] | or_ce[in_ce] | not_ce[in_ce] | exists_ce[in_ce] | eval_ce[in_ce] | normal_pattern[in_ce] | bound_pattern[in_ce] )",
+                                                                                  4,
+                                                                                  1,
+                                                                                  input );
+
+                            throw nvae;
+                    }
+
+                } else if ( (LA4_0 == VAR) ) {
+                    alt4 = 7;
+                } else {
+                    NoViableAltException nvae = new NoViableAltException( "304:4: ( and_ce[in_ce] | or_ce[in_ce] | not_ce[in_ce] | exists_ce[in_ce] | eval_ce[in_ce] | normal_pattern[in_ce] | bound_pattern[in_ce] )",
+                                                                          4,
+                                                                          0,
+                                                                          input );
+
+                    throw nvae;
+                }
+                switch ( alt4 ) {
+                    case 1 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:304:8: and_ce[in_ce]
+                    {
+                        pushFollow( FOLLOW_and_ce_in_ce234 );
+                        and_ce( in_ce );
+                        _fsp--;
+
+                    }
+                        break;
+                    case 2 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:305:7: or_ce[in_ce]
+                    {
+                        pushFollow( FOLLOW_or_ce_in_ce244 );
+                        or_ce( in_ce );
+                        _fsp--;
+
+                    }
+                        break;
+                    case 3 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:306:7: not_ce[in_ce]
+                    {
+                        pushFollow( FOLLOW_not_ce_in_ce253 );
+                        not_ce( in_ce );
+                        _fsp--;
+
+                    }
+                        break;
+                    case 4 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:307:7: exists_ce[in_ce]
+                    {
+                        pushFollow( FOLLOW_exists_ce_in_ce262 );
+                        exists_ce( in_ce );
+                        _fsp--;
+
+                    }
+                        break;
+                    case 5 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:308:8: eval_ce[in_ce]
+                    {
+                        pushFollow( FOLLOW_eval_ce_in_ce276 );
+                        eval_ce( in_ce );
+                        _fsp--;
+
+                    }
+                        break;
+                    case 6 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:309:7: normal_pattern[in_ce]
+                    {
+                        pushFollow( FOLLOW_normal_pattern_in_ce290 );
+                        normal_pattern( in_ce );
+                        _fsp--;
+
+                    }
+                        break;
+                    case 7 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:310:7: bound_pattern[in_ce]
+                    {
+                        pushFollow( FOLLOW_bound_pattern_in_ce299 );
+                        bound_pattern( in_ce );
+                        _fsp--;
+
+                    }
+                        break;
+
+                }
+
+            }
+
+        } catch ( RecognitionException re ) {
+            reportError( re );
+            recover( input,
+                     re );
+        } finally {
+        }
+        return;
+    }
+
+    // $ANTLR end ce
+
+    // $ANTLR start rhs
+    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:314:1: rhs returns [ExecutionEngine engine] : (fc= lisp_list[context, new LispForm(context) ] )* ;
+    public ExecutionEngine rhs() throws RecognitionException {
+        ExecutionEngine engine = null;
+
+        ValueHandler fc = null;
+
+        engine = new BlockExecutionEngine();
+        ExecutionBuildContext context = new ExecutionBuildContext( engine,
+                                                                   functionRegistry );
+
+        try {
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:321:3: ( (fc= lisp_list[context, new LispForm(context) ] )* )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:321:3: (fc= lisp_list[context, new LispForm(context) ] )*
+            {
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:321:3: (fc= lisp_list[context, new LispForm(context) ] )*
+                loop5 : do {
+                    int alt5 = 2;
+                    int LA5_0 = input.LA( 1 );
+                    if ( (LA5_0 == LEFT_PAREN) ) {
+                        alt5 = 1;
+                    }
+
+                    switch ( alt5 ) {
+                        case 1 :
+                            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:321:4: fc= lisp_list[context, new LispForm(context) ]
+                        {
+                            pushFollow( FOLLOW_lisp_list_in_rhs331 );
+                            fc = lisp_list( context,
+                                            new LispForm( context ) );
+                            _fsp--;
+
+                            context.addFunction( (FunctionCaller) fc );
+
+                        }
+                            break;
+
+                        default :
+                            break loop5;
+                    }
+                } while ( true );
+
+            }
+
+        } catch ( RecognitionException re ) {
+            reportError( re );
+            recover( input,
+                     re );
+        } finally {
+        }
+        return engine;
+    }
+
+    // $ANTLR end rhs
+
+    // $ANTLR start and_ce
+    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:324:1: and_ce[ConditionalElementDescr in_ce] : LEFT_PAREN AND ( ce[andDescr] )+ RIGHT_PAREN ;
+    public void and_ce(ConditionalElementDescr in_ce) throws RecognitionException {
+
+        AndDescr andDescr = null;
+
+        try {
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:328:4: ( LEFT_PAREN AND ( ce[andDescr] )+ RIGHT_PAREN )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:328:4: LEFT_PAREN AND ( ce[andDescr] )+ RIGHT_PAREN
+            {
+                match( input,
+                       LEFT_PAREN,
+                       FOLLOW_LEFT_PAREN_in_and_ce359 );
+                match( input,
+                       AND,
+                       FOLLOW_AND_in_and_ce364 );
+
+                andDescr = new AndDescr();
+                in_ce.addDescr( andDescr );
+
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:333:3: ( ce[andDescr] )+
+                int cnt6 = 0;
+                loop6 : do {
+                    int alt6 = 2;
+                    int LA6_0 = input.LA( 1 );
+                    if ( (LA6_0 == LEFT_PAREN || LA6_0 == VAR) ) {
+                        alt6 = 1;
+                    }
+
+                    switch ( alt6 ) {
+                        case 1 :
+                            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:333:3: ce[andDescr]
+                        {
+                            pushFollow( FOLLOW_ce_in_and_ce370 );
+                            ce( andDescr );
+                            _fsp--;
+
+                        }
+                            break;
+
+                        default :
+                            if ( cnt6 >= 1 ) break loop6;
+                            EarlyExitException eee = new EarlyExitException( 6,
+                                                                             input );
+                            throw eee;
+                    }
+                    cnt6++;
+                } while ( true );
+
+                match( input,
+                       RIGHT_PAREN,
+                       FOLLOW_RIGHT_PAREN_in_and_ce379 );
+
+            }
+
+        } catch ( RecognitionException re ) {
+            reportError( re );
+            recover( input,
+                     re );
+        } finally {
+        }
+        return;
+    }
+
+    // $ANTLR end and_ce
+
+    // $ANTLR start or_ce
+    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:337:1: or_ce[ConditionalElementDescr in_ce] : LEFT_PAREN OR ( ce[orDescr] )+ RIGHT_PAREN ;
+    public void or_ce(ConditionalElementDescr in_ce) throws RecognitionException {
+
+        OrDescr orDescr = null;
+
+        try {
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:341:4: ( LEFT_PAREN OR ( ce[orDescr] )+ RIGHT_PAREN )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:341:4: LEFT_PAREN OR ( ce[orDescr] )+ RIGHT_PAREN
+            {
+                match( input,
+                       LEFT_PAREN,
+                       FOLLOW_LEFT_PAREN_in_or_ce407 );
+                match( input,
+                       OR,
+                       FOLLOW_OR_in_or_ce412 );
+
+                orDescr = new OrDescr();
+                in_ce.addDescr( orDescr );
+
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:346:3: ( ce[orDescr] )+
+                int cnt7 = 0;
+                loop7 : do {
+                    int alt7 = 2;
+                    int LA7_0 = input.LA( 1 );
+                    if ( (LA7_0 == LEFT_PAREN || LA7_0 == VAR) ) {
+                        alt7 = 1;
+                    }
+
+                    switch ( alt7 ) {
+                        case 1 :
+                            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:346:3: ce[orDescr]
+                        {
+                            pushFollow( FOLLOW_ce_in_or_ce418 );
+                            ce( orDescr );
+                            _fsp--;
+
+                        }
+                            break;
+
+                        default :
+                            if ( cnt7 >= 1 ) break loop7;
+                            EarlyExitException eee = new EarlyExitException( 7,
+                                                                             input );
+                            throw eee;
+                    }
+                    cnt7++;
+                } while ( true );
+
+                match( input,
+                       RIGHT_PAREN,
+                       FOLLOW_RIGHT_PAREN_in_or_ce427 );
+
+            }
+
+        } catch ( RecognitionException re ) {
+            reportError( re );
+            recover( input,
+                     re );
+        } finally {
+        }
+        return;
+    }
+
+    // $ANTLR end or_ce
+
+    // $ANTLR start not_ce
+    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:350:1: not_ce[ConditionalElementDescr in_ce] : LEFT_PAREN NOT ce[notDescr] RIGHT_PAREN ;
+    public void not_ce(ConditionalElementDescr in_ce) throws RecognitionException {
+
+        NotDescr notDescr = null;
+
+        try {
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:354:4: ( LEFT_PAREN NOT ce[notDescr] RIGHT_PAREN )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:354:4: LEFT_PAREN NOT ce[notDescr] RIGHT_PAREN
+            {
+                match( input,
+                       LEFT_PAREN,
+                       FOLLOW_LEFT_PAREN_in_not_ce455 );
+                match( input,
+                       NOT,
+                       FOLLOW_NOT_in_not_ce460 );
+
+                notDescr = new NotDescr();
+                in_ce.addDescr( notDescr );
+
+                pushFollow( FOLLOW_ce_in_not_ce466 );
+                ce( notDescr );
+                _fsp--;
+
+                match( input,
+                       RIGHT_PAREN,
+                       FOLLOW_RIGHT_PAREN_in_not_ce474 );
+
+            }
+
+        } catch ( RecognitionException re ) {
+            reportError( re );
+            recover( input,
+                     re );
+        } finally {
+        }
+        return;
+    }
+
+    // $ANTLR end not_ce
+
+    // $ANTLR start exists_ce
+    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:363:1: exists_ce[ConditionalElementDescr in_ce] : LEFT_PAREN EXISTS ce[existsDescr] RIGHT_PAREN ;
+    public void exists_ce(ConditionalElementDescr in_ce) throws RecognitionException {
+
+        ExistsDescr existsDescr = null;
+
+        try {
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:367:4: ( LEFT_PAREN EXISTS ce[existsDescr] RIGHT_PAREN )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:367:4: LEFT_PAREN EXISTS ce[existsDescr] RIGHT_PAREN
+            {
+                match( input,
+                       LEFT_PAREN,
+                       FOLLOW_LEFT_PAREN_in_exists_ce503 );
+                match( input,
+                       EXISTS,
+                       FOLLOW_EXISTS_in_exists_ce508 );
+
+                existsDescr = new ExistsDescr();
+                in_ce.addDescr( existsDescr );
+
+                pushFollow( FOLLOW_ce_in_exists_ce514 );
+                ce( existsDescr );
+                _fsp--;
+
+                match( input,
+                       RIGHT_PAREN,
+                       FOLLOW_RIGHT_PAREN_in_exists_ce522 );
+
+            }
+
+        } catch ( RecognitionException re ) {
+            reportError( re );
+            recover( input,
+                     re );
+        } finally {
+        }
+        return;
+    }
+
+    // $ANTLR end exists_ce
+
+    // $ANTLR start eval_ce
+    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:376:1: eval_ce[ConditionalElementDescr in_ce] : LEFT_PAREN TEST fc= lisp_list[context, new LispForm(context)] RIGHT_PAREN ;
+    public void eval_ce(ConditionalElementDescr in_ce) throws RecognitionException {
+        ValueHandler fc = null;
+
+        EvalDescr evalDescr = null;
+        ExecutionEngine engine = new CLPEval();
+        ExecutionBuildContext context = new ExecutionBuildContext( engine,
+                                                                   functionRegistry );
+
+        try {
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:382:4: ( LEFT_PAREN TEST fc= lisp_list[context, new LispForm(context)] RIGHT_PAREN )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:382:4: LEFT_PAREN TEST fc= lisp_list[context, new LispForm(context)] RIGHT_PAREN
+            {
+                match( input,
+                       LEFT_PAREN,
+                       FOLLOW_LEFT_PAREN_in_eval_ce550 );
+                match( input,
+                       TEST,
+                       FOLLOW_TEST_in_eval_ce555 );
+
+                evalDescr = new EvalDescr();
+                in_ce.addDescr( evalDescr );
+
+                pushFollow( FOLLOW_lisp_list_in_eval_ce563 );
+                fc = lisp_list( context,
+                                new LispForm( context ) );
+                _fsp--;
+
+                engine.addFunction( (FunctionCaller) fc );
+                evalDescr.setContent( engine );
+
+                match( input,
+                       RIGHT_PAREN,
+                       FOLLOW_RIGHT_PAREN_in_eval_ce574 );
+
+            }
+
+        } catch ( RecognitionException re ) {
+            reportError( re );
+            recover( input,
+                     re );
+        } finally {
+        }
+        return;
+    }
+
+    // $ANTLR end eval_ce
+
+    // $ANTLR start normal_pattern
+    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:394:1: normal_pattern[ConditionalElementDescr in_ce] : LEFT_PAREN name= NAME ( field_constriant[column] )* RIGHT_PAREN ;
+    public void normal_pattern(ConditionalElementDescr in_ce) throws RecognitionException {
+        Token name = null;
+
+        ColumnDescr column = null;
+
+        try {
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:398:4: ( LEFT_PAREN name= NAME ( field_constriant[column] )* RIGHT_PAREN )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:398:4: LEFT_PAREN name= NAME ( field_constriant[column] )* RIGHT_PAREN
+            {
+                match( input,
+                       LEFT_PAREN,
+                       FOLLOW_LEFT_PAREN_in_normal_pattern602 );
+                name = (Token) input.LT( 1 );
+                match( input,
+                       NAME,
+                       FOLLOW_NAME_in_normal_pattern609 );
+
+                column = new ColumnDescr( name.getText() );
+                in_ce.addDescr( column );
+
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:403:3: ( field_constriant[column] )*
+                loop8 : do {
+                    int alt8 = 2;
+                    int LA8_0 = input.LA( 1 );
+                    if ( (LA8_0 == LEFT_PAREN) ) {
+                        alt8 = 1;
+                    }
+
+                    switch ( alt8 ) {
+                        case 1 :
+                            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:403:3: field_constriant[column]
+                        {
+                            pushFollow( FOLLOW_field_constriant_in_normal_pattern615 );
+                            field_constriant( column );
+                            _fsp--;
+
+                        }
+                            break;
+
+                        default :
+                            break loop8;
+                    }
+                } while ( true );
+
+                match( input,
+                       RIGHT_PAREN,
+                       FOLLOW_RIGHT_PAREN_in_normal_pattern625 );
+
+            }
+
+        } catch ( RecognitionException re ) {
+            reportError( re );
+            recover( input,
+                     re );
+        } finally {
+        }
+        return;
+    }
+
+    // $ANTLR end normal_pattern
+
+    // $ANTLR start bound_pattern
+    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:409:1: bound_pattern[ConditionalElementDescr in_ce] : var= VAR ASSIGN_OP LEFT_PAREN name= NAME ( field_constriant[column] )* RIGHT_PAREN ;
+    public void bound_pattern(ConditionalElementDescr in_ce) throws RecognitionException {
+        Token var = null;
+        Token name = null;
+
+        ColumnDescr column = null;
+        String identifier = null;
+
+        try {
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:414:4: (var= VAR ASSIGN_OP LEFT_PAREN name= NAME ( field_constriant[column] )* RIGHT_PAREN )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:414:4: var= VAR ASSIGN_OP LEFT_PAREN name= NAME ( field_constriant[column] )* RIGHT_PAREN
+            {
+                var = (Token) input.LT( 1 );
+                match( input,
+                       VAR,
+                       FOLLOW_VAR_in_bound_pattern653 );
+
+                identifier = var.getText();
+
+                match( input,
+                       ASSIGN_OP,
+                       FOLLOW_ASSIGN_OP_in_bound_pattern659 );
+                match( input,
+                       LEFT_PAREN,
+                       FOLLOW_LEFT_PAREN_in_bound_pattern661 );
+                name = (Token) input.LT( 1 );
+                match( input,
+                       NAME,
+                       FOLLOW_NAME_in_bound_pattern665 );
+
+                column = new ColumnDescr( name.getText() );
+                column.setIdentifier( identifier );
+                in_ce.addDescr( column );
+
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:423:3: ( field_constriant[column] )*
+                loop9 : do {
+                    int alt9 = 2;
+                    int LA9_0 = input.LA( 1 );
+                    if ( (LA9_0 == LEFT_PAREN) ) {
+                        alt9 = 1;
+                    }
+
+                    switch ( alt9 ) {
+                        case 1 :
+                            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:423:3: field_constriant[column]
+                        {
+                            pushFollow( FOLLOW_field_constriant_in_bound_pattern674 );
+                            field_constriant( column );
+                            _fsp--;
+
+                        }
+                            break;
+
+                        default :
+                            break loop9;
+                    }
+                } while ( true );
+
+                match( input,
+                       RIGHT_PAREN,
+                       FOLLOW_RIGHT_PAREN_in_bound_pattern681 );
+
+            }
+
+        } catch ( RecognitionException re ) {
+            reportError( re );
+            recover( input,
+                     re );
+        } finally {
+        }
+        return;
+    }
+
+    // $ANTLR end bound_pattern
+
+    // $ANTLR start field_constriant
+    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:427:1: field_constriant[ColumnDescr column] : LEFT_PAREN f= NAME connected_constraint[fc, column] RIGHT_PAREN ;
+    public void field_constriant(ColumnDescr column) throws RecognitionException {
+        Token f = null;
+
+        List list = new ArrayList();
+        FieldBindingDescr fbd = null;
+        FieldConstraintDescr fc = null;
+        String op = "==";
+
+        try {
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:435:3: ( LEFT_PAREN f= NAME connected_constraint[fc, column] RIGHT_PAREN )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:435:3: LEFT_PAREN f= NAME connected_constraint[fc, column] RIGHT_PAREN
+            {
+                match( input,
+                       LEFT_PAREN,
+                       FOLLOW_LEFT_PAREN_in_field_constriant712 );
+                f = (Token) input.LT( 1 );
+                match( input,
+                       NAME,
+                       FOLLOW_NAME_in_field_constriant716 );
+
+                fc = new FieldConstraintDescr( f.getText() );
+                fc.setLocation( offset( f.getLine() ),
+                                f.getCharPositionInLine() );
+                fc.setStartCharacter( ((CommonToken) f).getStartIndex() );
+                column.addDescr( fc );
+
+                pushFollow( FOLLOW_connected_constraint_in_field_constriant731 );
+                connected_constraint( fc,
+                                      column );
+                _fsp--;
+
+                match( input,
+                       RIGHT_PAREN,
+                       FOLLOW_RIGHT_PAREN_in_field_constriant737 );
+
+            }
+
+        } catch ( RecognitionException re ) {
+            reportError( re );
+            recover( input,
+                     re );
+        } finally {
+        }
+        return;
+    }
+
+    // $ANTLR end field_constriant
+
+    // $ANTLR start connected_constraint
+    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:447:1: connected_constraint[FieldConstraintDescr fc, ColumnDescr column] : restriction[fc, column] ( AMPERSAND connected_constraint[fc, column] | PIPE connected_constraint[fc, column] )? ;
+    public void connected_constraint(FieldConstraintDescr fc,
+                                     ColumnDescr column) throws RecognitionException {
+        try {
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:449:2: ( restriction[fc, column] ( AMPERSAND connected_constraint[fc, column] | PIPE connected_constraint[fc, column] )? )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:449:2: restriction[fc, column] ( AMPERSAND connected_constraint[fc, column] | PIPE connected_constraint[fc, column] )?
+            {
+                pushFollow( FOLLOW_restriction_in_connected_constraint753 );
+                restriction( fc,
+                             column );
+                _fsp--;
+
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:450:2: ( AMPERSAND connected_constraint[fc, column] | PIPE connected_constraint[fc, column] )?
+                int alt10 = 3;
+                int LA10_0 = input.LA( 1 );
+                if ( (LA10_0 == AMPERSAND) ) {
+                    alt10 = 1;
+                } else if ( (LA10_0 == PIPE) ) {
+                    alt10 = 2;
+                }
+                switch ( alt10 ) {
+                    case 1 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:451:6: AMPERSAND connected_constraint[fc, column]
+                    {
+                        match( input,
+                               AMPERSAND,
+                               FOLLOW_AMPERSAND_in_connected_constraint765 );
+                        fc.addRestriction( new RestrictionConnectiveDescr( RestrictionConnectiveDescr.AND ) );
+                        pushFollow( FOLLOW_connected_constraint_in_connected_constraint774 );
+                        connected_constraint( fc,
+                                              column );
+                        _fsp--;
+
+                    }
+                        break;
+                    case 2 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:454:6: PIPE connected_constraint[fc, column]
+                    {
+                        match( input,
+                               PIPE,
+                               FOLLOW_PIPE_in_connected_constraint786 );
+                        fc.addRestriction( new RestrictionConnectiveDescr( RestrictionConnectiveDescr.OR ) );
+                        pushFollow( FOLLOW_connected_constraint_in_connected_constraint795 );
+                        connected_constraint( fc,
+                                              column );
+                        _fsp--;
+
+                    }
+                        break;
+
+                }
+
+            }
+
+        } catch ( RecognitionException re ) {
+            reportError( re );
+            recover( input,
+                     re );
+        } finally {
+        }
+        return;
+    }
+
+    // $ANTLR end connected_constraint
+
+    // $ANTLR start restriction
+    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:459:1: restriction[FieldConstraintDescr fc, ColumnDescr column] : ( TILDE )? ( predicate_constraint[op, column] | return_value_restriction[op, fc] | variable_restriction[op, fc] | lc= literal_restriction ) ;
+    public void restriction(FieldConstraintDescr fc,
+                            ColumnDescr column) throws RecognitionException {
+        String lc = null;
+
+        String op = "==";
+
+        try {
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:463:4: ( ( TILDE )? ( predicate_constraint[op, column] | return_value_restriction[op, fc] | variable_restriction[op, fc] | lc= literal_restriction ) )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:463:4: ( TILDE )? ( predicate_constraint[op, column] | return_value_restriction[op, fc] | variable_restriction[op, fc] | lc= literal_restriction )
+            {
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:463:4: ( TILDE )?
+                int alt11 = 2;
+                int LA11_0 = input.LA( 1 );
+                if ( (LA11_0 == TILDE) ) {
+                    alt11 = 1;
+                }
+                switch ( alt11 ) {
+                    case 1 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:463:5: TILDE
+                    {
+                        match( input,
+                               TILDE,
+                               FOLLOW_TILDE_in_restriction821 );
+                        op = "!=";
+
+                    }
+                        break;
+
+                }
+
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:464:3: ( predicate_constraint[op, column] | return_value_restriction[op, fc] | variable_restriction[op, fc] | lc= literal_restriction )
+                int alt12 = 4;
+                switch ( input.LA( 1 ) ) {
+                    case COLON :
+                        alt12 = 1;
+                        break;
+                    case EQUALS :
+                        alt12 = 2;
+                        break;
+                    case VAR :
+                        alt12 = 3;
+                        break;
+                    case NAME :
+                    case STRING :
+                    case INT :
+                    case FLOAT :
+                    case BOOL :
+                    case NULL :
+                        alt12 = 4;
+                        break;
+                    default :
+                        NoViableAltException nvae = new NoViableAltException( "464:3: ( predicate_constraint[op, column] | return_value_restriction[op, fc] | variable_restriction[op, fc] | lc= literal_restriction )",
+                                                                              12,
+                                                                              0,
+                                                                              input );
+
+                        throw nvae;
+                }
+
+                switch ( alt12 ) {
+                    case 1 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:464:5: predicate_constraint[op, column]
+                    {
+                        pushFollow( FOLLOW_predicate_constraint_in_restriction837 );
+                        predicate_constraint( op,
+                                              column );
+                        _fsp--;
+
+                    }
+                        break;
+                    case 2 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:465:7: return_value_restriction[op, fc]
+                    {
+                        pushFollow( FOLLOW_return_value_restriction_in_restriction853 );
+                        return_value_restriction( op,
+                                                  fc );
+                        _fsp--;
+
+                    }
+                        break;
+                    case 3 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:466:7: variable_restriction[op, fc]
+                    {
+                        pushFollow( FOLLOW_variable_restriction_in_restriction862 );
+                        variable_restriction( op,
+                                              fc );
+                        _fsp--;
+
+                    }
+                        break;
+                    case 4 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:467:8: lc= literal_restriction
+                    {
+                        pushFollow( FOLLOW_literal_restriction_in_restriction874 );
+                        lc = literal_restriction();
+                        _fsp--;
+
+                        fc.addRestriction( new LiteralRestrictionDescr( op,
+                                                                        lc,
+                                                                        true ) );
+                        op = "==";
+
+                    }
+                        break;
+
+                }
+
+            }
+
+        } catch ( RecognitionException re ) {
+            reportError( re );
+            recover( input,
+                     re );
+        } finally {
+        }
+        return;
+    }
+
+    // $ANTLR end restriction
+
+    // $ANTLR start predicate_constraint
+    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:474:1: predicate_constraint[String op, ColumnDescr column] : COLON fc= lisp_list[context, new LispForm(context)] ;
+    public void predicate_constraint(String op,
+                                     ColumnDescr column) throws RecognitionException {
+        ValueHandler fc = null;
+
+        ExecutionEngine engine = new CLPPredicate();
+        ExecutionBuildContext context = new ExecutionBuildContext( engine,
+                                                                   functionRegistry );
+
+        try {
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:479:4: ( COLON fc= lisp_list[context, new LispForm(context)] )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:479:4: COLON fc= lisp_list[context, new LispForm(context)]
+            {
+                match( input,
+                       COLON,
+                       FOLLOW_COLON_in_predicate_constraint916 );
+                pushFollow( FOLLOW_lisp_list_in_predicate_constraint922 );
+                fc = lisp_list( context,
+                                new LispForm( context ) );
+                _fsp--;
+
+                engine.addFunction( (FunctionCaller) fc );
+                column.addDescr( new PredicateDescr( engine ) );
+
+            }
+
+        } catch ( RecognitionException re ) {
+            reportError( re );
+            recover( input,
+                     re );
+        } finally {
+        }
+        return;
+    }
+
+    // $ANTLR end predicate_constraint
+
+    // $ANTLR start return_value_restriction
+    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:488:1: return_value_restriction[String op, FieldConstraintDescr fc] : EQUALS func= lisp_list[context, new LispForm(context)] ;
+    public void return_value_restriction(String op,
+                                         FieldConstraintDescr fc) throws RecognitionException {
+        ValueHandler func = null;
+
+        ExecutionEngine engine = new CLPReturnValue();
+        ExecutionBuildContext context = new ExecutionBuildContext( engine,
+                                                                   functionRegistry );
+
+        try {
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:493:4: ( EQUALS func= lisp_list[context, new LispForm(context)] )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:493:4: EQUALS func= lisp_list[context, new LispForm(context)]
+            {
+                match( input,
+                       EQUALS,
+                       FOLLOW_EQUALS_in_return_value_restriction948 );
+                pushFollow( FOLLOW_lisp_list_in_return_value_restriction955 );
+                func = lisp_list( context,
+                                  new LispForm( context ) );
+                _fsp--;
+
+                engine.addFunction( (FunctionCaller) func );
+                fc.addRestriction( new ReturnValueRestrictionDescr( op,
+                                                                    engine ) );
+
+            }
+
+        } catch ( RecognitionException re ) {
+            reportError( re );
+            recover( input,
+                     re );
+        } finally {
+        }
+        return;
+    }
+
+    // $ANTLR end return_value_restriction
+
+    // $ANTLR start variable_restriction
+    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:500:1: variable_restriction[String op, FieldConstraintDescr fc] : var= VAR ;
+    public void variable_restriction(String op,
+                                     FieldConstraintDescr fc) throws RecognitionException {
+        Token var = null;
+
+        try {
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:501:4: (var= VAR )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:501:4: var= VAR
+            {
+                var = (Token) input.LT( 1 );
+                match( input,
+                       VAR,
+                       FOLLOW_VAR_in_variable_restriction976 );
+
+                fc.addRestriction( new VariableRestrictionDescr( op,
+                                                                 var.getText() ) );
+
+            }
+
+        } catch ( RecognitionException re ) {
+            reportError( re );
+            recover( input,
+                     re );
+        } finally {
+        }
+        return;
+    }
+
+    // $ANTLR end variable_restriction
+
+    // $ANTLR start literal_restriction
+    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:507:1: literal_restriction returns [String text] : t= literal ;
+    public String literal_restriction() throws RecognitionException {
+        String text = null;
+
+        String t = null;
+
+        text = null;
+
+        try {
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:512:6: (t= literal )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:512:6: t= literal
+            {
+                pushFollow( FOLLOW_literal_in_literal_restriction1009 );
+                t = literal();
+                _fsp--;
+
+                text = t;
+
+            }
+
+        } catch ( RecognitionException re ) {
+            reportError( re );
+            recover( input,
+                     re );
+        } finally {
+        }
+        return text;
+    }
+
+    // $ANTLR end literal_restriction
+
+    // $ANTLR start lisp_list
+    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:517:1: lisp_list[ExecutionBuildContext context, LispList list] returns [ValueHandler valueHandler] : LEFT_PAREN (a= lisp_atom[context] | a= lisp_list[context, list.createList()] )* RIGHT_PAREN ;
+    public ValueHandler lisp_list(ExecutionBuildContext context,
+                                  LispList list) throws RecognitionException {
+        ValueHandler valueHandler = null;
+
+        ValueHandler a = null;
+
+        try {
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:518:4: ( LEFT_PAREN (a= lisp_atom[context] | a= lisp_list[context, list.createList()] )* RIGHT_PAREN )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:518:4: LEFT_PAREN (a= lisp_atom[context] | a= lisp_list[context, list.createList()] )* RIGHT_PAREN
+            {
+                match( input,
+                       LEFT_PAREN,
+                       FOLLOW_LEFT_PAREN_in_lisp_list1028 );
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:519:3: (a= lisp_atom[context] | a= lisp_list[context, list.createList()] )*
+                loop13 : do {
+                    int alt13 = 3;
+                    int LA13_0 = input.LA( 1 );
+                    if ( ((LA13_0 >= NAME && LA13_0 <= STRING) || LA13_0 == INT || LA13_0 == VAR || (LA13_0 >= FLOAT && LA13_0 <= NULL)) ) {
+                        alt13 = 1;
+                    } else if ( (LA13_0 == LEFT_PAREN) ) {
+                        alt13 = 2;
+                    }
+
+                    switch ( alt13 ) {
+                        case 1 :
+                            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:519:6: a= lisp_atom[context]
+                        {
+                            pushFollow( FOLLOW_lisp_atom_in_lisp_list1038 );
+                            a = lisp_atom( context );
+                            _fsp--;
+
+                            list.add( a );
+
+                        }
+                            break;
+                        case 2 :
+                            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:520:6: a= lisp_list[context, list.createList()]
+                        {
+                            pushFollow( FOLLOW_lisp_list_in_lisp_list1054 );
+                            a = lisp_list( context,
+                                           list.createList() );
+                            _fsp--;
+
+                            list.add( a );
+
+                        }
+                            break;
+
+                        default :
+                            break loop13;
+                    }
+                } while ( true );
+
+                match( input,
+                       RIGHT_PAREN,
+                       FOLLOW_RIGHT_PAREN_in_lisp_list1084 );
+                valueHandler = list.getValueHandler();
+
+            }
+
+        } catch ( RecognitionException re ) {
+            reportError( re );
+            recover( input,
+                     re );
+        } finally {
+        }
+        return valueHandler;
+    }
+
+    // $ANTLR end lisp_list
+
+    // $ANTLR start lisp_atom
+    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:526:1: lisp_atom[ExecutionBuildContext context] returns [ValueHandler value] : (t= VAR | t= STRING | t= NAME | t= FLOAT | t= INT | t= BOOL | t= NULL ) ;
+    public ValueHandler lisp_atom(ExecutionBuildContext context) throws RecognitionException {
+        ValueHandler value = null;
+
+        Token t = null;
+
+        value = null;
+
+        try {
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:531:3: ( (t= VAR | t= STRING | t= NAME | t= FLOAT | t= INT | t= BOOL | t= NULL ) )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:531:3: (t= VAR | t= STRING | t= NAME | t= FLOAT | t= INT | t= BOOL | t= NULL )
+            {
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:531:3: (t= VAR | t= STRING | t= NAME | t= FLOAT | t= INT | t= BOOL | t= NULL )
+                int alt14 = 7;
+                switch ( input.LA( 1 ) ) {
+                    case VAR :
+                        alt14 = 1;
+                        break;
+                    case STRING :
+                        alt14 = 2;
+                        break;
+                    case NAME :
+                        alt14 = 3;
+                        break;
+                    case FLOAT :
+                        alt14 = 4;
+                        break;
+                    case INT :
+                        alt14 = 5;
+                        break;
+                    case BOOL :
+                        alt14 = 6;
+                        break;
+                    case NULL :
+                        alt14 = 7;
+                        break;
+                    default :
+                        NoViableAltException nvae = new NoViableAltException( "531:3: (t= VAR | t= STRING | t= NAME | t= FLOAT | t= INT | t= BOOL | t= NULL )",
+                                                                              14,
+                                                                              0,
+                                                                              input );
+
+                        throw nvae;
+                }
+
+                switch ( alt14 ) {
+                    case 1 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:531:6: t= VAR
+                    {
+                        t = (Token) input.LT( 1 );
+                        match( input,
+                               VAR,
+                               FOLLOW_VAR_in_lisp_atom1121 );
+                        value = context.getVariableValueHandler( t.getText() );
+
+                    }
+                        break;
+                    case 2 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:532:6: t= STRING
+                    {
+                        t = (Token) input.LT( 1 );
+                        match( input,
+                               STRING,
+                               FOLLOW_STRING_in_lisp_atom1133 );
+                        value = new ObjectValueHandler( getString( t ) );
+
+                    }
+                        break;
+                    case 3 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:533:7: t= NAME
+                    {
+                        t = (Token) input.LT( 1 );
+                        match( input,
+                               NAME,
+                               FOLLOW_NAME_in_lisp_atom1145 );
+                        value = new ObjectValueHandler( t.getText() );
+
+                    }
+                        break;
+                    case 4 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:534:6: t= FLOAT
+                    {
+                        t = (Token) input.LT( 1 );
+                        match( input,
+                               FLOAT,
+                               FOLLOW_FLOAT_in_lisp_atom1160 );
+                        value = new DoubleValueHandler( t.getText() );
+
+                    }
+                        break;
+                    case 5 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:535:6: t= INT
+                    {
+                        t = (Token) input.LT( 1 );
+                        match( input,
+                               INT,
+                               FOLLOW_INT_in_lisp_atom1172 );
+                        value = new LongValueHandler( t.getText() );
+
+                    }
+                        break;
+                    case 6 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:536:6: t= BOOL
+                    {
+                        t = (Token) input.LT( 1 );
+                        match( input,
+                               BOOL,
+                               FOLLOW_BOOL_in_lisp_atom1188 );
+                        value = new BooleanValueHandler( t.getText() );
+
+                    }
+                        break;
+                    case 7 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:537:6: t= NULL
+                    {
+                        t = (Token) input.LT( 1 );
+                        match( input,
+                               NULL,
+                               FOLLOW_NULL_in_lisp_atom1206 );
+                        value = ObjectValueHandler.NULL;
+
+                    }
+                        break;
+
+                }
+
+            }
+
+        } catch ( RecognitionException re ) {
+            reportError( re );
+            recover( input,
+                     re );
+        } finally {
+        }
+        return value;
+    }
+
+    // $ANTLR end lisp_atom
+
+    // $ANTLR start literal
+    // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:541:1: literal returns [String text] : (t= STRING | t= NAME | t= INT | t= FLOAT | t= BOOL | t= NULL ) ;
+    public String literal() throws RecognitionException {
+        String text = null;
+
+        Token t = null;
+
+        text = null;
+
+        try {
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:545:4: ( (t= STRING | t= NAME | t= INT | t= FLOAT | t= BOOL | t= NULL ) )
+            // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:545:4: (t= STRING | t= NAME | t= INT | t= FLOAT | t= BOOL | t= NULL )
+            {
+                // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:545:4: (t= STRING | t= NAME | t= INT | t= FLOAT | t= BOOL | t= NULL )
+                int alt15 = 6;
+                switch ( input.LA( 1 ) ) {
+                    case STRING :
+                        alt15 = 1;
+                        break;
+                    case NAME :
+                        alt15 = 2;
+                        break;
+                    case INT :
+                        alt15 = 3;
+                        break;
+                    case FLOAT :
+                        alt15 = 4;
+                        break;
+                    case BOOL :
+                        alt15 = 5;
+                        break;
+                    case NULL :
+                        alt15 = 6;
+                        break;
+                    default :
+                        NoViableAltException nvae = new NoViableAltException( "545:4: (t= STRING | t= NAME | t= INT | t= FLOAT | t= BOOL | t= NULL )",
+                                                                              15,
+                                                                              0,
+                                                                              input );
+
+                        throw nvae;
+                }
+
+                switch ( alt15 ) {
+                    case 1 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:545:8: t= STRING
+                    {
+                        t = (Token) input.LT( 1 );
+                        match( input,
+                               STRING,
+                               FOLLOW_STRING_in_literal1242 );
+                        text = getString( t );
+
+                    }
+                        break;
+                    case 2 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:546:7: t= NAME
+                    {
+                        t = (Token) input.LT( 1 );
+                        match( input,
+                               NAME,
+                               FOLLOW_NAME_in_literal1255 );
+                        text = t.getText();
+
+                    }
+                        break;
+                    case 3 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:547:7: t= INT
+                    {
+                        t = (Token) input.LT( 1 );
+                        match( input,
+                               INT,
+                               FOLLOW_INT_in_literal1271 );
+                        text = t.getText();
+
+                    }
+                        break;
+                    case 4 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:548:7: t= FLOAT
+                    {
+                        t = (Token) input.LT( 1 );
+                        match( input,
+                               FLOAT,
+                               FOLLOW_FLOAT_in_literal1286 );
+                        text = t.getText();
+
+                    }
+                        break;
+                    case 5 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:549:7: t= BOOL
+                    {
+                        t = (Token) input.LT( 1 );
+                        match( input,
+                               BOOL,
+                               FOLLOW_BOOL_in_literal1299 );
+                        text = t.getText();
+
+                    }
+                        break;
+                    case 6 :
+                        // C:\\dev\\jbossrules\\trunk\\drools-compiler\\src\\main\\resources\\org\\drools\\clp\\CLP.g:550:7: t= NULL
+                    {
+                        t = (Token) input.LT( 1 );
+                        match( input,
+                               NULL,
+                               FOLLOW_NULL_in_literal1313 );
+                        text = null;
+
+                    }
+                        break;
+
+                }
+
+            }
+
+        } catch ( RecognitionException re ) {
+            reportError( re );
+            recover( input,
+                     re );
+        } finally {
+        }
+        return text;
+    }
+
+    // $ANTLR end literal
+
+    public static final BitSet FOLLOW_LEFT_PAREN_in_defrule68                         = new BitSet( new long[]{0x0000000000000020L} );
+    public static final BitSet FOLLOW_DEFRULE_in_defrule76                            = new BitSet( new long[]{0x0000000000000040L} );
+    public static final BitSet FOLLOW_NAME_in_defrule80                               = new BitSet( new long[]{0x0000000000000080L} );
+    public static final BitSet FOLLOW_STRING_in_defrule92                             = new BitSet( new long[]{0x0000020000010010L} );
+    public static final BitSet FOLLOW_ruleAttribute_in_defrule98                      = new BitSet( new long[]{0x0000020000010010L} );
+    public static final BitSet FOLLOW_ce_in_defrule106                                = new BitSet( new long[]{0x0000020000010010L} );
+    public static final BitSet FOLLOW_41_in_defrule115                                = new BitSet( new long[]{0x0000000000000110L} );
+    public static final BitSet FOLLOW_rhs_in_defrule124                               = new BitSet( new long[]{0x0000000000000100L} );
+    public static final BitSet FOLLOW_RIGHT_PAREN_in_defrule133                       = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_LEFT_PAREN_in_ruleAttribute150                  = new BitSet( new long[]{0x0000000010000000L} );
+    public static final BitSet FOLLOW_DECLARE_in_ruleAttribute152                     = new BitSet( new long[]{0x0000000000000110L} );
+    public static final BitSet FOLLOW_LEFT_PAREN_in_ruleAttribute159                  = new BitSet( new long[]{0x0000000000000200L} );
+    public static final BitSet FOLLOW_salience_in_ruleAttribute163                    = new BitSet( new long[]{0x0000000000000100L} );
+    public static final BitSet FOLLOW_RIGHT_PAREN_in_ruleAttribute167                 = new BitSet( new long[]{0x0000000000000100L} );
+    public static final BitSet FOLLOW_RIGHT_PAREN_in_ruleAttribute174                 = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_SALIENCE_in_salience204                         = new BitSet( new long[]{0x0000000000000400L} );
+    public static final BitSet FOLLOW_INT_in_salience208                              = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_and_ce_in_ce234                                 = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_or_ce_in_ce244                                  = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_not_ce_in_ce253                                 = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_exists_ce_in_ce262                              = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_eval_ce_in_ce276                                = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_normal_pattern_in_ce290                         = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_bound_pattern_in_ce299                          = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_lisp_list_in_rhs331                             = new BitSet( new long[]{0x0000000000000012L} );
+    public static final BitSet FOLLOW_LEFT_PAREN_in_and_ce359                         = new BitSet( new long[]{0x0000000000000800L} );
+    public static final BitSet FOLLOW_AND_in_and_ce364                                = new BitSet( new long[]{0x0000000000010010L} );
+    public static final BitSet FOLLOW_ce_in_and_ce370                                 = new BitSet( new long[]{0x0000000000010110L} );
+    public static final BitSet FOLLOW_RIGHT_PAREN_in_and_ce379                        = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_LEFT_PAREN_in_or_ce407                          = new BitSet( new long[]{0x0000000000001000L} );
+    public static final BitSet FOLLOW_OR_in_or_ce412                                  = new BitSet( new long[]{0x0000000000010010L} );
+    public static final BitSet FOLLOW_ce_in_or_ce418                                  = new BitSet( new long[]{0x0000000000010110L} );
+    public static final BitSet FOLLOW_RIGHT_PAREN_in_or_ce427                         = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_LEFT_PAREN_in_not_ce455                         = new BitSet( new long[]{0x0000000000002000L} );
+    public static final BitSet FOLLOW_NOT_in_not_ce460                                = new BitSet( new long[]{0x0000000000010010L} );
+    public static final BitSet FOLLOW_ce_in_not_ce466                                 = new BitSet( new long[]{0x0000000000000100L} );
+    public static final BitSet FOLLOW_RIGHT_PAREN_in_not_ce474                        = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_LEFT_PAREN_in_exists_ce503                      = new BitSet( new long[]{0x0000000000004000L} );
+    public static final BitSet FOLLOW_EXISTS_in_exists_ce508                          = new BitSet( new long[]{0x0000000000010010L} );
+    public static final BitSet FOLLOW_ce_in_exists_ce514                              = new BitSet( new long[]{0x0000000000000100L} );
+    public static final BitSet FOLLOW_RIGHT_PAREN_in_exists_ce522                     = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_LEFT_PAREN_in_eval_ce550                        = new BitSet( new long[]{0x0000000000008000L} );
+    public static final BitSet FOLLOW_TEST_in_eval_ce555                              = new BitSet( new long[]{0x0000000000000010L} );
+    public static final BitSet FOLLOW_lisp_list_in_eval_ce563                         = new BitSet( new long[]{0x0000000000000100L} );
+    public static final BitSet FOLLOW_RIGHT_PAREN_in_eval_ce574                       = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_LEFT_PAREN_in_normal_pattern602                 = new BitSet( new long[]{0x0000000000000040L} );
+    public static final BitSet FOLLOW_NAME_in_normal_pattern609                       = new BitSet( new long[]{0x0000000000000110L} );
+    public static final BitSet FOLLOW_field_constriant_in_normal_pattern615           = new BitSet( new long[]{0x0000000000000110L} );
+    public static final BitSet FOLLOW_RIGHT_PAREN_in_normal_pattern625                = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_VAR_in_bound_pattern653                         = new BitSet( new long[]{0x0000000000020000L} );
+    public static final BitSet FOLLOW_ASSIGN_OP_in_bound_pattern659                   = new BitSet( new long[]{0x0000000000000010L} );
+    public static final BitSet FOLLOW_LEFT_PAREN_in_bound_pattern661                  = new BitSet( new long[]{0x0000000000000040L} );
+    public static final BitSet FOLLOW_NAME_in_bound_pattern665                        = new BitSet( new long[]{0x0000000000000110L} );
+    public static final BitSet FOLLOW_field_constriant_in_bound_pattern674            = new BitSet( new long[]{0x0000000000000110L} );
+    public static final BitSet FOLLOW_RIGHT_PAREN_in_bound_pattern681                 = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_LEFT_PAREN_in_field_constriant712               = new BitSet( new long[]{0x0000000000000040L} );
+    public static final BitSet FOLLOW_NAME_in_field_constriant716                     = new BitSet( new long[]{0x0000000003F104C0L} );
+    public static final BitSet FOLLOW_connected_constraint_in_field_constriant731     = new BitSet( new long[]{0x0000000000000100L} );
+    public static final BitSet FOLLOW_RIGHT_PAREN_in_field_constriant737              = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_restriction_in_connected_constraint753          = new BitSet( new long[]{0x00000000000C0002L} );
+    public static final BitSet FOLLOW_AMPERSAND_in_connected_constraint765            = new BitSet( new long[]{0x0000000003F104C0L} );
+    public static final BitSet FOLLOW_connected_constraint_in_connected_constraint774 = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_PIPE_in_connected_constraint786                 = new BitSet( new long[]{0x0000000003F104C0L} );
+    public static final BitSet FOLLOW_connected_constraint_in_connected_constraint795 = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_TILDE_in_restriction821                         = new BitSet( new long[]{0x0000000003E104C0L} );
+    public static final BitSet FOLLOW_predicate_constraint_in_restriction837          = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_return_value_restriction_in_restriction853      = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_variable_restriction_in_restriction862          = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_literal_restriction_in_restriction874           = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_COLON_in_predicate_constraint916                = new BitSet( new long[]{0x0000000000000010L} );
+    public static final BitSet FOLLOW_lisp_list_in_predicate_constraint922            = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_EQUALS_in_return_value_restriction948           = new BitSet( new long[]{0x0000000000000010L} );
+    public static final BitSet FOLLOW_lisp_list_in_return_value_restriction955        = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_VAR_in_variable_restriction976                  = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_literal_in_literal_restriction1009              = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_LEFT_PAREN_in_lisp_list1028                     = new BitSet( new long[]{0x00000000038105D0L} );
+    public static final BitSet FOLLOW_lisp_atom_in_lisp_list1038                      = new BitSet( new long[]{0x00000000038105D0L} );
+    public static final BitSet FOLLOW_lisp_list_in_lisp_list1054                      = new BitSet( new long[]{0x00000000038105D0L} );
+    public static final BitSet FOLLOW_RIGHT_PAREN_in_lisp_list1084                    = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_VAR_in_lisp_atom1121                            = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_STRING_in_lisp_atom1133                         = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_NAME_in_lisp_atom1145                           = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_FLOAT_in_lisp_atom1160                          = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_INT_in_lisp_atom1172                            = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_BOOL_in_lisp_atom1188                           = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_NULL_in_lisp_atom1206                           = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_STRING_in_literal1242                           = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_NAME_in_literal1255                             = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_INT_in_literal1271                              = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_FLOAT_in_literal1286                            = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_BOOL_in_literal1299                             = new BitSet( new long[]{0x0000000000000002L} );
+    public static final BitSet FOLLOW_NULL_in_literal1313                             = new BitSet( new long[]{0x0000000000000002L} );
+
+}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPPredicate.java (from rev 10524, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/CLPPredicate.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPPredicate.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPPredicate.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,61 @@
+/**
+ * 
+ */
+package org.drools.clp;
+
+import java.util.Map;
+
+import org.drools.WorkingMemory;
+import org.drools.clp.valuehandlers.FunctionCaller;
+import org.drools.common.InternalWorkingMemory;
+import org.drools.reteoo.ReteTuple;
+import org.drools.rule.Declaration;
+import org.drools.spi.PredicateExpression;
+import org.drools.spi.Tuple;
+
+public class CLPPredicate
+    implements
+    PredicateExpression,
+    ExecutionEngine {
+    private FunctionCaller function;
+    private int            index;
+
+    public CLPPredicate() {
+    }
+
+    public CLPPredicate(FunctionCaller function) {
+        this.function = function;
+    }
+
+    public void addFunction(FunctionCaller function) {
+        setFunction( function );
+    }
+
+    public void setFunction(FunctionCaller function) {
+        this.function = function;
+    }
+
+    public FunctionCaller[] getFunctions() {
+        return new FunctionCaller[]{this.function};
+    }
+
+    public int getNextIndex() {
+        return this.index++;
+    }
+
+    public boolean evaluate(Object object,
+                            Tuple tuple,
+                            Declaration[] previousDeclarations,
+                            Declaration[] localDeclarations,
+                            WorkingMemory workingMemory) throws Exception {
+        ExecutionContext context = new ExecutionContext( (InternalWorkingMemory) workingMemory,
+                                                         (ReteTuple) tuple,
+                                                         object,
+                                                         this.index - 1 );
+        return this.function.getBooleanValue( context );
+    }
+
+    public void replaceTempTokens(Map variables) {
+        this.function.replaceTempTokens( variables );
+    }
+}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPReturnValue.java (from rev 10524, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/CLPReturnValue.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPReturnValue.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/CLPReturnValue.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,64 @@
+/**
+ * 
+ */
+package org.drools.clp;
+
+import java.util.Map;
+
+import org.drools.WorkingMemory;
+import org.drools.base.FieldFactory;
+import org.drools.clp.valuehandlers.FunctionCaller;
+import org.drools.common.InternalWorkingMemory;
+import org.drools.reteoo.ReteTuple;
+import org.drools.rule.Declaration;
+import org.drools.spi.FieldValue;
+import org.drools.spi.ReturnValueExpression;
+import org.drools.spi.Tuple;
+
+public class CLPReturnValue
+    implements
+    ReturnValueExpression,
+    ExecutionEngine {
+    private FunctionCaller function;
+    private int            index;
+
+    public CLPReturnValue() {
+
+    }
+
+    public CLPReturnValue(FunctionCaller function) {
+        this.function = function;
+    }
+
+    public void setFunction(FunctionCaller function) {
+        this.function = function;
+    }
+
+    public void addFunction(FunctionCaller function) {
+        setFunction( function );
+    }
+
+    public FunctionCaller[] getFunctions() {
+        return new FunctionCaller[]{this.function};
+    }
+
+    public int getNextIndex() {
+        return this.index++;
+    }
+
+    public FieldValue evaluate(Object object,
+                               Tuple tuple,
+                               Declaration[] previousDeclarations,
+                               Declaration[] localDeclarations,
+                               WorkingMemory workingMemory) throws Exception {
+        ExecutionContext context = new ExecutionContext( (InternalWorkingMemory) workingMemory,
+                                                         (ReteTuple) tuple,
+                                                         object,
+                                                         this.index - 1 );
+        return FieldFactory.getFieldValue( this.function.getBooleanValue( context ) );
+    }
+
+    public void replaceTempTokens(Map variables) {
+        this.function.replaceTempTokens( variables );
+    }
+}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/Deffunction.java (from rev 10524, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/Deffunction.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/Deffunction.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/Deffunction.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,97 @@
+package org.drools.clp;
+
+import org.drools.clp.valuehandlers.FunctionCaller;
+import org.drools.clp.valuehandlers.LocalVariableValue;
+import org.drools.clp.valuehandlers.ObjectValueHandler;
+
+public class Deffunction
+    implements
+    Function {
+    private final String     name;
+    private FunctionCaller[] functions;
+
+    private ValueHandler[]   parameters;
+
+    public Deffunction(String name) {
+        this.name = name;
+    }
+
+    public void addParameter(ValueHandler parameter) {
+        if ( parameters == null ) {
+            this.parameters = new ValueHandler[]{parameter};
+        } else {
+            ValueHandler[] temp = new ValueHandler[parameters.length + 1];
+            System.arraycopy( this.parameters,
+                              0,
+                              temp,
+                              0,
+                              this.parameters.length );
+            temp[temp.length - 1] = parameter;
+            this.parameters = temp;
+        }
+    }
+
+    public void addFunction(FunctionCaller function) {
+        if ( functions == null ) {
+            this.functions = new FunctionCaller[]{function};
+        } else {
+            FunctionCaller[] temp = new FunctionCaller[functions.length + 1];
+            System.arraycopy( this.functions,
+                              0,
+                              temp,
+                              0,
+                              this.functions.length );
+            temp[temp.length - 1] = function;
+            this.functions = temp;
+        }
+    }
+
+    public ValueHandler[] getParameters() {
+        return this.parameters;
+    }
+
+    public ValueHandler addParameterCallback(int index,
+                                             ValueHandler valueHandler,
+                                             ExecutionBuildContext context) {
+        return valueHandler;
+    }
+
+    public void initCallback(ExecutionBuildContext context) {
+    }
+
+    public ValueHandler execute(ValueHandler[] args,
+                                ExecutionContext context) {
+        ExecutionContext newContext = initContext( args,
+                                                   context );
+
+        ValueHandler returnValue = null;
+
+        for ( int i = 0, length = this.functions.length; i < length; i++ ) {
+            // We know a function always returns a ValueHandler
+            returnValue = (ValueHandler) this.functions[i].getValue( newContext );
+        }
+        return returnValue;
+    }
+
+    private ExecutionContext initContext(ValueHandler[] args,
+                                         ExecutionContext context) {
+        ExecutionContext newContext = new ExecutionContext( context.getWorkingMemory(),
+                                                            context.getTuple(),
+                                                            args.length );
+        for ( int i = 0, length = args.length; i < length; i++ ) {
+            // We know that each argument is a local variable, so we can cast and access the underlying value handler, 
+            // as we don't want the variable fully resolved at this stage, just mapped.
+            newContext.setLocalVariable( i,
+                                         ((LocalVariableValue) args[i]).getValue( context ) );
+        }
+        return newContext;
+    }
+
+    public String getName() {
+        return this.name;
+    }
+
+    public LispList createList(int index) {
+        return new LispForm();
+    }
+}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/ExecutionBuildContext.java (from rev 10524, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/ExecutionBuildContext.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/ExecutionBuildContext.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/ExecutionBuildContext.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,63 @@
+package org.drools.clp;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.drools.clp.valuehandlers.FunctionCaller;
+import org.drools.clp.valuehandlers.LocalVariableValue;
+import org.drools.clp.valuehandlers.TempTokenVariable;
+
+public class ExecutionBuildContext {
+    private Map              vars       = new HashMap();
+    private Map              properties = Collections.EMPTY_MAP;
+    private ExecutionEngine  engine;
+    private FunctionRegistry registry;
+
+    public ExecutionBuildContext(ExecutionEngine engine,
+                                 FunctionRegistry registry) {
+        this.engine = engine;
+        this.registry = registry;
+    }
+
+    public FunctionRegistry getFunctionRegistry() {
+        return this.registry;
+    }
+
+    public void addFunction(FunctionCaller function) {
+        this.engine.addFunction( function );
+    }
+
+    public Object setProperty(Object key,
+                              Object value) {
+        if ( this.properties == Collections.EMPTY_MAP ) {
+            this.properties = new HashMap();
+        }
+        return this.properties.put( key,
+                                    value );
+    }
+
+    public Object getProperty(Object key) {
+        return this.properties.get( key );
+    }
+
+    public ValueHandler createLocalVariable(String identifier) {
+        ValueHandler var = (ValueHandler) this.vars.get( identifier );
+        if ( var == null ) {
+            var = new LocalVariableValue( identifier,
+                                          this.engine.getNextIndex() );
+            this.vars.put( identifier,
+                           var );
+        }
+        return var;
+    }
+
+    public ValueHandler getVariableValueHandler(String identifier) {
+        ValueHandler var = (ValueHandler) this.vars.get( identifier );
+        if ( var == null ) {
+            var = new TempTokenVariable( identifier );
+        }
+        return var;
+    }
+
+}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/ExecutionContext.java (from rev 10518, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/ExecutionContext.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/ExecutionContext.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/ExecutionContext.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,52 @@
+package org.drools.clp;
+
+import org.drools.common.InternalWorkingMemory;
+import org.drools.reteoo.ReteTuple;
+
+public class ExecutionContext {
+    private InternalWorkingMemory workingMemory;
+    private ReteTuple             tuple;
+    private Object                object;
+    private ValueHandler[]        localVariables;
+
+    public ExecutionContext(InternalWorkingMemory workingMemory,
+                            ReteTuple tuple,
+                            int localVariableSize) {
+        this( workingMemory,
+              tuple,
+              null,
+              localVariableSize );
+    }
+
+    public ExecutionContext(InternalWorkingMemory workingMemory,
+                            ReteTuple tuple,
+                            Object object,
+                            int localVariableSize) {
+        this.workingMemory = workingMemory;
+        this.tuple = tuple;
+        this.object = object;
+        this.localVariables = new ValueHandler[localVariableSize];
+    }
+
+    public ReteTuple getTuple() {
+        return tuple;
+    }
+
+    public InternalWorkingMemory getWorkingMemory() {
+        return workingMemory;
+    }
+
+    public Object getObject() {
+        return this.object;
+    }
+
+    public ValueHandler getLocalVariable(int index) {
+        return localVariables[index];
+    }
+
+    public void setLocalVariable(int index,
+                                 ValueHandler valueHandler) {
+        this.localVariables[index] = valueHandler;
+    }
+
+}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/ExecutionEngine.java (from rev 10524, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/ExecutionEngine.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/ExecutionEngine.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/ExecutionEngine.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,11 @@
+package org.drools.clp;
+
+import org.drools.clp.valuehandlers.FunctionCaller;
+
+public interface ExecutionEngine {
+    public void addFunction(FunctionCaller function);
+
+    public int getNextIndex();
+
+    public FunctionCaller[] getFunctions();
+}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/ExpressionExecutionEngine.java (from rev 10524, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/ExpressionExecutionEngine.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/ExpressionExecutionEngine.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/ExpressionExecutionEngine.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,21 @@
+package org.drools.clp;
+
+public class ExpressionExecutionEngine { //implements Consequence, ReturnValueExpression, PredicateExpression {
+    //private Map variableMap = new HashMap();
+
+    private Function function;
+    private int      localVariableSize;
+
+    public ExpressionExecutionEngine() {
+
+    }
+
+    public ExpressionExecutionEngine(Function function) {
+        this.function = function;
+    }
+
+    public void setFunction(Function function) {
+        this.function = function;
+    }
+
+}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/Function.java (from rev 10524, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/Function.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/Function.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/Function.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,16 @@
+package org.drools.clp;
+
+public interface Function { //extends ValueHandler {
+    public ValueHandler execute(ValueHandler[] args,
+                                ExecutionContext context);
+
+    public String getName();
+
+    public void initCallback(ExecutionBuildContext context);
+
+    public ValueHandler addParameterCallback(int index,
+                                             ValueHandler valueHandler,
+                                             ExecutionBuildContext context);
+
+    public LispList createList(int index);
+}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/FunctionDelegator.java (from rev 10525, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/FunctionDelegator.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/FunctionDelegator.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/FunctionDelegator.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,58 @@
+package org.drools.clp;
+
+public class FunctionDelegator
+    implements
+    Function {
+    private Function function;
+    private String   name;
+
+    public FunctionDelegator(String name) {
+        this.name = name;
+    }
+
+    public FunctionDelegator(Function function) {
+        this.function = function;
+    }
+
+    public void setFunction(Function function) {
+        this.function = function;
+    }
+
+    public Function getFunction() {
+        return this.function;
+    }
+
+    public ValueHandler addParameterCallback(int index,
+                                             ValueHandler valueHandler,
+                                             ExecutionBuildContext context) {
+        return this.function.addParameterCallback( 0,
+                                                   valueHandler,
+                                                   context );
+    }
+
+    public void initCallback(ExecutionBuildContext context) {
+        this.function.initCallback( context );
+    }
+
+    public ValueHandler execute(ValueHandler[] args,
+                                ExecutionContext context) {
+        if ( this.function == null ) {
+            throw new RuntimeException( "Unable to find and bine Function '" + this.name + "'" );
+        }
+        return function.execute( args,
+                                 context );
+    }
+
+    public String getName() {
+        return this.function == null ? this.name : function.getName();
+    }
+
+    public LispList createList(int index) {
+        return this.function.createList( index );
+    }
+
+    public String toString() {
+        return "[FunctionDelegate " + this.function + "]";
+    }
+
+}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/FunctionRegistry.java (from rev 10524, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/FunctionRegistry.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/FunctionRegistry.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/FunctionRegistry.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,115 @@
+package org.drools.clp;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.HashMap;
+import java.util.Map;
+
+public class FunctionRegistry {
+    public Map              functions;
+
+    public BuiltinFunctions builtin;
+
+    //public Map variables;        
+
+    public FunctionRegistry(BuiltinFunctions builtin) {
+        this.functions = new HashMap();
+        //this.variables = new HashMap();
+
+        this.builtin = builtin;
+
+        try {
+            loadFunctions();
+        } catch ( IOException e ) {
+            throw new RuntimeException( e );
+        } catch ( ClassNotFoundException e ) {
+            throw new RuntimeException( e );
+        }
+    }
+
+    public void loadFunctions() throws IOException,
+                               ClassNotFoundException {
+        BufferedReader reader = new BufferedReader( new InputStreamReader( getClass().getResourceAsStream( "functions.conf" ) ) );
+        loadFunctions( reader );
+    }
+
+    public void loadFunctions(BufferedReader reader) throws IOException,
+                                                    ClassNotFoundException {
+        String line = null;
+
+        try {
+            while ( (line = reader.readLine()) != null ) {
+                Class clazz = getClass().getClassLoader().loadClass( line );
+                Function function = (Function) clazz.newInstance();
+                addFunction( function );
+            }
+        } catch ( IllegalAccessException e ) {
+            throw new RuntimeException( e );
+        } catch ( InstantiationException e ) {
+            throw new RuntimeException( e );
+        }
+    }
+
+    public Function getFunction(String name) {
+        Function function = (Function) this.functions.get( name );
+
+        if ( function == null ) {
+            // Allows for late binidng FunctionDelegators
+            function = new FunctionDelegator( name );
+            this.functions.put( name,
+                                function );
+        }
+        return function;
+    }
+
+    //    public Function createFunction(String name) {
+    //        try {
+    //            Class clazz = ( Class ) this.functions.get( name );
+    //            if ( clazz == null ) {
+    //                throw new RuntimeException( "Function '" + name + "' does not exist" );
+    //            }
+    //            return (Function) clazz.newInstance();
+    //        } catch ( InstantiationException e ) {
+    //            throw new RuntimeException( e );
+    //        } catch ( IllegalAccessException e ) {
+    //            throw new RuntimeException( e );
+    //        }
+    //    }        
+
+    public void addFunction(Function function) {
+        FunctionDelegator delegator = (FunctionDelegator) this.functions.get( function.getName() );
+
+        if ( delegator == null ) {
+            delegator = new FunctionDelegator( function.getName() );
+            this.functions.put( function.getName(),
+                                delegator );
+        }
+        delegator.setFunction( function );
+    }
+
+    //    public void init() {
+    //        this.variables.clear();
+    //    }
+    //    
+    //    public void setVariable(LocalVariableValue variable) {
+    //        this.variables.put( variable.getIdentifier(), variable );
+    //    }
+    //    
+    //    public VariableValueHandler getVariable(String identifier) {
+    //        VariableValueHandler variable = ( VariableValueHandler ) this.variables.get( identifier );
+    //        if ( identifier == null ) {
+    //            variable = new TempTokenVariable( identifier );
+    //            this.variables.put( identifier, variable );
+    //        }
+    //        return variable;
+    //    }
+
+    public int getFunctionSize() {
+        return this.functions.size();
+    }
+
+    //    public int getVariablesSize() {
+    //        return this.variables.size();
+    //    }
+}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/GeneralParseException.java (from rev 10524, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/GeneralParseException.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/GeneralParseException.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/GeneralParseException.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,39 @@
+package org.drools.clp;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed 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.
+ */
+
+import org.antlr.runtime.RecognitionException;
+
+public class GeneralParseException extends RecognitionException {
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = -1743929851876940150L;
+    private String            message;
+
+    public GeneralParseException(final String message,
+                                 final int line) {
+        this.message = message;
+        this.line = line;
+    }
+
+    public String getMessage() {
+        return this.message;
+    }
+
+}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/LispData.java (from rev 10524, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/LispData.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/LispData.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/LispData.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,39 @@
+package org.drools.clp;
+
+import org.drools.clp.valuehandlers.ListValueHandler;
+
+public class LispData
+    implements
+    LispList {
+
+    private ListValueHandler      list;
+    private ExecutionBuildContext context;
+
+    public LispData() {
+        this.list = new ListValueHandler();
+    }
+
+    public void add(ValueHandler valueHandler) {
+        this.list.add( valueHandler );
+    }
+
+    public LispList createList() {
+        LispList list = new LispForm();
+
+        list.setContext( this.context );
+
+        return list;
+    }
+
+    public ValueHandler getValueHandler() {
+        return this.list;
+    }
+
+    public void setContext(ExecutionBuildContext context) {
+        this.context = context;
+    }
+
+    public ValueHandler[] toArray() {
+        return this.list.getList();
+    }
+}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/LispForm.java (from rev 10524, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/LispForm.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/LispForm.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/LispForm.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,71 @@
+package org.drools.clp;
+
+import org.drools.clp.valuehandlers.FunctionCaller;
+
+public class LispForm
+    implements
+    LispList {
+    private ExecutionBuildContext context;
+    private FunctionCaller        caller;
+
+    public LispForm(ExecutionBuildContext context) {
+        this.context = context;
+    }
+
+    public LispForm() {
+    }
+
+    public ValueHandler getValueHandler() {
+        return this.caller;
+    }
+
+    public void add(ValueHandler valueHandler) {
+        // we know this is a string literal, so can use null for the context
+        if ( this.caller == null ) {
+            this.caller = new FunctionCaller( this.context.getFunctionRegistry().getFunction( valueHandler.getStringValue( null ) ) );
+
+            //We can only call initCallback on known functions
+            FunctionDelegator delegator = (FunctionDelegator) this.caller.getFunction();
+            if ( delegator.getFunction() != null ) {
+                delegator.getFunction().initCallback( context );
+            }
+
+        } else {
+            // we can only execute callbacks on known functions            
+            FunctionDelegator delegator = (FunctionDelegator) this.caller.getFunction();
+            if ( delegator.getFunction() != null ) {
+                int length;
+                if ( this.caller == null || this.caller.getParameters() == null ) {
+                    length = 0;
+                } else {
+                    length = (this.caller == null) ? 0 : this.caller.getParameters().length;
+                }
+                valueHandler = delegator.getFunction().addParameterCallback( length,
+                                                                             valueHandler,
+                                                                             context );
+            }
+            this.caller.addParameter( valueHandler );
+
+        }
+    }
+
+    public LispList createList() {
+        int length;
+        if ( this.caller == null || this.caller.getParameters() == null ) {
+            length = 0;
+        } else {
+            length = (this.caller == null) ? 0 : this.caller.getParameters().length;
+        }
+
+        LispList list = this.caller.createList( length );
+
+        list.setContext( this.context );
+
+        return list;
+    }
+
+    public void setContext(ExecutionBuildContext context) {
+        this.context = context;
+    }
+
+}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/LispList.java (from rev 10524, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/LispList.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/LispList.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/LispList.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,12 @@
+package org.drools.clp;
+
+public interface LispList {
+    public void add(ValueHandler valueHandler);
+
+    public LispList createList();
+
+    public ValueHandler getValueHandler();
+
+    public void setContext(ExecutionBuildContext context);
+
+}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/ValueHandler.java (from rev 10524, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/ValueHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/ValueHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/ValueHandler.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,67 @@
+package org.drools.clp;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+public interface ValueHandler {    
+    public int getValueType(ExecutionContext context);
+
+    public void setValue(ExecutionContext context,
+                         Object object);
+
+    /**
+     * 
+     */
+    public ValueHandler getValue(ExecutionContext context);
+    
+    /**
+     * Resolves to a java Object
+     */
+    public Object getObject(ExecutionContext context);
+
+    /**
+     * Resolves to a String, if possible
+     */
+    public String getStringValue(ExecutionContext context);
+
+    /**
+     * Resolves to a boolean, if possible
+     */
+    public boolean getBooleanValue(ExecutionContext context) throws ClassCastException;
+
+    /**
+     * Resolves to a int, if possible
+     */    
+    public int getIntValue(ExecutionContext context) throws NumberFormatException;
+
+    /**
+     * Resolves to a short, if possible
+     */    
+    public short getShortValue(ExecutionContext context) throws NumberFormatException;
+
+    /**
+     * Resolves to a long, if possible
+     */    
+    public long getLongValue(ExecutionContext context) throws NumberFormatException;
+
+    /**
+     * Resolves to a float, if possible
+     */    
+    public float getFloatValue(ExecutionContext context) throws NumberFormatException;
+
+    /**
+     * Resolves to a double, if possible
+     */    
+    public double getDoubleValue(ExecutionContext context) throws NumberFormatException;
+
+    /**
+     * Resolves to a BigInteger, if possible
+     */    
+    public BigInteger getBigIntegerValue(ExecutionContext context) throws NumberFormatException;
+
+    /**
+     * Resolves to a BigDecimal, if possible
+     */     
+    public BigDecimal getBigDecimalValue(ExecutionContext context) throws NumberFormatException;
+
+}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/VariableValueHandler.java (from rev 10524, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/VariableValueHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/VariableValueHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/VariableValueHandler.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,7 @@
+package org.drools.clp;
+
+public interface VariableValueHandler
+    extends
+    ValueHandler {
+    public String getIdentifier();
+}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions (from rev 10465, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/functions)

Deleted: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/AddFunction.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/functions/AddFunction.java	2007-03-22 23:37:58 UTC (rev 10465)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/AddFunction.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -1,32 +0,0 @@
-package org.drools.clp.functions;
-
-import java.math.BigDecimal;
-
-import org.drools.FactHandle;
-import org.drools.clp.ExecutionContext;
-import org.drools.clp.Function;
-import org.drools.clp.ValueHandler;
-import org.drools.common.InternalWorkingMemory;
-import org.drools.spi.Extractor;
-
-public class AddFunction implements Function {
-    private static final String name = "+";
-
-    public AddFunction() {
-        
-    }
-    
-    public Object execute(ValueHandler[] args, ExecutionContext context) {
-        BigDecimal bdval = new BigDecimal(0);        
-        for ( int i = 0, length = args.length; i < length; i++ ) {
-            bdval = bdval.add( args[i].getBigDecimalValue( context ) );
-        }                
-        return new BigDecimal( bdval.intValue() );     
-    }
-    
-    
-    public String getName() {
-        return name;
-    }
-
-}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/AddFunction.java (from rev 10541, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/functions/AddFunction.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/AddFunction.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/AddFunction.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,33 @@
+package org.drools.clp.functions;
+
+import java.math.BigDecimal;
+
+import org.drools.clp.ExecutionContext;
+import org.drools.clp.Function;
+import org.drools.clp.ValueHandler;
+import org.drools.clp.valuehandlers.ObjectValueHandler;
+
+public class AddFunction extends BaseFunction
+    implements
+    Function {
+    private static final String name = "+";
+
+    public AddFunction() {
+
+    }
+
+    public ValueHandler execute(ValueHandler[] args,
+                                ExecutionContext context) {
+
+        BigDecimal bdval = new BigDecimal( 0 );
+        for ( int i = 0, length = args.length; i < length; i++ ) {
+            bdval = bdval.add( args[i].getBigDecimalValue( context ) );
+        }
+
+        return new ObjectValueHandler( bdval );
+    }
+
+    public String getName() {
+        return name;
+    }
+}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/BaseFunction.java (from rev 10541, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/functions/BaseFunction.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/BaseFunction.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/BaseFunction.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,31 @@
+package org.drools.clp.functions;
+
+import org.drools.clp.ExecutionBuildContext;
+import org.drools.clp.ExecutionContext;
+import org.drools.clp.Function;
+import org.drools.clp.LispForm;
+import org.drools.clp.LispList;
+import org.drools.clp.ValueHandler;
+
+public abstract class BaseFunction
+    implements
+    Function {
+
+    public void initCallback(ExecutionBuildContext context) {
+
+    }
+
+    public ValueHandler addParameterCallback(int index,
+                                             ValueHandler valueHandler,
+                                             ExecutionBuildContext context) {
+        return valueHandler;
+    }
+
+    public LispList createList(int index) {
+        return new LispForm();
+    }
+
+    public String toString() {
+        return "[Function '" + getName() + "']";
+    }
+}

Deleted: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/BindFunction.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/functions/BindFunction.java	2007-03-22 23:37:58 UTC (rev 10465)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/BindFunction.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -1,28 +0,0 @@
-package org.drools.clp.functions;
-
-import java.math.BigDecimal;
-
-import org.drools.FactHandle;
-import org.drools.clp.BaseFunction;
-import org.drools.clp.ExecutionContext;
-import org.drools.clp.Function;
-import org.drools.clp.ValueHandler;
-import org.drools.common.InternalWorkingMemory;
-import org.drools.spi.Extractor;
-
-public class BindFunction implements Function {
-    private static final String name = "bind";
-
-    public BindFunction() {
-        
-    }
-    public Object execute(ValueHandler[] args, ExecutionContext context) {
-        args[0].setValue( context, args[1].getValue( context ) );        
-        return args[0];    
-    }
-    
-    public String getName() {
-        return name;
-    }
-
-}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/BindFunction.java (from rev 10541, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/functions/BindFunction.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/BindFunction.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/BindFunction.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,45 @@
+package org.drools.clp.functions;
+
+import org.drools.clp.ExecutionBuildContext;
+import org.drools.clp.ExecutionContext;
+import org.drools.clp.Function;
+import org.drools.clp.ValueHandler;
+import org.drools.clp.valuehandlers.TempTokenVariable;
+
+public class BindFunction extends BaseFunction
+    implements
+    Function {
+    private static final String name = "bind";
+
+    public BindFunction() {
+
+    }
+
+    public ValueHandler addParameterCallback(int index,
+                                             ValueHandler valueHandler,
+                                             ExecutionBuildContext context) {
+        // The first index in the 'bind' function is the variable
+        // register the variable, if it doesn't already exist, will be a TempTokenVariable if it does not already exist
+        if ( index == 0 && (valueHandler instanceof TempTokenVariable) ) {
+            TempTokenVariable temp = (TempTokenVariable) valueHandler;
+            valueHandler = context.createLocalVariable( temp.getIdentifier() );
+        }
+
+        return valueHandler;
+    }
+
+    public ValueHandler execute(ValueHandler[] args,
+                                ExecutionContext context) {
+        ValueHandler nested = args[1].getValue( context );
+        ValueHandler value = (nested != null ) ? nested : args[1];
+    
+        args[0].setValue( context,
+                          value );
+        return args[0];
+    }
+
+    public String getName() {
+        return name;
+    }
+
+}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/CreateListFunction.java (from rev 10541, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/functions/CreateListFunction.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/CreateListFunction.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/CreateListFunction.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,28 @@
+package org.drools.clp.functions;
+
+import org.drools.clp.ExecutionContext;
+import org.drools.clp.Function;
+import org.drools.clp.ValueHandler;
+import org.drools.clp.valuehandlers.ListValueHandler;
+
+public class CreateListFunction extends BaseFunction
+    implements
+    Function {
+    private static final String name = "create$";
+
+    public CreateListFunction() {
+
+    }
+
+    public ValueHandler execute(ValueHandler[] args,
+                                ExecutionContext context) {
+        ListValueHandler list = new ListValueHandler();
+        list.add( args,
+                  context );
+        return list;
+    }
+
+    public String getName() {
+        return name;
+    }
+}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/ForeachFunction.java (from rev 10541, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/functions/ForeachFunction.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/ForeachFunction.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/ForeachFunction.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,63 @@
+package org.drools.clp.functions;
+
+import org.drools.clp.ExecutionBuildContext;
+import org.drools.clp.ExecutionContext;
+import org.drools.clp.Function;
+import org.drools.clp.ValueHandler;
+import org.drools.clp.valuehandlers.ListValueHandler;
+import org.drools.clp.valuehandlers.TempTokenVariable;
+
+public class ForeachFunction extends BaseFunction
+    implements
+    Function {
+    private static final String name = "foreach";
+
+    public ForeachFunction() {
+
+    }
+    
+    public ValueHandler addParameterCallback(int index,
+                                             ValueHandler valueHandler,
+                                             ExecutionBuildContext context) {
+        // The first index in the 'foreach' function is the variable
+        // register the variable, if it doesn't already exist, will be a TempTokenVariable if it does not already exist
+        if ( index == 0 && (valueHandler instanceof TempTokenVariable) ) {
+            TempTokenVariable temp = (TempTokenVariable) valueHandler;
+            valueHandler = context.createLocalVariable( temp.getIdentifier() );
+        }
+
+        return valueHandler;
+    }    
+
+    public ValueHandler execute(ValueHandler[] args,
+                                ExecutionContext context) {
+        ValueHandler result = null;
+        
+        BindFunction bind = new BindFunction();
+        ValueHandler[] bindArgs = new ValueHandler[2];
+        bindArgs[0] = args[0];
+  
+        // Check if the arg is a List or a variable resolving to a list
+        ValueHandler value = args[1];
+        if ( !(value instanceof ListValueHandler ) ) {
+           value = value.getValue( context ); 
+        }
+        ValueHandler[] list  = (( ListValueHandler ) value).getList();
+      
+        for (int i = 0, length1 = list.length; i < length1; i++ ) {
+            bindArgs[1] = list[i];
+            bind.execute( bindArgs, context );
+            for (int j = 2, length2 = args.length; j < length2; j++ ) {
+                // iterate for each action
+                result = args[j].getValue( context );
+            }            
+        }
+
+        return result;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/IfFunction.java (from rev 10541, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/functions/IfFunction.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/IfFunction.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/IfFunction.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,34 @@
+package org.drools.clp.functions;
+
+import org.drools.clp.ExecutionContext;
+import org.drools.clp.Function;
+import org.drools.clp.LispForm;
+import org.drools.clp.LispList;
+import org.drools.clp.ValueHandler;
+import org.drools.clp.valuehandlers.BooleanValueHandler;
+
+public class IfFunction extends BaseFunction
+    implements
+    Function {
+    private static final String name = "if";
+
+    public IfFunction() {
+
+    }
+
+    public ValueHandler execute(ValueHandler[] args,
+                                ExecutionContext context) {
+        boolean result = args[0].getBooleanValue( context );
+        if ( result ) {
+            return args[2].getValue( context );
+        } else if ( args[3] != null && args[4] != null ) {
+            return args[4].getValue( context );
+        } else {
+            return new BooleanValueHandler( result );
+        }
+    }
+
+    public String getName() {
+        return name;
+    }
+}

Deleted: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/LessThanFunction.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/functions/LessThanFunction.java	2007-03-22 23:37:58 UTC (rev 10465)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/LessThanFunction.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -1,22 +0,0 @@
-package org.drools.clp.functions;
-
-import org.drools.clp.ExecutionContext;
-import org.drools.clp.Function;
-import org.drools.clp.ValueHandler;
-
-public class LessThanFunction implements Function {
-    private static final String name = "<";
-
-    public LessThanFunction() {
-        
-    }   
-
-    public Object execute(ValueHandler[] args, ExecutionContext context) {
-        return new Boolean( args[1].getBigDecimalValue( context ).compareTo( args[2].getBigDecimalValue( context ) ) < 0 );    
-    }
-    
-    public String getName() {
-        return name;
-    }
-
-}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/LessThanFunction.java (from rev 10541, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/functions/LessThanFunction.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/LessThanFunction.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/LessThanFunction.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,26 @@
+package org.drools.clp.functions;
+
+import org.drools.clp.ExecutionContext;
+import org.drools.clp.Function;
+import org.drools.clp.ValueHandler;
+import org.drools.clp.valuehandlers.BooleanValueHandler;
+
+public class LessThanFunction extends BaseFunction
+    implements
+    Function {
+    private static final String name = "<";
+
+    public LessThanFunction() {
+
+    }
+
+    public ValueHandler execute(ValueHandler[] args,
+                                ExecutionContext context) {
+        return new BooleanValueHandler( args[0].getBigDecimalValue( context ).compareTo( args[1].getBigDecimalValue( context ) ) < 0 );
+    }
+
+    public String getName() {
+        return name;
+    }
+
+}

Deleted: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/ModifyFunction.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/functions/ModifyFunction.java	2007-03-22 23:37:58 UTC (rev 10465)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/ModifyFunction.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -1,30 +0,0 @@
-package org.drools.clp.functions;
-
-import org.drools.clp.ExecutionContext;
-import org.drools.clp.Function;
-import org.drools.clp.FunctionCaller;
-import org.drools.clp.SlotNameValuePair;
-import org.drools.clp.ValueHandler;
-import org.mvel.PropertyAccessor;
-
-public class ModifyFunction  implements Function {
-    private static final String name = "modify";    
-    
-    public ModifyFunction() {
-    }
-
-
-    public Object execute(ValueHandler[] args, ExecutionContext context) {
-        Object object = args[0].getValue( context );        
-            for ( int i = 1, length = args.length; i < length; i++ ) {
-                FunctionCaller pair = ( FunctionCaller ) args[i];                
-                PropertyAccessor.set(object, pair.getName(), pair.getParameters()[0].getValue( context ) );
-            }                
-        return null;
-    }
-    
-    public String getName() {
-        return name;
-    }
-
-}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/ModifyFunction.java (from rev 10541, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/functions/ModifyFunction.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/ModifyFunction.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/ModifyFunction.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,38 @@
+package org.drools.clp.functions;
+
+import org.drools.clp.ExecutionContext;
+import org.drools.clp.Function;
+import org.drools.clp.LispData;
+import org.drools.clp.LispList;
+import org.drools.clp.ValueHandler;
+import org.drools.clp.valuehandlers.ListValueHandler;
+import org.mvel.PropertyAccessor;
+
+public class ModifyFunction extends BaseFunction
+    implements
+    Function {
+    private static final String name = "modify";
+
+    public ModifyFunction() {
+    }
+
+    public ValueHandler execute(ValueHandler[] args,
+                                ExecutionContext context) {
+        Object object = args[0].getObject( context );
+        for ( int i = 1, length = args.length; i < length; i++ ) {
+            ValueHandler[] list = ((ListValueHandler) args[i]).getList();
+            PropertyAccessor.set( object,
+                                  list[0].getStringValue( context ),
+                                  list[1].getObject( context ) );
+        }
+        return null;
+    }   
+
+    public LispList createList(int index) {
+        return new LispData();
+    }
+
+    public String getName() {
+        return name;
+    }
+}

Deleted: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/MultiplyFunction.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/functions/MultiplyFunction.java	2007-03-22 23:37:58 UTC (rev 10465)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/MultiplyFunction.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -1,32 +0,0 @@
-package org.drools.clp.functions;
-
-import java.math.BigDecimal;
-
-import org.drools.FactHandle;
-import org.drools.clp.ExecutionContext;
-import org.drools.clp.Function;
-import org.drools.clp.ValueHandler;
-import org.drools.common.InternalWorkingMemory;
-import org.drools.spi.Extractor;
-
-public class MultiplyFunction implements Function {
-    private static final String name = "*";
-
-    public MultiplyFunction() {
-        
-    }
-    
-    public Object execute(ValueHandler[] args, ExecutionContext context) {
-        BigDecimal bdval = new BigDecimal(0);        
-        for ( int i = 0, length = args.length; i < length; i++ ) {
-            bdval = bdval.multiply( args[i].getBigDecimalValue( context ) );
-        }                
-        return bdval;        
-    }
-    
-    
-    public String getName() {
-        return name;
-    }
-
-}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/MultiplyFunction.java (from rev 10541, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/functions/MultiplyFunction.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/MultiplyFunction.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/MultiplyFunction.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,32 @@
+package org.drools.clp.functions;
+
+import java.math.BigDecimal;
+
+import org.drools.clp.ExecutionContext;
+import org.drools.clp.Function;
+import org.drools.clp.ValueHandler;
+import org.drools.clp.valuehandlers.ObjectValueHandler;
+
+public class MultiplyFunction extends BaseFunction
+    implements
+    Function {
+    private static final String name = "*";
+
+    public MultiplyFunction() {
+
+    }
+
+    public ValueHandler execute(ValueHandler[] args,
+                                ExecutionContext context) {
+        BigDecimal bdval = new BigDecimal( 0 );
+        for ( int i = 0, length = args.length; i < length; i++ ) {
+            bdval = bdval.multiply( args[i].getBigDecimalValue( context ) );
+        }
+        return new ObjectValueHandler( bdval );
+    }
+
+    public String getName() {
+        return name;
+    }
+
+}

Added: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/SwitchCaseFunction.java
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/SwitchCaseFunction.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/SwitchCaseFunction.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,51 @@
+package org.drools.clp.functions;
+
+import org.drools.clp.ExecutionContext;
+import org.drools.clp.Function;
+import org.drools.clp.LispForm;
+import org.drools.clp.LispList;
+import org.drools.clp.ValueHandler;
+import org.drools.clp.valuehandlers.BooleanValueHandler;
+
+public class SwitchCaseFunction extends BaseFunction
+    implements
+    Function {
+    private static final String name = "switch";
+
+    public SwitchCaseFunction() {
+
+    }
+
+    public ValueHandler execute(ValueHandler[] args,
+                                ExecutionContext context) {
+        ValueHandler value = args[0].getValue( context );
+        
+        ValueHandler result = null;
+        
+        //ValueHandler
+        
+        for (int j = 2, length = args.length; j < length; j++ ) {
+            
+            
+            // iterate for each action
+            //result = args[j].getValue( context );
+            
+        }   
+        
+        return result;
+        
+        /*
+        if ( result ) {
+            return args[2].getValue( context );
+        } else if ( args[3] != null && args[4] != null ) {
+            return args[4].getValue( context );
+        } else {
+            return new BooleanValueHandler( result );
+        }
+        */
+    }
+
+    public String getName() {
+        return name;
+    }
+}

Added: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/SwitchFunction.java
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/SwitchFunction.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/SwitchFunction.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,51 @@
+package org.drools.clp.functions;
+
+import org.drools.clp.ExecutionContext;
+import org.drools.clp.Function;
+import org.drools.clp.LispForm;
+import org.drools.clp.LispList;
+import org.drools.clp.ValueHandler;
+import org.drools.clp.valuehandlers.BooleanValueHandler;
+
+public class SwitchFunction extends BaseFunction
+    implements
+    Function {
+    private static final String name = "switch";
+
+    public SwitchFunction() {
+
+    }
+
+    public ValueHandler execute(ValueHandler[] args,
+                                ExecutionContext context) {
+        ValueHandler value = args[0].getValue( context );
+        
+        ValueHandler result = null;
+        
+        //ValueHandler
+        
+        for (int j = 2, length = args.length; j < length; j++ ) {
+            
+            
+            // iterate for each action
+            //result = args[j].getValue( context );
+            
+        }   
+        
+        return result;
+        
+        /*
+        if ( result ) {
+            return args[2].getValue( context );
+        } else if ( args[3] != null && args[4] != null ) {
+            return args[4].getValue( context );
+        } else {
+            return new BooleanValueHandler( result );
+        }
+        */
+    }
+
+    public String getName() {
+        return name;
+    }
+}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/WhileFunction.java (from rev 10541, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/functions/WhileFunction.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/WhileFunction.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/functions/WhileFunction.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,36 @@
+package org.drools.clp.functions;
+
+import org.drools.clp.ExecutionContext;
+import org.drools.clp.Function;
+import org.drools.clp.ValueHandler;
+
+public class WhileFunction extends BaseFunction
+    implements
+    Function {
+    private static final String name = "while";
+
+    public WhileFunction() {
+
+    }
+
+    public ValueHandler execute(ValueHandler[] args,
+                                ExecutionContext context) {
+        ValueHandler result = null;
+
+        ValueHandler doLoop = args[0];
+        
+        while ( doLoop.getBooleanValue( context ) ) {
+            for (int i = 2, length = args.length; i < length; i++ ) {
+                // iterate for each action                
+                result = args[i].getValue( context );
+            }
+        }
+
+        return result;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers (from rev 10522, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/valuehandlers)

Deleted: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/BaseValueHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/valuehandlers/BaseValueHandler.java	2007-03-24 19:59:03 UTC (rev 10522)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/BaseValueHandler.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -1,67 +0,0 @@
-package org.drools.clp.ValueHandlers;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
-import org.drools.clp.ExecutionContext;
-import org.drools.clp.ValueHandler;
-
-public abstract class BaseValueHandler implements ValueHandler {        
-    
-    public BigDecimal getBigDecimalValue(ExecutionContext context) throws NumberFormatException {
-        Object object = getValue( context );
-        if ( object instanceof BigDecimal ) {
-            return (BigDecimal) object;
-        } else {
-            return new BigDecimal( object.toString() );
-        }
-    }
-
-    public BigInteger getBigIntegerValue(ExecutionContext context) throws NumberFormatException {
-        Object object = getValue( context );
-        if ( object instanceof BigInteger ) {
-            return (BigInteger) object;
-        } else {
-            return new BigInteger( object.toString() );
-        }
-    }
-
-    public boolean getBooleanValue(ExecutionContext context) throws ClassCastException {
-        return ((Boolean) getValue(context)).booleanValue();
-    }
-
-    public double getDoubleValue(ExecutionContext context) throws NumberFormatException {
-        return ((Double) getValue(context)).doubleValue();
-    }
-
-    public float getFloatValue(ExecutionContext context) throws NumberFormatException {
-        return ((Float) getValue(context)).floatValue();
-    }
-
-    public int getIntValue(ExecutionContext context) throws NumberFormatException {
-        return ((Integer) getValue(context)).intValue();
-    }
-
-    public long getLongValue(ExecutionContext context) throws NumberFormatException {
-        return ((Long) getValue(context)).longValue();
-    }
-
-    public short getShortValue(ExecutionContext context) throws NumberFormatException {
-        return ((Short) getValue(context)).shortValue();
-    }
-
-    public String getStringValue(ExecutionContext context) {
-        return (String) getValue(context);
-    }      
-    
-    public String toString() {
-        String name = getClass().getName();
-        name = name.substring( name.lastIndexOf( "." ) + 1 );
-        try {
-            return "[" + name + " value = '" + getValue(null) + "']";
-        } catch (Exception e) {
-            return "[" + name + " value = N/A]";
-        }
-    }
-    
-}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/BaseValueHandler.java (from rev 10541, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/valuehandlers/BaseValueHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/BaseValueHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/BaseValueHandler.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,67 @@
+package org.drools.clp.valuehandlers;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+import org.drools.clp.ExecutionContext;
+import org.drools.clp.ValueHandler;
+
+public abstract class BaseValueHandler implements ValueHandler {        
+    
+    public BigDecimal getBigDecimalValue(ExecutionContext context) throws NumberFormatException {
+        Object object = getObject( context );        
+        if ( object instanceof BigDecimal ) {
+            return (BigDecimal) object;
+        } else {
+            return new BigDecimal( object.toString() );
+        }
+    }
+
+    public BigInteger getBigIntegerValue(ExecutionContext context) throws NumberFormatException {
+        Object object = getObject( context );
+        if ( object instanceof BigInteger ) {
+            return (BigInteger) object;
+        } else {
+            return new BigInteger( object.toString() );
+        }
+    }
+
+    public boolean getBooleanValue(ExecutionContext context) throws ClassCastException {
+        return ((Boolean) getObject(context)).booleanValue();
+    }
+
+    public double getDoubleValue(ExecutionContext context) throws NumberFormatException {
+        return ((Double) getObject(context)).doubleValue();
+    }
+
+    public float getFloatValue(ExecutionContext context) throws NumberFormatException {
+        return ((Float) getObject(context)).floatValue();
+    }
+
+    public int getIntValue(ExecutionContext context) throws NumberFormatException {
+        return ((Integer) getObject(context)).intValue();
+    }
+
+    public long getLongValue(ExecutionContext context) throws NumberFormatException {
+        return ((Long) getObject(context)).longValue();
+    }
+
+    public short getShortValue(ExecutionContext context) throws NumberFormatException {
+        return ((Short) getObject(context)).shortValue();
+    }
+
+    public String getStringValue(ExecutionContext context) {
+        return (String) getObject(context);
+    }      
+    
+    public String toString() {
+        String name = getClass().getName();
+        name = name.substring( name.lastIndexOf( "." ) + 1 );
+        try {
+            return "[" + name + " value = '" + getObject(null) + "']";
+        } catch (Exception e) {
+            return "[" + name + " value = N/A]";
+        }
+    }
+    
+}

Deleted: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/BooleanValueHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/valuehandlers/BooleanValueHandler.java	2007-03-24 19:59:03 UTC (rev 10522)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/BooleanValueHandler.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -1,90 +0,0 @@
-package org.drools.clp.ValueHandlers;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
-import org.drools.base.SimpleValueType;
-import org.drools.clp.ExecutionContext;
-import org.drools.clp.ValueHandler;
-
-public class BooleanValueHandler implements ValueHandler {
-    private boolean booleanValue;
-    
-    public BooleanValueHandler(String booleanValue) {
-        this.booleanValue = Boolean.valueOf( booleanValue ).booleanValue();
-    } 
-    
-    public BooleanValueHandler(boolean booleanValue) {
-        this.booleanValue = booleanValue;
-    }
-    
-    public int getValueType(ExecutionContext context) {
-        return SimpleValueType.BOOLEAN;
-    }
-
-    public void setValue(ExecutionContext context, Object value) {
-        throw new RuntimeException( "LiteralValues cannot be set");
-    }
-    
-    public Object getValue(ExecutionContext context) {
-        return new Boolean( this.booleanValue );
-    }
-    
-    public BigDecimal getBigDecimalValue(ExecutionContext context) throws NumberFormatException {
-        throw new RuntimeException( "Boolean format exception, cannot be cast to BitDecimal" );
-    }
-
-    public BigInteger getBigIntegerValue(ExecutionContext context) throws NumberFormatException {
-        throw new RuntimeException( "Boolean format exception, cannot be cast to BitInteger" );
-    }
-
-    public boolean getBooleanValue(ExecutionContext context) throws ClassCastException {
-        return this.booleanValue;
-    }
-
-    public double getDoubleValue(ExecutionContext context) throws NumberFormatException {
-        throw new RuntimeException( "Boolean format exception, cannot be cast to double" );
-    }
-
-    public float getFloatValue(ExecutionContext context) throws NumberFormatException {
-        throw new RuntimeException( "Boolean format exception, cannot be cast to float" );
-    }
-
-    public int getIntValue(ExecutionContext context) throws NumberFormatException {
-        throw new RuntimeException( "Boolean format exception, cannot be cast to int" );
-    }
-
-    public long getLongValue(ExecutionContext context) throws NumberFormatException {
-        throw new RuntimeException( "Boolean format exception, cannot be cast to long" );
-    }
-
-    public short getShortValue(ExecutionContext context) throws NumberFormatException {
-        throw new RuntimeException( "Boolean format exception, cannot be cast to short" ); 
-    }
-
-    public String getStringValue(ExecutionContext context) {
-        return Boolean.toString( this.booleanValue );
-    }      
-    
-    public String toString() {
-        return "[BooleanLiteralValue value='" + this.booleanValue + "']";
-    }
-
-    public int hashCode() {
-        final int PRIME = 31;
-        int result = 1;
-        result = PRIME * result + (booleanValue ? 1231 : 1237);
-        return result;
-    }
-
-    public boolean equals(Object obj) {
-        if ( this == obj ) return true;
-        if ( obj == null ) return false;
-        if ( !(obj instanceof BooleanValueHandler) ) return false;
-        final BooleanValueHandler other = (BooleanValueHandler) obj;
-        if ( booleanValue != other.booleanValue ) return false;
-        return true;
-    }
-    
-    
-}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/BooleanValueHandler.java (from rev 10541, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/valuehandlers/BooleanValueHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/BooleanValueHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/BooleanValueHandler.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,94 @@
+package org.drools.clp.valuehandlers;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+import org.drools.base.SimpleValueType;
+import org.drools.clp.ExecutionContext;
+import org.drools.clp.ValueHandler;
+
+public class BooleanValueHandler implements ValueHandler {
+    private boolean booleanValue;    
+    
+    public BooleanValueHandler(String booleanValue) {
+        this.booleanValue = Boolean.valueOf( booleanValue ).booleanValue();
+    } 
+    
+    public BooleanValueHandler(boolean booleanValue) {
+        this.booleanValue = booleanValue;
+    } 
+
+    public ValueHandler getValue(ExecutionContext context) {
+        return null;
+    }    
+    
+    public int getValueType(ExecutionContext context) {
+        return SimpleValueType.BOOLEAN;
+    }
+
+    public void setValue(ExecutionContext context, Object value) {
+        throw new RuntimeException( "LiteralValues cannot be set");
+    }
+    
+    public Object getObject(ExecutionContext context) {
+        return new Boolean( this.booleanValue );
+    }
+    
+    public BigDecimal getBigDecimalValue(ExecutionContext context) throws NumberFormatException {
+        throw new RuntimeException( "Boolean format exception, cannot be cast to BitDecimal" );
+    }
+
+    public BigInteger getBigIntegerValue(ExecutionContext context) throws NumberFormatException {
+        throw new RuntimeException( "Boolean format exception, cannot be cast to BitInteger" );
+    }
+
+    public boolean getBooleanValue(ExecutionContext context) throws ClassCastException {
+        return this.booleanValue;
+    }
+
+    public double getDoubleValue(ExecutionContext context) throws NumberFormatException {
+        throw new RuntimeException( "Boolean format exception, cannot be cast to double" );
+    }
+
+    public float getFloatValue(ExecutionContext context) throws NumberFormatException {
+        throw new RuntimeException( "Boolean format exception, cannot be cast to float" );
+    }
+
+    public int getIntValue(ExecutionContext context) throws NumberFormatException {
+        throw new RuntimeException( "Boolean format exception, cannot be cast to int" );
+    }
+
+    public long getLongValue(ExecutionContext context) throws NumberFormatException {
+        throw new RuntimeException( "Boolean format exception, cannot be cast to long" );
+    }
+
+    public short getShortValue(ExecutionContext context) throws NumberFormatException {
+        throw new RuntimeException( "Boolean format exception, cannot be cast to short" ); 
+    }
+
+    public String getStringValue(ExecutionContext context) {
+        return Boolean.toString( this.booleanValue );
+    }      
+    
+    public String toString() {
+        return "[BooleanLiteralValue value='" + this.booleanValue + "']";
+    }
+
+    public int hashCode() {
+        final int PRIME = 31;
+        int result = 1;
+        result = PRIME * result + (booleanValue ? 1231 : 1237);
+        return result;
+    }
+
+    public boolean equals(Object obj) {
+        if ( this == obj ) return true;
+        if ( obj == null ) return false;
+        if ( !(obj instanceof BooleanValueHandler) ) return false;
+        final BooleanValueHandler other = (BooleanValueHandler) obj;
+        if ( booleanValue != other.booleanValue ) return false;
+        return true;
+    }
+    
+    
+}

Deleted: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/CLPGlobalVariable.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/valuehandlers/CLPGlobalVariable.java	2007-03-24 19:59:03 UTC (rev 10522)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/CLPGlobalVariable.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -1,50 +0,0 @@
-package org.drools.clp.ValueHandlers;
-
-import org.drools.clp.CLPFactory;
-import org.drools.clp.ExecutionContext;
-import org.drools.clp.VariableValueHandler;
-
-
-public class CLPGlobalVariable extends BaseValueHandler implements VariableValueHandler  {
-    
-    private String identifier;
-    private Class knownType;
-    private int simpleType;
-    private CLPFactory factory;
-       
-    public CLPGlobalVariable(String identifier,
-                                    Class knownType,
-                                    int simpleType,
-                                    CLPFactory factory ) {
-        this.identifier = identifier;
-        this.factory =  factory;
-        this.knownType = knownType;
-    }
-    
-    public String getIdentifier() {
-        return this.identifier;
-    }
-    
-    public int getValueType(ExecutionContext context) {
-        return this.simpleType;
-    }    
-
-    public Class getKnownType() {
-        return this.knownType;
-    }
-
-    public Object getValue(ExecutionContext context) {
-        return this.factory.getValue( this.identifier );
-    }
-
-    public void setValue(ExecutionContext context, Object value) {
-        throw new UnsupportedOperationException( "External Variable identifer='" + getIdentifier() + "' type='" + getKnownType() + "' is final, it cannot be set" );
-    }       
-    
-    public String toString() {
-        String name = getClass().getName();
-        name = name.substring( name.lastIndexOf( "." ) + 1 );
-        return "[" + name + " identifier = '" + getIdentifier()  + "']";
-    }        
-
-}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/CLPGlobalVariable.java (from rev 10541, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/valuehandlers/CLPGlobalVariable.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/CLPGlobalVariable.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/CLPGlobalVariable.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,55 @@
+package org.drools.clp.valuehandlers;
+
+import org.drools.clp.CLPFactory;
+import org.drools.clp.ExecutionContext;
+import org.drools.clp.ValueHandler;
+import org.drools.clp.VariableValueHandler;
+
+
+public class CLPGlobalVariable extends BaseValueHandler implements VariableValueHandler  {
+    
+    private String identifier;
+    private Class knownType;
+    private int simpleType;
+    private CLPFactory factory;
+       
+    public CLPGlobalVariable(String identifier,
+                                    Class knownType,
+                                    int simpleType,
+                                    CLPFactory factory ) {
+        this.identifier = identifier;
+        this.factory =  factory;
+        this.knownType = knownType;
+    }    
+    
+    public ValueHandler getValue(ExecutionContext context) {
+        return null;
+    }    
+    
+    public String getIdentifier() {
+        return this.identifier;
+    }
+    
+    public int getValueType(ExecutionContext context) {
+        return this.simpleType;
+    }    
+
+    public Class getKnownType() {
+        return this.knownType;
+    }
+
+    public Object getObject(ExecutionContext context) {
+        return this.factory.getValue( this.identifier );
+    }
+
+    public void setValue(ExecutionContext context, Object value) {
+        throw new UnsupportedOperationException( "External Variable identifer='" + getIdentifier() + "' type='" + getKnownType() + "' is final, it cannot be set" );
+    }       
+    
+    public String toString() {
+        String name = getClass().getName();
+        name = name.substring( name.lastIndexOf( "." ) + 1 );
+        return "[" + name + " identifier = '" + getIdentifier()  + "']";
+    }        
+
+}

Deleted: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/CLPLocalDeclarationVariable.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/valuehandlers/CLPLocalDeclarationVariable.java	2007-03-24 19:59:03 UTC (rev 10522)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/CLPLocalDeclarationVariable.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -1,89 +0,0 @@
-package org.drools.clp.ValueHandlers;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
-import org.drools.clp.ExecutionContext;
-import org.drools.clp.VariableValueHandler;
-import org.drools.rule.Declaration;
-
-public class CLPLocalDeclarationVariable implements VariableValueHandler {
-    
-    private Declaration declaration;
-       
-    public CLPLocalDeclarationVariable(Declaration declaration) {
-        this.declaration = declaration;
-    }        
-    public String getIdentifier() {
-        return this.declaration.getIdentifier();
-    }
-
-    public Class getKnownType() {
-        return declaration.getExtractor().getExtractToClass();
-    }
-    
-    public int getValueType(ExecutionContext context) {
-        return this.declaration.getValueType().getSimpleType(); 
-    }
-
-    public void setValue(ExecutionContext context,
-                         Object object) {
-        throw new UnsupportedOperationException( "External Variable identifer='" + getIdentifier() + "' type='" + getKnownType() + "' is final, it cannot be set" );
-    }
-    
-    public Object getValue(ExecutionContext context) {
-        return declaration.getValue( context.getObject() );
-    }
-    
-    public BigDecimal getBigDecimalValue(ExecutionContext context) throws NumberFormatException {
-        Object object = declaration.getValue( context.getObject() );
-        if ( object instanceof BigDecimal ) {
-            return (BigDecimal) object;
-        } else {
-            return new BigDecimal( object.toString() );
-        }
-    }
-
-    public BigInteger getBigIntegerValue(ExecutionContext context) throws NumberFormatException {
-        Object object = declaration.getValue( context.getObject() );
-        if ( object instanceof BigInteger ) {
-            return (BigInteger) object;
-        } else {
-            return new BigInteger( object.toString() );
-        }
-    }    
-
-    public boolean getBooleanValue(ExecutionContext context) throws ClassCastException {
-        return declaration.getBooleanValue( context.getObject() );
-    }
-
-    public double getDoubleValue(ExecutionContext context) throws NumberFormatException {
-        return declaration.getDoubleValue( context.getObject() );
-    }
-
-    public float getFloatValue(ExecutionContext context) throws NumberFormatException {
-        return declaration.getFloatValue( context.getObject() );
-    }
-
-    public int getIntValue(ExecutionContext context) throws NumberFormatException {
-        return declaration.getIntValue( context.getObject() );
-    }
-
-    public long getLongValue(ExecutionContext context) throws NumberFormatException {
-        return declaration.getLongValue( context.getObject() );
-    }
-
-    public short getShortValue(ExecutionContext context) throws NumberFormatException {
-        return declaration.getShortValue( context.getObject() );
-    }
-
-    public String getStringValue(ExecutionContext context) {
-        return (String) declaration.getValue( context.getObject() );
-    }
-    
-    public String toString() {
-        String name = getClass().getName();
-        name = name.substring( name.lastIndexOf( "." ) + 1 );
-        return "[" + name + " identifier = '" + getIdentifier()  + "']";
-    }    
-}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/CLPLocalDeclarationVariable.java (from rev 10541, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/valuehandlers/CLPLocalDeclarationVariable.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/CLPLocalDeclarationVariable.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/CLPLocalDeclarationVariable.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,95 @@
+package org.drools.clp.valuehandlers;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+import org.drools.clp.ExecutionContext;
+import org.drools.clp.ValueHandler;
+import org.drools.clp.VariableValueHandler;
+import org.drools.rule.Declaration;
+
+public class CLPLocalDeclarationVariable implements VariableValueHandler {
+    
+    private Declaration declaration;
+       
+    public CLPLocalDeclarationVariable(Declaration declaration) {
+        this.declaration = declaration;
+    }  
+    
+    public ValueHandler getValue(ExecutionContext context) {
+        return null;
+    }    
+    
+    public String getIdentifier() {
+        return this.declaration.getIdentifier();
+    }
+
+    public Class getKnownType() {
+        return declaration.getExtractor().getExtractToClass();
+    }
+    
+    public int getValueType(ExecutionContext context) {
+        return this.declaration.getValueType().getSimpleType(); 
+    }
+
+    public void setValue(ExecutionContext context,
+                         Object object) {
+        throw new UnsupportedOperationException( "External Variable identifer='" + getIdentifier() + "' type='" + getKnownType() + "' is final, it cannot be set" );
+    }
+    
+    public Object getObject(ExecutionContext context) {
+        return declaration.getValue( context.getObject() );
+    }
+    
+    public BigDecimal getBigDecimalValue(ExecutionContext context) throws NumberFormatException {
+        Object object = declaration.getValue( context.getObject() );
+        if ( object instanceof BigDecimal ) {
+            return (BigDecimal) object;
+        } else {
+            return new BigDecimal( object.toString() );
+        }
+    }
+
+    public BigInteger getBigIntegerValue(ExecutionContext context) throws NumberFormatException {
+        Object object = declaration.getValue( context.getObject() );
+        if ( object instanceof BigInteger ) {
+            return (BigInteger) object;
+        } else {
+            return new BigInteger( object.toString() );
+        }
+    }    
+
+    public boolean getBooleanValue(ExecutionContext context) throws ClassCastException {
+        return declaration.getBooleanValue( context.getObject() );
+    }
+
+    public double getDoubleValue(ExecutionContext context) throws NumberFormatException {
+        return declaration.getDoubleValue( context.getObject() );
+    }
+
+    public float getFloatValue(ExecutionContext context) throws NumberFormatException {
+        return declaration.getFloatValue( context.getObject() );
+    }
+
+    public int getIntValue(ExecutionContext context) throws NumberFormatException {
+        return declaration.getIntValue( context.getObject() );
+    }
+
+    public long getLongValue(ExecutionContext context) throws NumberFormatException {
+        return declaration.getLongValue( context.getObject() );
+    }
+
+    public short getShortValue(ExecutionContext context) throws NumberFormatException {
+        return declaration.getShortValue( context.getObject() );
+    }
+
+    public String getStringValue(ExecutionContext context) {
+        return (String) declaration.getValue( context.getObject() );
+    }
+    
+    public String toString() {
+        String name = getClass().getName();
+        name = name.substring( name.lastIndexOf( "." ) + 1 );
+        return "[" + name + " identifier = '" + getIdentifier()  + "']";
+    }    
+}

Deleted: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/CLPPreviousDeclarationVariable.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/valuehandlers/CLPPreviousDeclarationVariable.java	2007-03-24 19:59:03 UTC (rev 10522)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/CLPPreviousDeclarationVariable.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -1,102 +0,0 @@
-package org.drools.clp.ValueHandlers;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
-import org.drools.clp.ExecutionContext;
-import org.drools.clp.VariableValueHandler;
-import org.drools.common.InternalFactHandle;
-import org.drools.rule.Declaration;
-
-public class CLPPreviousDeclarationVariable implements VariableValueHandler {
-
-    private Declaration declaration;
-    
-    public CLPPreviousDeclarationVariable(Declaration declaration) {
-        this.declaration = declaration;
-    }
-
-    public String getIdentifier() {
-        return this.declaration.getIdentifier();
-    }
-
-    public Class getKnownType() {
-        return declaration.getExtractor().getExtractToClass();
-    }
-    
-    public int getValueType(ExecutionContext context) {
-        return this.declaration.getValueType().getSimpleType(); 
-    }
-
-    public void setValue(ExecutionContext context,
-                         Object object) {
-        throw new UnsupportedOperationException( "External Variable identifer='" + getIdentifier() + "' type='" + getKnownType() + "' is final, it cannot be set" );
-    }
-    
-    public Object getValue(ExecutionContext context) {
-        InternalFactHandle handle = context.getTuple().get( this.declaration );
-        return declaration.getValue( handle.getObject() );
-    }
-    
-    public BigDecimal getBigDecimalValue(ExecutionContext context) throws NumberFormatException {
-        InternalFactHandle handle = context.getTuple().get( this.declaration );
-        Object object = declaration.getValue(  handle.getObject() );
-        if ( object instanceof BigDecimal ) {
-            return (BigDecimal) object;
-        } else {
-            return new BigDecimal( object.toString() );
-        }
-    }
-
-    public BigInteger getBigIntegerValue(ExecutionContext context) throws NumberFormatException {
-        InternalFactHandle handle = context.getTuple().get( this.declaration );
-        Object object = declaration.getValue(  handle.getObject() );
-        if ( object instanceof BigInteger ) {
-            return (BigInteger) object;
-        } else {
-            return new BigInteger( object.toString() );
-        }
-    }    
-
-    public boolean getBooleanValue(ExecutionContext context) throws ClassCastException {
-        InternalFactHandle handle = context.getTuple().get( this.declaration );
-        return declaration.getBooleanValue( handle.getObject() );
-    }
-
-    public double getDoubleValue(ExecutionContext context) throws NumberFormatException {
-        InternalFactHandle handle = context.getTuple().get( this.declaration );
-        return declaration.getDoubleValue( handle.getObject() );
-    }
-
-    public float getFloatValue(ExecutionContext context) throws NumberFormatException {
-        InternalFactHandle handle = context.getTuple().get( this.declaration );
-        return declaration.getFloatValue( handle.getObject() );
-    }
-
-    public int getIntValue(ExecutionContext context) throws NumberFormatException {
-        InternalFactHandle handle = context.getTuple().get( this.declaration );
-        return declaration.getIntValue( handle.getObject() );
-    }
-
-    public long getLongValue(ExecutionContext context) throws NumberFormatException {
-        InternalFactHandle handle = context.getTuple().get( this.declaration );
-        return declaration.getLongValue( handle.getObject() );
-    }
-
-    public short getShortValue(ExecutionContext context) throws NumberFormatException {
-        InternalFactHandle handle = context.getTuple().get( this.declaration );
-        return declaration.getShortValue( handle.getObject() );
-    }
-
-    public String getStringValue(ExecutionContext context) {
-        InternalFactHandle handle = context.getTuple().get( this.declaration );
-        return (String) declaration.getValue( handle.getObject() );
-    }
-    
-    public String toString() {
-        String name = getClass().getName();
-        name = name.substring( name.lastIndexOf( "." ) + 1 );
-        return "[" + name + " identifier = '" + getIdentifier()  + "']";
-    }    
-        
-}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/CLPPreviousDeclarationVariable.java (from rev 10541, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/valuehandlers/CLPPreviousDeclarationVariable.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/CLPPreviousDeclarationVariable.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/CLPPreviousDeclarationVariable.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,107 @@
+package org.drools.clp.valuehandlers;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+import org.drools.clp.ExecutionContext;
+import org.drools.clp.ValueHandler;
+import org.drools.clp.VariableValueHandler;
+import org.drools.common.InternalFactHandle;
+import org.drools.rule.Declaration;
+
+public class CLPPreviousDeclarationVariable implements VariableValueHandler {
+
+    private Declaration declaration;
+    
+    public CLPPreviousDeclarationVariable(Declaration declaration) {
+        this.declaration = declaration;
+    }
+    
+    public ValueHandler getValue(ExecutionContext context) {
+        return null;
+    }    
+
+    public String getIdentifier() {
+        return this.declaration.getIdentifier();
+    }
+
+    public Class getKnownType() {
+        return declaration.getExtractor().getExtractToClass();
+    }
+    
+    public int getValueType(ExecutionContext context) {
+        return this.declaration.getValueType().getSimpleType(); 
+    }
+
+    public void setValue(ExecutionContext context,
+                         Object object) {
+        throw new UnsupportedOperationException( "External Variable identifer='" + getIdentifier() + "' type='" + getKnownType() + "' is final, it cannot be set" );
+    }
+    
+    public Object getObject(ExecutionContext context) {
+        InternalFactHandle handle = context.getTuple().get( this.declaration );
+        return declaration.getValue( handle.getObject() );
+    }
+    
+    public BigDecimal getBigDecimalValue(ExecutionContext context) throws NumberFormatException {
+        InternalFactHandle handle = context.getTuple().get( this.declaration );
+        Object object = declaration.getValue(  handle.getObject() );
+        if ( object instanceof BigDecimal ) {
+            return (BigDecimal) object;
+        } else {
+            return new BigDecimal( object.toString() );
+        }
+    }
+
+    public BigInteger getBigIntegerValue(ExecutionContext context) throws NumberFormatException {
+        InternalFactHandle handle = context.getTuple().get( this.declaration );
+        Object object = declaration.getValue(  handle.getObject() );
+        if ( object instanceof BigInteger ) {
+            return (BigInteger) object;
+        } else {
+            return new BigInteger( object.toString() );
+        }
+    }    
+
+    public boolean getBooleanValue(ExecutionContext context) throws ClassCastException {
+        InternalFactHandle handle = context.getTuple().get( this.declaration );
+        return declaration.getBooleanValue( handle.getObject() );
+    }
+
+    public double getDoubleValue(ExecutionContext context) throws NumberFormatException {
+        InternalFactHandle handle = context.getTuple().get( this.declaration );
+        return declaration.getDoubleValue( handle.getObject() );
+    }
+
+    public float getFloatValue(ExecutionContext context) throws NumberFormatException {
+        InternalFactHandle handle = context.getTuple().get( this.declaration );
+        return declaration.getFloatValue( handle.getObject() );
+    }
+
+    public int getIntValue(ExecutionContext context) throws NumberFormatException {
+        InternalFactHandle handle = context.getTuple().get( this.declaration );
+        return declaration.getIntValue( handle.getObject() );
+    }
+
+    public long getLongValue(ExecutionContext context) throws NumberFormatException {
+        InternalFactHandle handle = context.getTuple().get( this.declaration );
+        return declaration.getLongValue( handle.getObject() );
+    }
+
+    public short getShortValue(ExecutionContext context) throws NumberFormatException {
+        InternalFactHandle handle = context.getTuple().get( this.declaration );
+        return declaration.getShortValue( handle.getObject() );
+    }
+
+    public String getStringValue(ExecutionContext context) {
+        InternalFactHandle handle = context.getTuple().get( this.declaration );
+        return (String) declaration.getValue( handle.getObject() );
+    }
+    
+    public String toString() {
+        String name = getClass().getName();
+        name = name.substring( name.lastIndexOf( "." ) + 1 );
+        return "[" + name + " identifier = '" + getIdentifier()  + "']";
+    }    
+        
+}

Deleted: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/DoubleValueHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/valuehandlers/DoubleValueHandler.java	2007-03-24 19:59:03 UTC (rev 10522)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/DoubleValueHandler.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -1,92 +0,0 @@
-package org.drools.clp.ValueHandlers;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
-import org.drools.base.SimpleValueType;
-import org.drools.clp.ExecutionContext;
-import org.drools.clp.ValueHandler;
-
-public class DoubleValueHandler implements ValueHandler {
-    private double doubleValue;
-    
-    public DoubleValueHandler(String doubleValue) {
-        this.doubleValue = Double.valueOf( doubleValue ).doubleValue();
-    }
-    
-    public DoubleValueHandler(double doubleValue) {
-        this.doubleValue = doubleValue;
-    }
-    
-    public int getValueType(ExecutionContext context) {
-        return SimpleValueType.DECIMAL;
-    }
-
-    public void setValue(ExecutionContext context, Object value) {
-        throw new RuntimeException( "LiteralValues cannot be set");
-    }
-    
-    public Object getValue(ExecutionContext context) {
-        return new Double( this.doubleValue );
-    }
-    
-    public BigDecimal getBigDecimalValue(ExecutionContext context) throws NumberFormatException {
-        return new BigDecimal( this.doubleValue );
-    }
-
-    public BigInteger getBigIntegerValue(ExecutionContext context) throws NumberFormatException {
-        return BigInteger.valueOf( (long) this.doubleValue );
-    }
-
-    public boolean getBooleanValue(ExecutionContext context) throws ClassCastException {
-        return ( this.doubleValue == 0 ) ? false : true;
-    }
-
-    public double getDoubleValue(ExecutionContext context) throws NumberFormatException {
-        return this.doubleValue;
-    }
-
-    public float getFloatValue(ExecutionContext context) throws NumberFormatException {
-        return (float) this.doubleValue;
-    }
-
-    public int getIntValue(ExecutionContext context) throws NumberFormatException {
-        return (int) this.doubleValue;
-    }
-
-    public long getLongValue(ExecutionContext context) throws NumberFormatException {
-        return (long) this.doubleValue;
-    }
-
-    public short getShortValue(ExecutionContext context) throws NumberFormatException {
-        return (short) this.doubleValue;
-    }
-
-    public String getStringValue(ExecutionContext context) {
-        return Double.toString( this.doubleValue );
-    }
-
-    public String toString() {
-        return "[DoubleLiteralValue value='" + this.doubleValue + "']";
-    }    
-    
-    public int hashCode() {
-        final int PRIME = 31;
-        int result = 1;
-        long temp;
-        temp = Double.doubleToLongBits( doubleValue );
-        result = PRIME * result + (int) (temp ^ (temp >>> 32));
-        return result;
-    }
-
-    public boolean equals(Object obj) {
-        if ( this == obj ) return true;
-        if ( obj == null ) return false;
-        if ( !(obj instanceof DoubleValueHandler) ) return false;
-        final DoubleValueHandler other = (DoubleValueHandler) obj;
-        if ( Double.doubleToLongBits( doubleValue ) != Double.doubleToLongBits( other.doubleValue ) ) return false;
-        return true;
-    }
-    
-    
-}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/DoubleValueHandler.java (from rev 10541, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/valuehandlers/DoubleValueHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/DoubleValueHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/DoubleValueHandler.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,96 @@
+package org.drools.clp.valuehandlers;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+import org.drools.base.SimpleValueType;
+import org.drools.clp.ExecutionContext;
+import org.drools.clp.ValueHandler;
+
+public class DoubleValueHandler implements ValueHandler {
+    private double doubleValue;
+    
+    public DoubleValueHandler(String doubleValue) {
+        this.doubleValue = Double.valueOf( doubleValue ).doubleValue();
+    }
+    
+    public DoubleValueHandler(double doubleValue) {
+        this.doubleValue = doubleValue;
+    }   
+    
+    public ValueHandler getValue(ExecutionContext context) {
+        return null;
+    }    
+    
+    public int getValueType(ExecutionContext context) {
+        return SimpleValueType.DECIMAL;
+    }
+
+    public void setValue(ExecutionContext context, Object value) {
+        throw new RuntimeException( "LiteralValues cannot be set");
+    }
+    
+    public Object getObject(ExecutionContext context) {
+        return new Double( this.doubleValue );
+    }
+    
+    public BigDecimal getBigDecimalValue(ExecutionContext context) throws NumberFormatException {
+        return new BigDecimal( this.doubleValue );
+    }
+
+    public BigInteger getBigIntegerValue(ExecutionContext context) throws NumberFormatException {
+        return BigInteger.valueOf( (long) this.doubleValue );
+    }
+
+    public boolean getBooleanValue(ExecutionContext context) throws ClassCastException {
+        return ( this.doubleValue == 0 ) ? false : true;
+    }
+
+    public double getDoubleValue(ExecutionContext context) throws NumberFormatException {
+        return this.doubleValue;
+    }
+
+    public float getFloatValue(ExecutionContext context) throws NumberFormatException {
+        return (float) this.doubleValue;
+    }
+
+    public int getIntValue(ExecutionContext context) throws NumberFormatException {
+        return (int) this.doubleValue;
+    }
+
+    public long getLongValue(ExecutionContext context) throws NumberFormatException {
+        return (long) this.doubleValue;
+    }
+
+    public short getShortValue(ExecutionContext context) throws NumberFormatException {
+        return (short) this.doubleValue;
+    }
+
+    public String getStringValue(ExecutionContext context) {
+        return Double.toString( this.doubleValue );
+    }
+
+    public String toString() {
+        return "[DoubleLiteralValue value='" + this.doubleValue + "']";
+    }    
+    
+    public int hashCode() {
+        final int PRIME = 31;
+        int result = 1;
+        long temp;
+        temp = Double.doubleToLongBits( doubleValue );
+        result = PRIME * result + (int) (temp ^ (temp >>> 32));
+        return result;
+    }
+
+    public boolean equals(Object obj) {
+        if ( this == obj ) return true;
+        if ( obj == null ) return false;
+        if ( !(obj instanceof DoubleValueHandler) ) return false;
+        final DoubleValueHandler other = (DoubleValueHandler) obj;
+        if ( Double.doubleToLongBits( doubleValue ) != Double.doubleToLongBits( other.doubleValue ) ) return false;
+        return true;
+    }
+    
+    
+}

Deleted: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/FunctionCaller.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/valuehandlers/FunctionCaller.java	2007-03-24 19:59:03 UTC (rev 10522)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/FunctionCaller.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -1,141 +0,0 @@
-package org.drools.clp.ValueHandlers;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.Map;
-
-import org.drools.base.SimpleValueType;
-import org.drools.clp.ExecutionContext;
-import org.drools.clp.Function;
-import org.drools.clp.LispList;
-import org.drools.clp.ValueHandler;
-
-public class FunctionCaller
-    implements
-    ValueHandler {
-    private Function         function;
-
-    protected ValueHandler[] parameters;
-
-    public FunctionCaller() {
-        this( null );
-    }
-
-    public FunctionCaller(Function function) {
-        this.function = function;
-    }
-
-    public int getValueType(ExecutionContext context) {
-        return SimpleValueType.FUNCTION;
-    }
-
-    public void setFunction(Function function) {
-        this.function = function;
-    }
-
-    public Function getFunction() {
-        return this.function;
-    }
-
-    public String getName() {
-        return (this.function == null) ? null : this.function.getName();
-    }
-
-    public LispList createList(int index) {
-        return this.function.createList( index );
-    }
-
-    public void addParameter(ValueHandler valueHandler) {
-        if ( this.parameters == null ) {
-            this.parameters = new ValueHandler[]{valueHandler};
-        } else {
-            ValueHandler[] temp = new ValueHandler[parameters.length + 1];
-            System.arraycopy( this.parameters,
-                              0,
-                              temp,
-                              0,
-                              this.parameters.length );
-            temp[temp.length - 1] = valueHandler;
-            this.parameters = temp;
-        }
-    }
-
-    public ValueHandler[] getParameters() {
-        return this.parameters;
-    }
-
-    private ValueHandler resolveFunction(FunctionCaller caller,
-                                         ExecutionContext context) {
-        ValueHandler result = caller.getFunction().execute( caller.getParameters(),
-                                                            context );
-        if ( result instanceof FunctionCaller ) {
-            result = resolveFunction( (FunctionCaller) result,
-                                      context );
-        }
-        return result;
-    }
-    
-    public Object getValue(ExecutionContext context) {
-        return resolveFunction( this,
-                                context ).getValue( context );
-    }    
-
-    public void setValue(ExecutionContext context,
-                         Object object) {
-        throw new RuntimeException( "You cannot set the value on a Function" );
-    }
-
-    public void replaceTempTokens(Map variables) {
-        for ( int i = 0, length = this.parameters.length; i < length; i++ ) {
-            if ( this.parameters[i] instanceof TempTokenVariable ) {
-                TempTokenVariable var = (TempTokenVariable) this.parameters[i];
-                this.parameters[i] = (ValueHandler) variables.get( var.getIdentifier() );
-            } else if ( this.parameters[i] instanceof FunctionCaller ) {
-                ((FunctionCaller) parameters[i]).replaceTempTokens( variables );
-            } else if ( this.parameters[i] instanceof ListValueHandler ) {
-                ((ListValueHandler) parameters[i]).replaceTempTokens( variables );
-            }
-        }
-    }
-
-    public BigDecimal getBigDecimalValue(ExecutionContext context) throws NumberFormatException {
-        return resolveFunction( this, context ).getBigDecimalValue( context );
-    }
-
-    public BigInteger getBigIntegerValue(ExecutionContext context) throws NumberFormatException {
-        return resolveFunction( this, context ).getBigIntegerValue( context );
-    }
-
-    public boolean getBooleanValue(ExecutionContext context) throws ClassCastException {
-        return resolveFunction( this, context ).getBooleanValue( context );
-    }
-
-    public double getDoubleValue(ExecutionContext context) throws NumberFormatException {
-        return resolveFunction( this, context ).getDoubleValue( context );
-    }
-
-    public float getFloatValue(ExecutionContext context) throws NumberFormatException {
-        return resolveFunction( this, context ).getFloatValue( context );
-    }
-
-    public int getIntValue(ExecutionContext context) throws NumberFormatException {
-        return resolveFunction( this, context ).getIntValue( context );
-    }
-
-    public long getLongValue(ExecutionContext context) throws NumberFormatException {
-        return resolveFunction( this, context ).getLongValue( context );
-    }
-
-    public short getShortValue(ExecutionContext context) throws NumberFormatException {
-        return resolveFunction( this, context ).getShortValue( context );
-    }
-
-    public String getStringValue(ExecutionContext context) {
-        return resolveFunction( this, context ).getStringValue( context );
-    }
-
-    public String toString() {
-        return "[FunctionCaller " + this.function + "]";
-    }
-
-}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/FunctionCaller.java (from rev 10541, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/valuehandlers/FunctionCaller.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/FunctionCaller.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/FunctionCaller.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,134 @@
+package org.drools.clp.valuehandlers;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Map;
+
+import org.drools.base.SimpleValueType;
+import org.drools.clp.ExecutionContext;
+import org.drools.clp.Function;
+import org.drools.clp.LispList;
+import org.drools.clp.ValueHandler;
+
+public class FunctionCaller
+    implements
+    ValueHandler {
+    private Function         function;
+
+    protected ValueHandler[] parameters;
+
+    public FunctionCaller() {
+        this( null );
+    }
+
+    public FunctionCaller(Function function) {
+        this.function = function;
+    }
+
+    public ValueHandler getValue(ExecutionContext context) {
+        return this.function.execute( this.parameters,
+                                      context );
+    }
+
+    public int getValueType(ExecutionContext context) {
+        return SimpleValueType.FUNCTION;
+    }
+
+    public void setFunction(Function function) {
+        this.function = function;
+    }
+
+    public Function getFunction() {
+        return this.function;
+    }
+
+    public String getName() {
+        return (this.function == null) ? null : this.function.getName();
+    }
+
+    public LispList createList(int index) {
+        return this.function.createList( index );
+    }
+
+    public void addParameter(ValueHandler valueHandler) {
+        if ( this.parameters == null ) {
+            this.parameters = new ValueHandler[]{valueHandler};
+        } else {
+            ValueHandler[] temp = new ValueHandler[parameters.length + 1];
+            System.arraycopy( this.parameters,
+                              0,
+                              temp,
+                              0,
+                              this.parameters.length );
+            temp[temp.length - 1] = valueHandler;
+            this.parameters = temp;
+        }
+    }
+
+    public ValueHandler[] getParameters() {
+        return this.parameters;
+    }
+
+    public Object getObject(ExecutionContext context) {
+        return getValue( context ).getObject( context );
+    }
+
+    public void setValue(ExecutionContext context,
+                         Object object) {
+        throw new RuntimeException( "You cannot set the value on a Function" );
+    }
+
+    public void replaceTempTokens(Map variables) {
+        for ( int i = 0, length = this.parameters.length; i < length; i++ ) {
+            if ( this.parameters[i] instanceof TempTokenVariable ) {
+                TempTokenVariable var = (TempTokenVariable) this.parameters[i];
+                this.parameters[i] = (ValueHandler) variables.get( var.getIdentifier() );
+            } else if ( this.parameters[i] instanceof FunctionCaller ) {
+                ((FunctionCaller) parameters[i]).replaceTempTokens( variables );
+            } else if ( this.parameters[i] instanceof ListValueHandler ) {
+                ((ListValueHandler) parameters[i]).replaceTempTokens( variables );
+            }
+        }
+    }
+
+    public BigDecimal getBigDecimalValue(ExecutionContext context) throws NumberFormatException {
+        return getValue( context ).getBigDecimalValue( context );
+    }
+
+    public BigInteger getBigIntegerValue(ExecutionContext context) throws NumberFormatException {
+        return getValue( context ).getBigIntegerValue( context );
+    }
+
+    public boolean getBooleanValue(ExecutionContext context) throws ClassCastException {
+        return getValue( context ).getBooleanValue( context );
+    }
+
+    public double getDoubleValue(ExecutionContext context) throws NumberFormatException {
+        return getValue( context ).getDoubleValue( context );
+    }
+
+    public float getFloatValue(ExecutionContext context) throws NumberFormatException {
+        return getValue( context ).getFloatValue( context );
+    }
+
+    public int getIntValue(ExecutionContext context) throws NumberFormatException {
+        return getValue( context ).getIntValue( context );
+    }
+
+    public long getLongValue(ExecutionContext context) throws NumberFormatException {
+        return getValue( context ).getLongValue( context );
+    }
+
+    public short getShortValue(ExecutionContext context) throws NumberFormatException {
+        return getValue( context ).getShortValue( context );
+    }
+
+    public String getStringValue(ExecutionContext context) {
+        return getValue( context ).getStringValue( context );
+    }
+
+    public String toString() {
+        return "[FunctionCaller " + this.function + "]";
+    }
+
+}

Deleted: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/ListValueHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/valuehandlers/ListValueHandler.java	2007-03-24 19:59:03 UTC (rev 10522)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/ListValueHandler.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -1,113 +0,0 @@
-package org.drools.clp.ValueHandlers;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.Map;
-
-import org.drools.base.SimpleValueType;
-import org.drools.clp.ExecutionContext;
-import org.drools.clp.ValueHandler;
-
-public class ListValueHandler implements ValueHandler {
-    private ValueHandler[] list;
-    
-    public ListValueHandler() {
-        
-    }
-    
-    public int getValueType(ExecutionContext context) {
-        return SimpleValueType.LIST;
-    }    
-    
-    public void add(ValueHandler valueHandler) {
-        if (this.list == null) {
-            this.list = new ValueHandler[] { valueHandler};
-        } else {
-            ValueHandler[] temp =  new ValueHandler[ this.list.length + 1 ];
-            System.arraycopy( this.list, 0, temp, 0, this.list.length );
-            temp[ temp.length - 1] = valueHandler;
-            this.list = temp;             
-        }            
-    }
-    
-    public ValueHandler[] getList() {
-        return this.list;
-    }
-
-    public BigDecimal getBigDecimalValue(ExecutionContext context) throws NumberFormatException {
-        throw new RuntimeException( "ListValueHandler cannot return BigDecimal" );
-    }
-
-    public BigInteger getBigIntegerValue(ExecutionContext context) throws NumberFormatException {
-        throw new RuntimeException( "ListValueHandler cannot return BigInteger" );
-    }
-
-    public boolean getBooleanValue(ExecutionContext context) throws ClassCastException {
-        throw new RuntimeException( "ListValueHandler cannot return Boolean" );
-    }
-
-    public double getDoubleValue(ExecutionContext context) throws NumberFormatException {
-        throw new RuntimeException( "ListValueHandler cannot return Double" );
-    }
-
-    public float getFloatValue(ExecutionContext context) throws NumberFormatException {
-        throw new RuntimeException( "ListValueHandler cannot return Float" );
-    }
-
-    public int getIntValue(ExecutionContext context) throws NumberFormatException {
-        throw new RuntimeException( "ListValueHandler cannot return Int" );
-    }
-
-    public long getLongValue(ExecutionContext context) throws NumberFormatException {
-        throw new RuntimeException( "ListValueHandler cannot return Long" );
-    }
-
-    public short getShortValue(ExecutionContext context) throws NumberFormatException {
-        throw new RuntimeException( "ListValueHandler cannot return Short" );
-    }
-
-    public String getStringValue(ExecutionContext context) {
-        throw new RuntimeException( "ListValueHandler cannot return String" );
-    }
-
-    public Object getValue(ExecutionContext context) {
-        return this.list;
-    }
-
-    public void setValue(ExecutionContext context,
-                         Object object) {
-        throw new RuntimeException( "cannot set value on ListValueHandler" );       
-    }
-    
-    public void replaceTempTokens(Map variables) {
-        for ( int i = 0, length = this.list.length; i < length; i++ ) {
-            if ( this.list[i] instanceof TempTokenVariable ) {
-                TempTokenVariable var = ( TempTokenVariable ) this.list[i]; 
-                this.list[i] = ( ValueHandler ) variables.get( var.getIdentifier() );
-            } else if ( this.list[i] instanceof FunctionCaller ) {
-                ((FunctionCaller)list[i]).replaceTempTokens( variables );
-            } else if ( this.list[i] instanceof ListValueHandler ) {
-                ((ListValueHandler)list[i]).replaceTempTokens( variables );
-            }
-        }  
-    }    
-    
-    public int size() {
-        return (this.list == null) ? 0 : this.list.length;
-    }
-    
-    public boolean isEmpty() {
-        return (this.list == null) ? true : this.list.length > 0; 
-    }
-    
-    public String toString() {
-        StringBuffer b = new StringBuffer();
-        b.append( "[ListValueHandler " );
-        for ( int i = 0, length = this.list.length; i < length; i++ ) {
-            b.append( this.list[i] + " " );
-        }
-        b.append("]");
-                
-        return b.toString();
-    }
-}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/ListValueHandler.java (from rev 10541, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/valuehandlers/ListValueHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/ListValueHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/ListValueHandler.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,154 @@
+package org.drools.clp.valuehandlers;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Map;
+
+import org.drools.base.SimpleValueType;
+import org.drools.clp.ExecutionContext;
+import org.drools.clp.ValueHandler;
+
+public class ListValueHandler
+    implements
+    ValueHandler {
+    private ValueHandler[] list;
+
+    public ListValueHandler() {
+
+    }
+
+    public ValueHandler getValue(ExecutionContext context) {
+        return null;
+    }
+
+    public int getValueType(ExecutionContext context) {
+        return SimpleValueType.LIST;
+    }
+
+    public void add(ListValueHandler list,
+                    ExecutionContext context) {
+        add( list.getList(),
+             context );
+    }
+
+    public void add(ValueHandler[] valueHandlers,
+                    ExecutionContext context) {
+        for ( int i = 0, length = valueHandlers.length; i < length; i++ ) {
+            add( valueHandlers[i],
+                 context );
+        }
+    }
+
+    public void add(ValueHandler valueHandler,
+                    ExecutionContext context) {
+        ValueHandler nested = valueHandler.getValue( context );
+        valueHandler = (nested != null ) ? nested : valueHandler;
+        if ( valueHandler instanceof ListValueHandler ) {
+            add( (ListValueHandler) valueHandler,
+                 context );
+        } else {
+            add( valueHandler );
+        }
+    }
+
+    public void add(ValueHandler valueHandler) {
+        if ( this.list == null ) {
+            this.list = new ValueHandler[]{valueHandler};
+        } else {
+            ValueHandler[] temp = new ValueHandler[this.list.length + 1];
+            System.arraycopy( this.list,
+                              0,
+                              temp,
+                              0,
+                              this.list.length );
+            temp[temp.length - 1] = valueHandler;
+            this.list = temp;
+        }
+    }
+
+    public ValueHandler[] getList() {
+        return this.list;
+    }
+
+    public BigDecimal getBigDecimalValue(ExecutionContext context) throws NumberFormatException {
+        throw new RuntimeException( "ListValueHandler cannot return BigDecimal" );
+    }
+
+    public BigInteger getBigIntegerValue(ExecutionContext context) throws NumberFormatException {
+        throw new RuntimeException( "ListValueHandler cannot return BigInteger" );
+    }
+
+    public boolean getBooleanValue(ExecutionContext context) throws ClassCastException {
+        throw new RuntimeException( "ListValueHandler cannot return Boolean" );
+    }
+
+    public double getDoubleValue(ExecutionContext context) throws NumberFormatException {
+        throw new RuntimeException( "ListValueHandler cannot return Double" );
+    }
+
+    public float getFloatValue(ExecutionContext context) throws NumberFormatException {
+        throw new RuntimeException( "ListValueHandler cannot return Float" );
+    }
+
+    public int getIntValue(ExecutionContext context) throws NumberFormatException {
+        throw new RuntimeException( "ListValueHandler cannot return Int" );
+    }
+
+    public long getLongValue(ExecutionContext context) throws NumberFormatException {
+        throw new RuntimeException( "ListValueHandler cannot return Long" );
+    }
+
+    public short getShortValue(ExecutionContext context) throws NumberFormatException {
+        throw new RuntimeException( "ListValueHandler cannot return Short" );
+    }
+
+    public String getStringValue(ExecutionContext context) {
+        throw new RuntimeException( "ListValueHandler cannot return String" );
+    }
+
+    public Object getObject(ExecutionContext context) {
+        Object[] objects = new Object[this.list.length];
+        for ( int i = 0, length = this.list.length; i < length; i++ ) {
+            objects[i] = this.list[i].getObject( context );
+        }
+
+        return objects;
+    }
+
+    public void setValue(ExecutionContext context,
+                         Object object) {
+        throw new RuntimeException( "cannot set value on ListValueHandler" );
+    }
+
+    public void replaceTempTokens(Map variables) {
+        for ( int i = 0, length = this.list.length; i < length; i++ ) {
+            if ( this.list[i] instanceof TempTokenVariable ) {
+                TempTokenVariable var = (TempTokenVariable) this.list[i];
+                this.list[i] = (ValueHandler) variables.get( var.getIdentifier() );
+            } else if ( this.list[i] instanceof FunctionCaller ) {
+                ((FunctionCaller) list[i]).replaceTempTokens( variables );
+            } else if ( this.list[i] instanceof ListValueHandler ) {
+                ((ListValueHandler) list[i]).replaceTempTokens( variables );
+            }
+        }
+    }
+
+    public int size() {
+        return (this.list == null) ? 0 : this.list.length;
+    }
+
+    public boolean isEmpty() {
+        return (this.list == null) ? true : this.list.length > 0;
+    }
+
+    public String toString() {
+        StringBuffer b = new StringBuffer();
+        b.append( "[ListValueHandler " );
+        for ( int i = 0, length = this.list.length; i < length; i++ ) {
+            b.append( this.list[i] + " " );
+        }
+        b.append( "]" );
+
+        return b.toString();
+    }
+}

Deleted: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/LocalVariableValue.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/valuehandlers/LocalVariableValue.java	2007-03-24 19:59:03 UTC (rev 10522)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/LocalVariableValue.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -1,62 +0,0 @@
-package org.drools.clp.ValueHandlers;
-
-import org.drools.clp.ExecutionContext;
-import org.drools.clp.ValueHandler;
-import org.drools.clp.VariableValueHandler;
-
-
-public class LocalVariableValue extends BaseValueHandler implements VariableValueHandler {
-    private static final long serialVersionUID = 320L;    
-
-    /** The identifier for the variable. */
-    private final String      identifier;    
-    private final int         index;
-    
-    /**
-     * Construct.
-     * 
-     * @param identifier
-     *            The name of the variable.
-     */
-    public LocalVariableValue(final String identifier, final int index) {
-        this.identifier = identifier;
-        this.index = index;
-    }
-    
-    /**
-     * Retrieve the variable's identifier.
-     * 
-     * @return The variable's identifier.
-     */
-    public String getIdentifier() {
-        return this.identifier;
-    }
-    
-    public int getValueType(ExecutionContext context) {
-        return context.getLocalVariable( this.index ).getValueType( context );
-    }
-    
-    public Object getValue(ExecutionContext context) {
-        Object object = context.getLocalVariable( this.index ).getValue( context );
-        //if ( object instanceof )
-        return object;
-    }        
-    
-    public ValueHandler getRawValue(ExecutionContext context) {
-        // this is a hack as some parts of the system need the ValueHandler and not the Value
-        return context.getLocalVariable( this.index );
-    }
-
-    public void setValue(ExecutionContext context,
-                         Object object) {
-        context.setLocalVariable( this.index, (ValueHandler) object );        
-    }        
-    
-    public String toString() {
-        String name = getClass().getName();
-        name = name.substring( name.lastIndexOf( "." ) + 1 );
-        return "[" + name + " identifier = '" + getIdentifier()  + "']";
-    }    
-        
-}
-

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/LocalVariableValue.java (from rev 10541, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/valuehandlers/LocalVariableValue.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/LocalVariableValue.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/LocalVariableValue.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,64 @@
+package org.drools.clp.valuehandlers;
+
+import org.drools.clp.ExecutionContext;
+import org.drools.clp.ValueHandler;
+import org.drools.clp.VariableValueHandler;
+
+
+public class LocalVariableValue extends BaseValueHandler implements VariableValueHandler {
+    private static final long serialVersionUID = 320L;    
+
+    /** The identifier for the variable. */
+    private final String      identifier;    
+    private final int         index;
+    
+    /**
+     * Construct.
+     * 
+     * @param identifier
+     *            The name of the variable.
+     */
+    public LocalVariableValue(final String identifier, final int index) {
+        this.identifier = identifier;
+        this.index = index;
+    }
+        
+    /**
+     * Retrieve the variable's identifier.
+     * 
+     * @return The variable's identifier.
+     */
+    public String getIdentifier() {
+        return this.identifier;
+    }
+    
+    public int getValueType(ExecutionContext context) {
+        return context.getLocalVariable( this.index ).getValueType( context );
+    }
+    
+    public Object getObject(ExecutionContext context) {        
+        return getValue(context).getObject( context );
+    }        
+    
+    public ValueHandler getValue(ExecutionContext context) {
+        ValueHandler valueHandler = context.getLocalVariable( this.index );
+        ValueHandler nested; 
+        while ( (nested = valueHandler.getValue( context ) ) != null ) {
+            valueHandler = nested;
+        }
+        return valueHandler;
+    }
+
+    public void setValue(ExecutionContext context,
+                         Object object) {
+        context.setLocalVariable( this.index, (ValueHandler) object );        
+    }        
+    
+    public String toString() {
+        String name = getClass().getName();
+        name = name.substring( name.lastIndexOf( "." ) + 1 );
+        return "[" + name + " identifier = '" + getIdentifier()  + "']";
+    }    
+        
+}
+

Deleted: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/LongValueHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/valuehandlers/LongValueHandler.java	2007-03-24 19:59:03 UTC (rev 10522)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/LongValueHandler.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -1,90 +0,0 @@
-package org.drools.clp.ValueHandlers;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
-import org.drools.base.SimpleValueType;
-import org.drools.clp.ExecutionContext;
-import org.drools.clp.ValueHandler;
-
-public class LongValueHandler implements ValueHandler {
-    private long longValue;
-    
-    public LongValueHandler(String longValue) {
-        this.longValue = Long.valueOf( longValue ).longValue();
-    } 
-    
-    public int getValueType(ExecutionContext context) {
-        return SimpleValueType.INTEGER;
-    }    
-    
-    public LongValueHandler(long longValue) {
-        this.longValue = longValue;
-    }
-
-    public void setValue(ExecutionContext context, Object value) {
-        throw new RuntimeException( "LiteralValues cannot be set");
-    }
-    
-    public Object getValue(ExecutionContext context) {
-        return new Long( this.longValue );
-    }
-    
-    public BigDecimal getBigDecimalValue(ExecutionContext context) throws NumberFormatException {
-        return new BigDecimal( this.longValue );
-    }
-
-    public BigInteger getBigIntegerValue(ExecutionContext context) throws NumberFormatException {
-        return BigInteger.valueOf( this.longValue );
-    }
-
-    public boolean getBooleanValue(ExecutionContext context) throws ClassCastException {
-        return ( this.longValue == 0 ) ? false : true;
-    }
-
-    public double getDoubleValue(ExecutionContext context) throws NumberFormatException {
-        return this.longValue;
-    }
-
-    public float getFloatValue(ExecutionContext context) throws NumberFormatException {
-        return this.longValue;
-    }
-
-    public int getIntValue(ExecutionContext context) throws NumberFormatException {
-        return (int) this.longValue;
-    }
-
-    public long getLongValue(ExecutionContext context) throws NumberFormatException {
-        return this.longValue;
-    }
-
-    public short getShortValue(ExecutionContext context) throws NumberFormatException {
-        return (short) this.longValue;
-    }
-
-    public String getStringValue(ExecutionContext context) {
-        return Long.toString( this.longValue );
-    }
-    
-    public String toString() {
-        return "[LongLiteralValue value='" + this.longValue + "']";
-    }
-
-    public int hashCode() {
-        final int PRIME = 31;
-        int result = 1;
-        result = PRIME * result + (int) (longValue ^ (longValue >>> 32));
-        return result;
-    }
-
-    public boolean equals(Object obj) {
-        if ( this == obj ) return true;
-        if ( obj == null ) return false;
-        if ( ! ( obj instanceof LongValueHandler ) ) return false;
-        final LongValueHandler other = (LongValueHandler) obj;
-        if ( longValue != other.longValue ) return false;
-        return true;
-    }      
-    
-    
-}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/LongValueHandler.java (from rev 10541, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/valuehandlers/LongValueHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/LongValueHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/LongValueHandler.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,94 @@
+package org.drools.clp.valuehandlers;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+import org.drools.base.SimpleValueType;
+import org.drools.clp.ExecutionContext;
+import org.drools.clp.ValueHandler;
+
+public class LongValueHandler implements ValueHandler {
+    private long longValue;
+    
+    public LongValueHandler(String longValue) {
+        this.longValue = Long.valueOf( longValue ).longValue();
+    } 
+    
+    public int getValueType(ExecutionContext context) {
+        return SimpleValueType.INTEGER;
+    }    
+    
+    public LongValueHandler(long longValue) {
+        this.longValue = longValue;
+    }   
+    
+    public ValueHandler getValue(ExecutionContext context) {
+        return null;
+    }      
+
+    public void setValue(ExecutionContext context, Object value) {
+        throw new RuntimeException( "LiteralValues cannot be set");
+    }
+    
+    public Object getObject(ExecutionContext context) {
+        return new Long( this.longValue );
+    }
+    
+    public BigDecimal getBigDecimalValue(ExecutionContext context) throws NumberFormatException {
+        return new BigDecimal( this.longValue );
+    }
+
+    public BigInteger getBigIntegerValue(ExecutionContext context) throws NumberFormatException {
+        return BigInteger.valueOf( this.longValue );
+    }
+
+    public boolean getBooleanValue(ExecutionContext context) throws ClassCastException {
+        return ( this.longValue == 0 ) ? false : true;
+    }
+
+    public double getDoubleValue(ExecutionContext context) throws NumberFormatException {
+        return this.longValue;
+    }
+
+    public float getFloatValue(ExecutionContext context) throws NumberFormatException {
+        return this.longValue;
+    }
+
+    public int getIntValue(ExecutionContext context) throws NumberFormatException {
+        return (int) this.longValue;
+    }
+
+    public long getLongValue(ExecutionContext context) throws NumberFormatException {
+        return this.longValue;
+    }
+
+    public short getShortValue(ExecutionContext context) throws NumberFormatException {
+        return (short) this.longValue;
+    }
+
+    public String getStringValue(ExecutionContext context) {
+        return Long.toString( this.longValue );
+    }
+    
+    public String toString() {
+        return "[LongLiteralValue value='" + this.longValue + "']";
+    }
+
+    public int hashCode() {
+        final int PRIME = 31;
+        int result = 1;
+        result = PRIME * result + (int) (longValue ^ (longValue >>> 32));
+        return result;
+    }
+
+    public boolean equals(Object obj) {
+        if ( this == obj ) return true;
+        if ( obj == null ) return false;
+        if ( ! ( obj instanceof LongValueHandler ) ) return false;
+        final LongValueHandler other = (LongValueHandler) obj;
+        if ( longValue != other.longValue ) return false;
+        return true;
+    }      
+    
+    
+}

Deleted: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/ObjectValueHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/valuehandlers/ObjectValueHandler.java	2007-03-24 19:59:03 UTC (rev 10522)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/ObjectValueHandler.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -1,63 +0,0 @@
-package org.drools.clp.ValueHandlers;
-
-import org.drools.base.SimpleValueType;
-import org.drools.clp.ExecutionContext;
-
-public class ObjectValueHandler extends BaseValueHandler {
-    public static final ObjectValueHandler NULL = new ObjectValueHandler( "null" );    
-    
-    private Object objectValue;
-    
-    public int getValueType(ExecutionContext context) {
-        return SimpleValueType.OBJECT;
-    }
-    
-    public ObjectValueHandler(Object objectValue) {
-        this.objectValue = objectValue;
-    }
-
-    public void setValue(ExecutionContext context, Object value) {
-        throw new RuntimeException( "LiteralValues cannot be set");
-    }
-    
-    public Object getValue(ExecutionContext context) {
-        return this.objectValue;
-    }
-    /*
-    public BigDecimal getBigDecimalValue(ExecutionContext context) throws NumberFormatException {
-        return (BigDecimal) getValue(context);
-    }
-
-    public BigInteger getBigIntegerValue(ExecutionContext context) throws NumberFormatException {
-        return (BigInteger) getValue(context);
-    }
-
-    public boolean getBooleanValue(ExecutionContext context) throws ClassCastException {
-        return ((Boolean) getValue(context)).booleanValue();
-    }
-
-    public double getDoubleValue(ExecutionContext context) throws NumberFormatException {
-        return ((Double) getValue(context)).doubleValue();
-    }
-
-    public float getFloatValue(ExecutionContext context) throws NumberFormatException {
-        return ((Float) getValue(context)).floatValue();
-    }
-
-    public int getIntValue(ExecutionContext context) throws NumberFormatException {
-        return ((Integer) getValue(context)).intValue();
-    }
-
-    public long getLongValue(ExecutionContext context) throws NumberFormatException {
-        return ((Long) getValue(context)).longValue();
-    }
-
-    public short getShortValue(ExecutionContext context) throws NumberFormatException {
-        return ((Short) getValue(context)).shortValue();
-    }
-
-    public String getStringValue(ExecutionContext context) {
-        return (String) getValue(context);
-    }      */
-
-}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/ObjectValueHandler.java (from rev 10541, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/valuehandlers/ObjectValueHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/ObjectValueHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/ObjectValueHandler.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,32 @@
+package org.drools.clp.valuehandlers;
+
+import org.drools.base.SimpleValueType;
+import org.drools.clp.ExecutionContext;
+import org.drools.clp.ValueHandler;
+
+public class ObjectValueHandler extends BaseValueHandler {
+    public static final ObjectValueHandler NULL = new ObjectValueHandler( "null" );    
+    
+    private Object objectValue;       
+    
+    public ObjectValueHandler(Object objectValue) {
+        this.objectValue = objectValue;
+    }
+    
+    public int getValueType(ExecutionContext context) {
+        return SimpleValueType.OBJECT;
+    }
+    
+    public ValueHandler getValue(ExecutionContext context) {
+        return null;
+    }    
+    
+    public void setValue(ExecutionContext context, Object value) {
+        throw new RuntimeException( "LiteralValues cannot be set");
+    }
+    
+    public Object getObject(ExecutionContext context) {
+        return this.objectValue;
+    }
+
+}

Deleted: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/TempTokenVariable.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/valuehandlers/TempTokenVariable.java	2007-03-24 19:59:03 UTC (rev 10522)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/TempTokenVariable.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -1,36 +0,0 @@
-package org.drools.clp.ValueHandlers;
-
-import org.drools.base.SimpleValueType;
-import org.drools.clp.ExecutionContext;
-import org.drools.clp.VariableValueHandler;
-
-
-public class TempTokenVariable extends BaseValueHandler implements VariableValueHandler {
-
-    private String identifier;
-    
-    public TempTokenVariable(String identifier) {
-        this.identifier = identifier;
-    }
-
-    public String getIdentifier() {
-        return this.identifier;
-    }
-    
-    public int getValueType(ExecutionContext context) {
-        return SimpleValueType.UNKNOWN;
-    }    
-
-    public Object getValue(ExecutionContext context) {
-        throw new UnsupportedOperationException( "TempTokenVariable Variable identifer='" + getIdentifier() + " cannot be read" );
-    }
-
-    public void setValue(ExecutionContext context, Object value) {
-        throw new UnsupportedOperationException( "TempTokenVariable Variable identifer='" + getIdentifier() + " cannot be set" );
-    }
-
-    public void setContext(ExecutionContext context) {
-
-    }
-
-}

Copied: labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/TempTokenVariable.java (from rev 10541, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/clp/valuehandlers/TempTokenVariable.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/TempTokenVariable.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/java/org/drools/clp/valuehandlers/TempTokenVariable.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,41 @@
+package org.drools.clp.valuehandlers;
+
+import org.drools.base.SimpleValueType;
+import org.drools.clp.ExecutionContext;
+import org.drools.clp.ValueHandler;
+import org.drools.clp.VariableValueHandler;
+
+
+public class TempTokenVariable extends BaseValueHandler implements VariableValueHandler {
+
+    private String identifier;
+    
+    public TempTokenVariable(String identifier) {
+        this.identifier = identifier;
+    }
+    
+    public ValueHandler getValue(ExecutionContext context) {
+        return null;
+    }    
+
+    public String getIdentifier() {
+        return this.identifier;
+    }
+    
+    public int getValueType(ExecutionContext context) {
+        return SimpleValueType.UNKNOWN;
+    }    
+
+    public Object getObject(ExecutionContext context) {
+        throw new UnsupportedOperationException( "TempTokenVariable Variable identifer='" + getIdentifier() + " cannot be read" );
+    }
+
+    public void setValue(ExecutionContext context, Object value) {
+        throw new UnsupportedOperationException( "TempTokenVariable Variable identifer='" + getIdentifier() + " cannot be set" );
+    }
+
+    public void setContext(ExecutionContext context) {
+
+    }
+
+}

Copied: labs/jbossrules/trunk/drools-clips/src/main/resources/org/drools/clp/CLP.g (from rev 10524, labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/clp/CLP.g)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/resources/org/drools/clp/CLP.g	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/resources/org/drools/clp/CLP.g	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,694 @@
+grammar CLP;
+
+ at parser::header {
+	package org.drools.clp;
+	
+	import org.drools.clp.valuehandlers.*;
+	import java.util.List;
+	import java.util.ArrayList;
+	import java.util.Iterator;
+	import java.util.HashMap;	
+	import java.util.StringTokenizer;
+	import org.drools.lang.descr.*;
+	import org.drools.compiler.SwitchingCommonTokenStream;
+}
+
+ at parser::members {
+	private PackageDescr packageDescr;
+	private List errors = new ArrayList();
+	private String source = "unknown";
+	private int lineOffset = 0;
+	private DescrFactory factory = new DescrFactory();
+	private boolean parserDebug = false;
+	private FunctionRegistry functionRegistry;
+	
+    FunctionRegistry factoryRegistry;
+	
+	public void setFunctionRegistry(FunctionRegistry functionRegistry) {
+		this.functionRegistry = functionRegistry;
+	}
+	
+	public void setParserDebug(boolean parserDebug) {
+		this.parserDebug = parserDebug;
+	}		
+	
+	public void debug(String message) {
+		if ( parserDebug ) 
+			System.err.println( "drl parser: " + message );
+	}
+	
+	public void setSource(String source) {
+		this.source = source;
+	}
+	public DescrFactory getFactory() {
+		return factory;
+	}	
+
+	public String getSource() {
+		return this.source;
+	}
+	
+	public PackageDescr getPackageDescr() {
+		return packageDescr;
+	}
+	
+	private int offset(int line) {
+		return line + lineOffset;
+	}
+	
+	/**
+	 * This will set the offset to record when reparsing. Normally is zero of course 
+	 */
+	public void setLineOffset(int i) {
+	 	this.lineOffset = i;
+	}
+	
+	private String getString(Token token) {
+		String orig = token.getText();
+		return orig.substring( 1, orig.length() -1 );
+	}
+	
+	public void reportError(RecognitionException ex) {
+	        // if we've already reported an error and have not matched a token
+                // yet successfully, don't report any errors.
+                if ( errorRecovery ) {
+                        return;
+                }
+                errorRecovery = true;
+
+		ex.line = offset(ex.line); //add the offset if there is one
+		errors.add( ex ); 
+	}
+     	
+     	/** return the raw RecognitionException errors */
+     	public List getErrors() {
+     		return errors;
+     	}
+     	
+     	/** Return a list of pretty strings summarising the errors */
+     	public List getErrorMessages() {
+     		List messages = new ArrayList();
+ 		for ( Iterator errorIter = errors.iterator() ; errorIter.hasNext() ; ) {
+     	     		messages.add( createErrorMessage( (RecognitionException) errorIter.next() ) );
+     	     	}
+     	     	return messages;
+     	}
+     	
+     	/** return true if any parser errors were accumulated */
+     	public boolean hasErrors() {
+  		return ! errors.isEmpty();
+     	}
+     	
+     	/** This will take a RecognitionException, and create a sensible error message out of it */
+     	public String createErrorMessage(RecognitionException e)
+        {
+		StringBuffer message = new StringBuffer();		
+                message.append( source + ":"+e.line+":"+e.charPositionInLine+" ");
+                if ( e instanceof MismatchedTokenException ) {
+                        MismatchedTokenException mte = (MismatchedTokenException)e;
+                        message.append("mismatched token: "+
+                                                           e.token+
+                                                           "; expecting type "+
+                                                           tokenNames[mte.expecting]);
+                }
+                else if ( e instanceof MismatchedTreeNodeException ) {
+                        MismatchedTreeNodeException mtne = (MismatchedTreeNodeException)e;
+                        message.append("mismatched tree node: "+
+                                                           mtne.foundNode+
+                                                           "; expecting type "+
+                                                           tokenNames[mtne.expecting]);
+                }
+                else if ( e instanceof NoViableAltException ) {
+                        NoViableAltException nvae = (NoViableAltException)e;
+			message.append( "Unexpected token '" + e.token.getText() + "'" );
+                        /*
+                        message.append("decision=<<"+nvae.grammarDecisionDescription+">>"+
+                                                           " state "+nvae.stateNumber+
+                                                           " (decision="+nvae.decisionNumber+
+                                                           ") no viable alt; token="+
+                                                           e.token);
+                                                           */
+                }
+                else if ( e instanceof EarlyExitException ) {
+                        EarlyExitException eee = (EarlyExitException)e;
+                        message.append("required (...)+ loop (decision="+
+                                                           eee.decisionNumber+
+                                                           ") did not match anything; token="+
+                                                           e.token);
+                }
+                else if ( e instanceof MismatchedSetException ) {
+                        MismatchedSetException mse = (MismatchedSetException)e;
+                        message.append("mismatched token '"+
+                                                           e.token+
+                                                           "' expecting set "+mse.expecting);
+                }
+                else if ( e instanceof MismatchedNotSetException ) {
+                        MismatchedNotSetException mse = (MismatchedNotSetException)e;
+                        message.append("mismatched token '"+
+                                                           e.token+
+                                                           "' expecting set "+mse.expecting);
+                }
+                else if ( e instanceof FailedPredicateException ) {
+                        FailedPredicateException fpe = (FailedPredicateException)e;
+                        message.append("rule "+fpe.ruleName+" failed predicate: {"+
+                                                           fpe.predicateText+"}?");
+                } else if (e instanceof GeneralParseException) {
+			message.append(" " + e.getMessage());
+		}
+               	return message.toString();
+        }   
+        
+        void checkTrailingSemicolon(String text, int line) {
+        	if (text.trim().endsWith( ";" ) ) {
+        		this.errors.add( new GeneralParseException( "Trailing semi-colon not allowed", offset(line) ) );
+        	}
+        }
+      
+}
+
+ at lexer::header {
+	package org.drools.clp;
+}
+
+/*
+opt_semicolon
+	: ';'?
+	;
+
+
+compilation_unit
+	:	
+		( statement )+
+	;
+*/
+/*
+statement
+	:
+	//later we add the other possible statements here 
+	(  //do something with the returned rule here )
+	;
+*/		
+/* prolog
+	@init {
+		String packageName = "";
+	}
+	:	( n=package_statement { packageName = n; } )?
+		{ 
+			this.packageDescr = factory.createPackage( packageName ); 
+		}
+	;
+	
+statement
+	:
+	(	import_statement 
+	|       function_import_statement 
+	|	global 
+	|	function 
+	|       t=template {this.packageDescr.addFactTemplate( t ); }
+	|	r=rule { if( r != null ) this.packageDescr.addRule( r ); }			
+	|	q=query	{ if( q != null ) this.packageDescr.addRule( q ); }
+	) 
+	;
+
+package_statement returns [String packageName]
+	@init{
+		packageName = null;
+	}
+	:	
+		PACKAGE n=dotted_name[null] opt_semicolon
+		{
+			packageName = n;
+		}
+	;	
+*/
+
+deffunction
+	:
+	;
+
+defrule returns [RuleDescr rule]
+	@init { 
+	        rule = null; 
+	        AndDescr lhs = null;
+	        ColumnDescr colum = null;
+	        AttributeDescr module = null;	        
+	      }
+	:	loc=LEFT_PAREN 
+		
+		DEFRULE ruleName=NAME
+	  	{ 	  			  		
+	  		debug( "start rule: " + ruleName.getText() );
+	  		String ruleStr = ruleName.getText();
+
+	        if ( ruleStr.indexOf("::") >= 0 ) {
+	            String mod = ruleStr.substring(0, ruleStr.indexOf("::"));
+	            ruleStr = ruleStr.substring(ruleStr.indexOf("::")+2);
+				module = new AttributeDescr( "agenda-group", mod );
+				module.setLocation( offset(ruleName.getLine()), ruleName.getCharPositionInLine() );
+				module.setStartCharacter( ((CommonToken)ruleName).getStartIndex() );
+				module.setEndCharacter( ((CommonToken)ruleName).getStopIndex() );
+			}
+		    
+		    rule = new RuleDescr( ruleStr, null ); 
+		    if( module != null ) {
+		    	rule.addAttribute( module );
+		    }
+		        
+			rule.setLocation( offset(loc.getLine()), loc.getCharPositionInLine() );
+			rule.setStartCharacter( ((CommonToken)loc).getStartIndex() ); 
+		
+			// not sure how you define where a LHS starts in clips, so just putting it here for now
+  	        	lhs = new AndDescr(); 
+	  	        rule.setLhs( lhs ); 
+   		        lhs.setLocation( offset(loc.getLine()), loc.getCharPositionInLine() );
+			lhs.setStartCharacter( ((CommonToken)loc).getStartIndex() );				
+		}
+		documentation=STRING {
+	    	// do nothing here for now
+		}
+		ruleAttribute[rule]
+		
+		ce[lhs]*
+		
+		'=>'
+		
+		engine=rhs { rule.setConsequence( engine ); }
+		
+		RIGHT_PAREN
+	;
+
+
+ruleAttribute[RuleDescr rule]
+	:
+		( LEFT_PAREN 'declare'
+			( LEFT_PAREN d=salience { rule.addAttribute( d ); } RIGHT_PAREN )?
+		RIGHT_PAREN )?
+	;	
+
+salience returns [AttributeDescr d ]
+	@init {
+		d = null;
+	}
+	:	
+		loc=SALIENCE i=INT   
+		{
+			d = new AttributeDescr( "salience", i.getText() );
+			d.setLocation( offset(loc.getLine()), loc.getCharPositionInLine() );
+			d.setStartCharacter( ((CommonToken)loc).getStartIndex() );
+			d.setEndCharacter( ((CommonToken)i).getStopIndex() );
+		}
+	;
+		
+
+ce[ConditionalElementDescr in_ce]
+	:	(   and_ce[in_ce]	
+		  | or_ce[in_ce]
+		  | not_ce[in_ce]
+		  | exists_ce[in_ce]		  
+ 		  | eval_ce[in_ce] 		  
+		  | normal_pattern[in_ce]
+		  | bound_pattern[in_ce]
+		)
+	;
+
+rhs returns[ExecutionEngine engine]
+	@init {
+	        engine = new BlockExecutionEngine();
+			ExecutionBuildContext context = new ExecutionBuildContext( engine, functionRegistry );  	
+	}
+	
+	:
+		(fc=lisp_list[context, new LispForm(context) ] { context.addFunction( (FunctionCaller) fc ); })*
+	;	
+	
+and_ce[ConditionalElementDescr in_ce]
+    @init {
+        AndDescr andDescr= null;        
+    }
+	:	LEFT_PAREN	
+		AND {
+	    	andDescr = new AndDescr();
+			in_ce.addDescr( andDescr );
+		}
+		ce[andDescr]+		 
+		RIGHT_PAREN					
+	;	
+	
+or_ce[ConditionalElementDescr in_ce]
+    @init {
+        OrDescr orDescr= null;         
+    }
+	:	LEFT_PAREN	
+		OR {
+	    	orDescr = new OrDescr();
+			in_ce.addDescr( orDescr );
+		}
+		ce[orDescr]+		 
+		RIGHT_PAREN					
+	;	
+	
+not_ce[ConditionalElementDescr in_ce]
+    @init {
+        NotDescr notDescr= null;         
+    }
+	:	LEFT_PAREN	
+		NOT {
+			notDescr = new NotDescr();
+		    in_ce.addDescr( notDescr );
+		}
+		ce[notDescr]		 
+		RIGHT_PAREN					
+	;		
+	
+exists_ce[ConditionalElementDescr in_ce]
+    @init {
+        ExistsDescr existsDescr= null;        
+    }
+	:	LEFT_PAREN	
+		EXISTS {
+		    existsDescr = new ExistsDescr();
+		    in_ce.addDescr( existsDescr );
+		}
+		ce[existsDescr]		 
+		RIGHT_PAREN					
+	;		
+
+eval_ce[ConditionalElementDescr in_ce]
+    @init {
+        EvalDescr evalDescr= null;    
+   		ExecutionEngine engine = new CLPEval();     
+		ExecutionBuildContext context = new ExecutionBuildContext( engine, functionRegistry );   		         
+    }
+	:	LEFT_PAREN	
+		TEST {
+		    evalDescr = new EvalDescr();
+		    in_ce.addDescr( evalDescr );
+		}
+		fc=lisp_list[context, new LispForm(context)] {					
+		    engine.addFunction( (FunctionCaller) fc );		
+			evalDescr.setContent( engine );			
+		}			 
+		RIGHT_PAREN					
+	;		
+
+normal_pattern[ConditionalElementDescr in_ce]
+    @init {
+        ColumnDescr column = null;
+    }
+	:	LEFT_PAREN 
+		name=NAME {
+			column = new ColumnDescr(name.getText());
+			in_ce.addDescr( column );
+		}
+		field_constriant[column]* 	  
+		RIGHT_PAREN
+	;		
+	
+
+
+bound_pattern[ConditionalElementDescr in_ce]
+    @init {
+        ColumnDescr column = null;
+        String identifier = null;
+    }
+	:	var=VAR {
+			identifier = var.getText();
+		}
+		ASSIGN_OP LEFT_PAREN name=NAME 
+		{
+			column = new ColumnDescr(name.getText());
+			column.setIdentifier( identifier );
+			in_ce.addDescr( column );	    
+		}
+		field_constriant[column]* 
+		RIGHT_PAREN	
+	;			
+	
+field_constriant[ColumnDescr column] 
+	@init {
+     	List list = new ArrayList();
+		FieldBindingDescr fbd = null;
+		FieldConstraintDescr fc = null;
+		String op = "==";
+	}    
+	:	
+		LEFT_PAREN f=NAME 
+		{
+			fc = new FieldConstraintDescr(f.getText());
+			fc.setLocation( offset(f.getLine()), f.getCharPositionInLine() );
+			fc.setStartCharacter( ((CommonToken)f).getStartIndex() );
+			column.addDescr( fc );			
+		}	  
+		
+		connected_constraint[fc, column] 
+		RIGHT_PAREN		
+	;
+	
+connected_constraint[FieldConstraintDescr fc, ColumnDescr column]
+	:
+	restriction[fc, column]
+	( 
+	    AMPERSAND { fc.addRestriction(new RestrictionConnectiveDescr(RestrictionConnectiveDescr.AND)); }
+	    connected_constraint[fc, column]
+	| 
+	    PIPE {fc.addRestriction(new RestrictionConnectiveDescr(RestrictionConnectiveDescr.OR)); }
+	    connected_constraint[fc, column]
+	)?
+	;	
+	
+restriction[FieldConstraintDescr fc, ColumnDescr column]
+	@init {
+			String op = "==";
+	}
+	:	(TILDE{op = "!=";})?	 	  	 
+		(	predicate_constraint[op, column]	  	  	
+	  	|	return_value_restriction[op, fc]
+	  	|	variable_restriction[op, fc]
+	  	| 	lc=literal_restriction {
+     	    			fc.addRestriction( new LiteralRestrictionDescr(op, lc, true) );
+		      		op = "==";
+		        } 	  	  	  
+		)		
+	;		
+
+predicate_constraint[String op, ColumnDescr column]	
+    @init {
+   		ExecutionEngine engine = new CLPPredicate();
+		ExecutionBuildContext context = new ExecutionBuildContext( engine, functionRegistry );    
+    }
+	:	COLON
+		fc=lisp_list[context, new LispForm(context)] {	
+		    engine.addFunction( (FunctionCaller) fc );
+			column.addDescr( new PredicateDescr( engine ) );
+		}	
+		
+	;
+
+
+return_value_restriction[String op, FieldConstraintDescr fc]
+	@init {
+		ExecutionEngine engine = new CLPReturnValue();
+		ExecutionBuildContext context = new ExecutionBuildContext( engine, functionRegistry );
+	}
+	:	EQUALS 
+		func=lisp_list[context, new LispForm(context)] {					
+   		    engine.addFunction( (FunctionCaller) func );
+			fc.addRestriction( new ReturnValueRestrictionDescr (op, engine ) );
+		}		
+	;
+		
+variable_restriction[String op, FieldConstraintDescr fc]
+	:	var=VAR {
+			fc.addRestriction( new VariableRestrictionDescr(op, var.getText()) );
+		}
+	;	
+
+	
+literal_restriction returns [String text]
+	@init {
+		text = null;
+	}
+	:
+	    t=literal {
+	    	text = t;
+	    }
+	;		
+
+lisp_list[ExecutionBuildContext context, LispList list] returns[ValueHandler valueHandler]
+	:	LEFT_PAREN	
+		(		a=lisp_atom[context]					{ list.add( a ); }
+			|	a=lisp_list[context, list.createList()]	{ list.add( a ); }
+		)*										    	
+	    RIGHT_PAREN
+	    { valueHandler = list.getValueHandler(); }
+	;
+	
+lisp_atom[ExecutionBuildContext context] returns[ValueHandler value] 
+	@init {
+		value  =  null;		
+	}
+	:
+		(		t=VAR		{ value = context.getVariableValueHandler(t.getText() ); }
+			|	t=STRING	{ value = new ObjectValueHandler( getString( t ) ); }
+			| 	t=NAME		{ value = new ObjectValueHandler( t.getText() ); }			
+			|	t=FLOAT		{ value = new DoubleValueHandler( t.getText() ); }
+			|	t=INT 		{ value = new LongValueHandler( t.getText() ); }			
+			|	t=BOOL		{ value = new BooleanValueHandler( t.getText() ); }						
+			|	t=NULL		{ value = ObjectValueHandler.NULL; }
+		)	
+	;
+	
+literal returns [String text]
+	@init {
+		text = null;
+	}
+	:	(   t=STRING { text = getString( t ); } 
+		  | t=NAME     { text = t.getText(); }
+		  | t=INT    { text = t.getText(); }
+		  | t=FLOAT	 { text = t.getText(); }
+		  | t=BOOL 	 { text = t.getText(); }
+		  | t=NULL   { text = null; }
+		)
+	;
+	
+WS      :       (	' '
+                |	'\t'
+                |	'\f'
+                |	EOL
+                )
+                { $channel=HIDDEN; }
+        ;                      
+        
+DEFRULE	:	'defrule';
+OR 	:	'or';
+AND 	:	'and';
+NOT 	:	'not';
+EXISTS 	:	'exists';
+TEST 	:	'test';
+
+NULL	:	'null';
+
+DECLARE :	'declare';        		
+
+SALIENCE:	'salience';
+
+//MODIFY  :	'modify';
+
+fragment
+EOL 	:	     
+   		(       ( '\r\n' )=> '\r\n'  // Evil DOS
+                |       '\r'    // Macintosh
+                |       '\n'    // Unix (the right way)
+                )
+        ;  
+        
+INT	
+	:	('-')?('0'..'9')+
+	;
+
+FLOAT
+	:	('-')?('0'..'9')+ '.' ('0'..'9')+
+	;
+
+STRING
+    :  ('"' ( EscapeSequence | ~('\\'|'"') )* '"')
+     | ('\'' ( EscapeSequence | ~('\\'|'\'') )* '\'')
+    ;
+
+fragment
+HexDigit : ('0'..'9'|'a'..'f'|'A'..'F') ;
+
+fragment
+EscapeSequence
+    :   '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\')
+    |   UnicodeEscape
+    |   OctalEscape
+    ;
+
+fragment
+OctalEscape
+    :   '\\' ('0'..'3') ('0'..'7') ('0'..'7')
+    |   '\\' ('0'..'7') ('0'..'7')
+    |   '\\' ('0'..'7')
+    ;
+
+fragment
+UnicodeEscape
+    :   '\\' 'u' HexDigit HexDigit HexDigit HexDigit
+    ;
+
+BOOL
+	:	('true'|'false') 
+	;
+	
+VAR 	: '?'('a'..'z'|'A'..'Z'|'_'|'$')SYMBOL* 
+        ;
+
+SH_STYLE_SINGLE_LINE_COMMENT	
+	:	'#' ( options{greedy=false;} : .)* EOL /* ('\r')? '\n'  */
+                { $channel=HIDDEN; }
+	;
+        
+        
+C_STYLE_SINGLE_LINE_COMMENT	
+	:	'//' ( options{greedy=false;} : .)* EOL // ('\r')? '\n' 
+                { $channel=HIDDEN; }
+	;
+
+
+LEFT_PAREN
+	:	'('
+	;
+
+RIGHT_PAREN
+	:	')'
+	;
+        
+LEFT_SQUARE
+	:	'['
+	;
+
+RIGHT_SQUARE
+	:	']'
+	;        
+
+LEFT_CURLY
+	:	'{'
+	;
+
+RIGHT_CURLY
+	:	'}'
+	;
+	
+TILDE	:	'~'
+	;	
+	
+AMPERSAND 
+	:	'&'
+	;
+	
+PIPE
+	:	'|'
+	;		
+	
+ASSIGN_OP 
+	:	'<-'	
+	;
+
+COLON	:	':';
+
+EQUALS	:	'=';	
+        
+MULTI_LINE_COMMENT
+	:	'/*' (options{greedy=false;} : .)* '*/'
+                { $channel=HIDDEN; }
+	;
+
+NAME	:	SYMBOL	;
+	
+fragment	
+SYMBOL
+	:	((~(' '|'\t'|'\n'|'\r'|'"'|'('|')'|';'|'&'|'|'|'~'|'?'|'$'))|('$' ~('?'|' '|'\t'|'\n'|'\r'|'"'|'('|')'|';'|'&'|'|'|'~'|'<'))) 
+	         (~(' '|'\t'|'\n'|'\r'|'"'|'('|')'|';'|'&'|'|'|'~'|'<'|'?'))*
+	;
+

Copied: labs/jbossrules/trunk/drools-clips/src/main/resources/org/drools/clp/functions.conf (from rev 10525, labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/clp/functions.conf)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/main/resources/org/drools/clp/functions.conf	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/main/resources/org/drools/clp/functions.conf	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,8 @@
+org.drools.clp.functions.CreateListFunction
+org.drools.clp.functions.AddFunction
+org.drools.clp.functions.IfFunction
+org.drools.clp.functions.WhileFunction
+org.drools.clp.functions.ForeachFunction
+org.drools.clp.functions.LessThanFunction
+org.drools.clp.functions.BindFunction
+org.drools.clp.functions.ModifyFunction
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/AddFunctionTest.java (from rev 10524, labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/clp/AddFunctionTest.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/AddFunctionTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/AddFunctionTest.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,118 @@
+package org.drools.clp;
+
+import java.math.BigDecimal;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.drools.RuleBase;
+import org.drools.RuleBaseFactory;
+import org.drools.base.ClassObjectType;
+import org.drools.clp.functions.AddFunction;
+import org.drools.clp.valuehandlers.CLPLocalDeclarationVariable;
+import org.drools.clp.valuehandlers.CLPPreviousDeclarationVariable;
+import org.drools.clp.valuehandlers.FunctionCaller;
+import org.drools.clp.valuehandlers.LocalVariableValue;
+import org.drools.clp.valuehandlers.ObjectValueHandler;
+import org.drools.clp.valuehandlers.TempTokenVariable;
+import org.drools.common.InternalFactHandle;
+import org.drools.common.InternalWorkingMemory;
+import org.drools.reteoo.ReteTuple;
+import org.drools.rule.Column;
+import org.drools.rule.Declaration;
+import org.drools.spi.ColumnExtractor;
+import org.drools.spi.ObjectType;
+
+import junit.framework.TestCase;
+
+public class AddFunctionTest extends TestCase {
+    public void testAdd() {
+        ValueHandler val1 = new ObjectValueHandler( new BigDecimal( 10 ) );
+        ValueHandler val2 = new ObjectValueHandler( new BigDecimal( 10 ) );
+
+        ValueHandler[] params = new ValueHandler[]{val1, val2};
+        AddFunction add = new AddFunction();
+
+        assertEquals( new BigDecimal( 20 ),
+                      add.execute( params,
+                                   null ).getObject( null ) );
+    }
+
+    public void testNestedAdd() {
+        ValueHandler val1 = new ObjectValueHandler( new BigDecimal( 10 ) );
+        ValueHandler val2 = new ObjectValueHandler( new BigDecimal( 10 ) );
+        ValueHandler val3 = new ObjectValueHandler( new BigDecimal( 10 ) );
+
+        FunctionCaller functionValue = new FunctionCaller( new AddFunction() );
+        functionValue.addParameter( val1 );
+        functionValue.addParameter( val2 );
+
+        ValueHandler[] params = new ValueHandler[]{val3, functionValue};
+
+        AddFunction add = new AddFunction();
+
+        assertEquals( new BigDecimal( 30 ),
+                      add.execute( params,
+                                   null ).getObject( null ) );
+    }
+
+    public void testNestedAddWithVars() {
+        RuleBase ruleBase = RuleBaseFactory.newRuleBase();
+        InternalWorkingMemory workingMemory = (InternalWorkingMemory) ruleBase.newWorkingMemory();
+
+        InternalFactHandle factHandle = (InternalFactHandle) workingMemory.assertObject( new BigDecimal( 10 ) );
+        ReteTuple tuple = new ReteTuple( factHandle );
+
+        ObjectType objectType = new ClassObjectType( BigDecimal.class );
+        Column column0 = new Column( 0,
+                                     objectType );
+        Column column1 = new Column( 1,
+                                     objectType );
+        ColumnExtractor extractor = new ColumnExtractor( objectType );
+
+//        VariableValueHandler pd = new CLPPreviousDeclarationVariable( new Declaration( "pd",
+//                                                                                       extractor,
+//                                                                                       column0 ) );
+//
+//        VariableValueHandler ld = new CLPLocalDeclarationVariable( new Declaration( "ld",
+//                                                                                    extractor,
+//                                                                                    column1 ) );
+
+        Map variables = new HashMap();
+        variables.put( "pd",
+                       new CLPPreviousDeclarationVariable( new Declaration( "pd",
+                                                                            extractor,
+                                                                            column0 ) ) );
+        variables.put( "ld",
+                       new CLPLocalDeclarationVariable( new Declaration( "ld",
+                                                                         extractor,
+                                                                         column1 ) ) );
+
+        ValueHandler val1 = new TempTokenVariable( "pd" );
+        ValueHandler val2 = new LocalVariableValue( "lv",
+                                                    0 );
+        ValueHandler val3 = new TempTokenVariable( "ld" );
+
+        ExecutionContext context = new ExecutionContext( workingMemory,
+                                                         tuple,
+                                                         new BigDecimal( 10 ),
+                                                         1 );
+        context.setLocalVariable( 0,
+                                  new ObjectValueHandler( new BigDecimal( 10 ) ) );
+
+        FunctionCaller functionValue = new FunctionCaller( new AddFunction() );
+        functionValue.addParameter( val1 );
+        functionValue.addParameter( val2 );
+
+        AddFunction add = new AddFunction();
+
+        FunctionCaller f = new FunctionCaller( add );
+        f.addParameter( val3 );
+        f.addParameter( functionValue );
+
+        f.replaceTempTokens( variables );
+
+        assertEquals( new BigDecimal( 30 ),
+                      f.getBigDecimalValue( context ) ); 
+
+    }
+}

Copied: labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/BlockExecutionTest.java (from rev 10524, labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/clp/BlockExecutionTest.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/BlockExecutionTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/BlockExecutionTest.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,60 @@
+package org.drools.clp;
+
+import java.math.BigDecimal;
+
+import junit.framework.TestCase;
+
+import org.drools.Person;
+import org.drools.clp.functions.AddFunction;
+import org.drools.clp.functions.BindFunction;
+import org.drools.clp.functions.ModifyFunction;
+import org.drools.clp.valuehandlers.FunctionCaller;
+import org.drools.clp.valuehandlers.ListValueHandler;
+import org.drools.clp.valuehandlers.LongValueHandler;
+import org.drools.clp.valuehandlers.ObjectValueHandler;
+
+public class BlockExecutionTest extends TestCase {
+    
+    FunctionRegistry registry;
+    
+    public void setUp() {
+        this.registry = new FunctionRegistry( BuiltinFunctions.getInstance() );
+    }    
+    
+    public void testAddWithModify() {
+        BlockExecutionEngine engine = new BlockExecutionEngine();        
+        ExecutionBuildContext build = new ExecutionBuildContext(engine, this.registry );                
+        
+        FunctionCaller addCaller = new FunctionCaller( new AddFunction() );
+        addCaller.addParameter( new ObjectValueHandler( new BigDecimal( 20) ) );
+        addCaller.addParameter( new LongValueHandler( "11" ) );
+                
+        FunctionCaller bindCaller = new FunctionCaller( new BindFunction() );
+        bindCaller.addParameter( build.createLocalVariable( "?x" ) );
+        bindCaller.addParameter( addCaller );
+        
+        engine.addFunction( bindCaller );
+        
+        
+        FunctionCaller modifyCaller = new FunctionCaller( new ModifyFunction() );        
+        build.createLocalVariable( "?p" );        
+        modifyCaller.addParameter( build.getVariableValueHandler( "?p" ) );
+        
+        ListValueHandler list = new ListValueHandler();
+        list.add( new ObjectValueHandler( "age") );
+        list.add( build.getVariableValueHandler( "?x" ) );
+        modifyCaller.addParameter( list );
+        
+        ExecutionContext context = new ExecutionContext(null, null, 2);
+        Person p = new Person("mark");
+        context.setLocalVariable( 1, new ObjectValueHandler( p ) );
+        
+        engine.addFunction( modifyCaller );
+        
+        engine.execute( context );
+        
+        assertEquals( 31, p.getAge() );
+        
+        
+    }
+}

Copied: labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/ClpParserTest.java (from rev 10524, labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/clp/ClpParserTest.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/ClpParserTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/ClpParserTest.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,410 @@
+package org.drools.clp;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.antlr.runtime.ANTLRStringStream;
+import org.antlr.runtime.CharStream;
+import org.antlr.runtime.Lexer;
+import org.antlr.runtime.TokenStream;
+import org.drools.clp.valuehandlers.DoubleValueHandler;
+import org.drools.clp.valuehandlers.FunctionCaller;
+import org.drools.clp.valuehandlers.LongValueHandler;
+import org.drools.compiler.SwitchingCommonTokenStream;
+import org.drools.lang.descr.AndDescr;
+import org.drools.lang.descr.AttributeDescr;
+import org.drools.lang.descr.ColumnDescr;
+import org.drools.lang.descr.EvalDescr;
+import org.drools.lang.descr.ExistsDescr;
+import org.drools.lang.descr.FieldConstraintDescr;
+import org.drools.lang.descr.LiteralRestrictionDescr;
+import org.drools.lang.descr.NotDescr;
+import org.drools.lang.descr.OrDescr;
+import org.drools.lang.descr.PredicateDescr;
+import org.drools.lang.descr.RestrictionConnectiveDescr;
+import org.drools.lang.descr.ReturnValueRestrictionDescr;
+import org.drools.lang.descr.RuleDescr;
+import org.drools.lang.descr.VariableRestrictionDescr;
+
+public class ClpParserTest extends TestCase {
+
+    private CLPParser parser;
+    
+    FunctionRegistry registry;
+    
+    public void setUp() {
+        this.registry = new FunctionRegistry( BuiltinFunctions.getInstance() );
+    }
+    
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        this.parser = null;
+    }
+
+    public void testParseFunction() throws Exception {        
+        ExecutionBuildContext context = new ExecutionBuildContext( new CLPPredicate(), this.registry );
+        FunctionCaller fc = ( FunctionCaller ) parse( "(< 1 2)" ).lisp_list( context, new LispForm(context) );
+        
+        assertEquals( "<", fc.getName() );        
+        assertEquals( new LongValueHandler( 1 ), fc.getParameters()[0] );
+        assertEquals( new LongValueHandler( 2 ), fc.getParameters()[1] );
+    }
+    
+    public void testPatternsRule() throws Exception {
+        RuleDescr rule = parse( "(defrule xxx ?b <- (person (name \"yyy\"&?bf|~\"zzz\"|~=(+ 2 3)&:(< 1 2)) ) ?c <- (hobby (type ?bf2&~iii) (rating fivestar) ) => )" ).defrule();
+
+        assertEquals( "xxx",
+                      rule.getName() );
+
+        AndDescr lhs = rule.getLhs();
+        List lhsList = lhs.getDescrs();
+        assertEquals( 2,
+                      lhsList.size() );
+
+        // Parse the first column
+        ColumnDescr col = (ColumnDescr) lhsList.get( 0 );
+        assertEquals( "?b",
+                      col.getIdentifier() );
+        assertEquals( "person",
+                      col.getObjectType() );
+
+        List colList = col.getDescrs();
+        assertEquals( 2,
+                      colList.size() );
+        FieldConstraintDescr fieldConstraintDescr = (FieldConstraintDescr) colList.get( 0 );
+        List restrictionList = fieldConstraintDescr.getRestrictions();
+
+        assertEquals( "name",
+                      fieldConstraintDescr.getFieldName() );
+        // @todo the 7th one has no constraint, as its a predicate, have to figure out how to handle this
+        assertEquals( 8,
+                      restrictionList.size() );
+
+        LiteralRestrictionDescr litDescr = (LiteralRestrictionDescr) restrictionList.get( 0 );
+        assertEquals( "==",
+                      litDescr.getEvaluator() );
+        assertEquals( "yyy",
+                      litDescr.getText() );
+
+        RestrictionConnectiveDescr connDescr = (RestrictionConnectiveDescr) restrictionList.get( 1 );
+        assertEquals( RestrictionConnectiveDescr.AND,
+                      connDescr.getConnective() );
+
+        VariableRestrictionDescr varDescr = (VariableRestrictionDescr) restrictionList.get( 2 );
+        assertEquals( "==",
+                      varDescr.getEvaluator() );
+        assertEquals( "?bf",
+                      varDescr.getIdentifier() );
+
+        connDescr = (RestrictionConnectiveDescr) restrictionList.get( 3 );
+        assertEquals( RestrictionConnectiveDescr.OR,
+                      connDescr.getConnective() );
+
+        litDescr = (LiteralRestrictionDescr) restrictionList.get( 4 );
+        assertEquals( "!=",
+                      litDescr.getEvaluator() );
+        assertEquals( "zzz",
+                      litDescr.getText() );
+
+        connDescr = (RestrictionConnectiveDescr) restrictionList.get( 5 );
+        assertEquals( RestrictionConnectiveDescr.OR,
+                      connDescr.getConnective() );
+
+        ReturnValueRestrictionDescr retDescr = (ReturnValueRestrictionDescr) restrictionList.get( 6 );
+        assertEquals( "!=",
+                      retDescr.getEvaluator() );
+        CLPReturnValue clprv = ( CLPReturnValue ) retDescr.getContent();
+        FunctionCaller fc = clprv.getFunctions()[0];
+        assertEquals( "+", fc.getName() );        
+        assertEquals( new LongValueHandler( 2 ), fc.getParameters()[0] );
+        assertEquals( new LongValueHandler( 3 ), fc.getParameters()[1] );       
+
+        PredicateDescr predicateDescr = (PredicateDescr) colList.get( 1 );        
+        CLPPredicate clpp = ( CLPPredicate ) predicateDescr.getContent();
+        fc = clpp.getFunctions()[0];
+        assertEquals( "<", fc.getName() );        
+        assertEquals( new LongValueHandler( 1 ), fc.getParameters()[0] );
+        assertEquals( new LongValueHandler( 2 ), fc.getParameters()[1] );        
+
+        // Parse the second column
+        col = (ColumnDescr) lhsList.get( 1 );
+        assertEquals( "?c",
+                      col.getIdentifier() );
+        assertEquals( "hobby",
+                      col.getObjectType() );
+
+        colList = col.getDescrs();
+        assertEquals( 2,
+                      colList.size() );
+        fieldConstraintDescr = (FieldConstraintDescr) colList.get( 0 );
+        restrictionList = fieldConstraintDescr.getRestrictions();
+
+        assertEquals( "type",
+                      fieldConstraintDescr.getFieldName() );
+
+        varDescr = (VariableRestrictionDescr) restrictionList.get( 0 );
+        assertEquals( "==",
+                      varDescr.getEvaluator() );
+        assertEquals( "?bf2",
+                      varDescr.getIdentifier() );
+
+        connDescr = (RestrictionConnectiveDescr) restrictionList.get( 1 );
+        assertEquals( RestrictionConnectiveDescr.AND,
+                      connDescr.getConnective() );
+
+        litDescr = (LiteralRestrictionDescr) restrictionList.get( 2 );
+        assertEquals( "!=",
+                      litDescr.getEvaluator() );
+        assertEquals( "iii",
+                      litDescr.getText() );
+
+        fieldConstraintDescr = (FieldConstraintDescr) colList.get( 1 );
+        restrictionList = fieldConstraintDescr.getRestrictions();
+
+        assertEquals( "rating",
+                      fieldConstraintDescr.getFieldName() );
+
+        litDescr = (LiteralRestrictionDescr) restrictionList.get( 0 );
+        assertEquals( "==",
+                      litDescr.getEvaluator() );
+        assertEquals( "fivestar",
+                      litDescr.getText() );
+    }
+
+    public void testNestedCERule() throws Exception {
+        RuleDescr rule = parse( "(defrule xxx ?b <- (person (name yyy)) (or (and (hobby1 (type qqq1)) (hobby2 (type ~qqq2))) (food (veg ~shroom) ) ) => )" ).defrule();
+
+        assertEquals( "xxx",
+                      rule.getName() );
+
+        AndDescr lhs = rule.getLhs();
+        List lhsList = lhs.getDescrs();
+        assertEquals( 2,
+                      lhsList.size() );
+
+        // Parse the first column
+        ColumnDescr col = (ColumnDescr) lhsList.get( 0 );
+        assertEquals( "?b",
+                      col.getIdentifier() );
+        assertEquals( "person",
+                      col.getObjectType() );
+        FieldConstraintDescr fieldConstraintDescr = (FieldConstraintDescr) col.getDescrs().get( 0 );
+        assertEquals( "name",
+                      fieldConstraintDescr.getFieldName() ); //         
+        LiteralRestrictionDescr litDescr = (LiteralRestrictionDescr) fieldConstraintDescr.getRestrictions().get( 0 );
+        assertEquals( "==",
+                      litDescr.getEvaluator() );
+        assertEquals( "yyy",
+                      litDescr.getText() );
+
+        OrDescr orDescr = (OrDescr) lhsList.get( 1 );
+        assertEquals( 2,
+                      orDescr.getDescrs().size() );
+
+        AndDescr andDescr = (AndDescr) orDescr.getDescrs().get( 0 );
+        col = (ColumnDescr) andDescr.getDescrs().get( 0 );
+        assertEquals( "hobby1",
+                      col.getObjectType() );
+        fieldConstraintDescr = (FieldConstraintDescr) col.getDescrs().get( 0 );
+        assertEquals( "type",
+                      fieldConstraintDescr.getFieldName() ); //         
+        litDescr = (LiteralRestrictionDescr) fieldConstraintDescr.getRestrictions().get( 0 );
+        assertEquals( "==",
+                      litDescr.getEvaluator() );
+        assertEquals( "qqq1",
+                      litDescr.getText() );
+
+        col = (ColumnDescr) andDescr.getDescrs().get( 1 );
+        assertEquals( "hobby2",
+                      col.getObjectType() );
+        fieldConstraintDescr = (FieldConstraintDescr) col.getDescrs().get( 0 );
+        assertEquals( "type",
+                      fieldConstraintDescr.getFieldName() ); //         
+        litDescr = (LiteralRestrictionDescr) fieldConstraintDescr.getRestrictions().get( 0 );
+        assertEquals( "!=",
+                      litDescr.getEvaluator() );
+        assertEquals( "qqq2",
+                      litDescr.getText() );
+
+        col = (ColumnDescr) orDescr.getDescrs().get( 1 );
+        assertEquals( "food",
+                      col.getObjectType() );
+        fieldConstraintDescr = (FieldConstraintDescr) col.getDescrs().get( 0 );
+        assertEquals( "veg",
+                      fieldConstraintDescr.getFieldName() ); //         
+        litDescr = (LiteralRestrictionDescr) fieldConstraintDescr.getRestrictions().get( 0 );
+        assertEquals( "!=",
+                      litDescr.getEvaluator() );
+        assertEquals( "shroom",
+                      litDescr.getText() );
+    }
+
+    public void testNotExistsRule() throws Exception {
+        RuleDescr rule = parse( "(defrule xxx (or (hobby1 (type qqq1)) (not (and (exists (person (name ppp))) (person (name yyy))))) => )" ).defrule();
+
+        assertEquals( "xxx",
+                      rule.getName() );
+
+        AndDescr lhs = rule.getLhs();
+        List lhsList = lhs.getDescrs();
+        assertEquals( 1,
+                      lhsList.size() );
+
+        OrDescr orDescr = (OrDescr) lhsList.get( 0 );
+        assertEquals( 2,
+                      orDescr.getDescrs().size() );
+
+        ColumnDescr col = (ColumnDescr) orDescr.getDescrs().get( 0 );
+        assertEquals( "hobby1",
+                      col.getObjectType() );
+        FieldConstraintDescr fieldConstraintDescr = (FieldConstraintDescr) col.getDescrs().get( 0 );
+        assertEquals( "type",
+                      fieldConstraintDescr.getFieldName() ); //         
+        LiteralRestrictionDescr litDescr = (LiteralRestrictionDescr) fieldConstraintDescr.getRestrictions().get( 0 );
+        assertEquals( "==",
+                      litDescr.getEvaluator() );
+        assertEquals( "qqq1",
+                      litDescr.getText() );
+
+        NotDescr notDescr = (NotDescr) orDescr.getDescrs().get( 1 );
+        assertEquals( 1,
+                      notDescr.getDescrs().size() );
+        
+        AndDescr andDescr = (AndDescr) notDescr.getDescrs().get( 0 );
+        assertEquals( 2, andDescr.getDescrs().size() );
+        ExistsDescr existsDescr = (ExistsDescr) andDescr.getDescrs().get( 0 );
+        col = (ColumnDescr) existsDescr.getDescrs().get( 0 );
+        assertEquals( "person",
+                      col.getObjectType() );
+        fieldConstraintDescr = (FieldConstraintDescr) col.getDescrs().get( 0 );
+        assertEquals( "name",
+                      fieldConstraintDescr.getFieldName() ); //         
+        litDescr = (LiteralRestrictionDescr) fieldConstraintDescr.getRestrictions().get( 0 );
+        assertEquals( "==",
+                      litDescr.getEvaluator() );
+        assertEquals( "ppp",
+                      litDescr.getText() );              
+        
+        col = (ColumnDescr) andDescr.getDescrs().get( 1 );
+        assertEquals( "person",
+                      col.getObjectType() );
+        fieldConstraintDescr = (FieldConstraintDescr) col.getDescrs().get( 0 );
+        assertEquals( "name",
+                      fieldConstraintDescr.getFieldName() ); //         
+        litDescr = (LiteralRestrictionDescr) fieldConstraintDescr.getRestrictions().get( 0 );
+        assertEquals( "==",
+                      litDescr.getEvaluator() );
+        assertEquals( "yyy",
+                      litDescr.getText() );  
+    }
+    
+    public void testTestRule() throws Exception {
+        RuleDescr rule = parse( "(defrule xxx (test (< 9.0 1.3) ) => )" ).defrule();
+
+        assertEquals( "xxx",
+                      rule.getName() );
+
+        AndDescr lhs = rule.getLhs();
+        List lhsList = lhs.getDescrs();
+        assertEquals( 1,
+                      lhsList.size() );
+
+        EvalDescr evalDescr = (EvalDescr) lhsList.get( 0 );
+        
+        CLPEval clpe = ( CLPEval ) evalDescr.getContent();
+        FunctionCaller f = clpe.getFunctions()[0];
+        assertEquals( "<", f.getName() );        
+        assertEquals( new DoubleValueHandler( 9.0 ), f.getParameters()[0] );
+        assertEquals( new DoubleValueHandler( 1.3 ), f.getParameters()[1] );          
+    }
+
+    public void testRuleHeader() throws Exception {
+        RuleDescr rule = parse( "(defrule MAIN::name \"docs\"(declare (salience -100) ) => )" ).defrule();
+        
+        List attributes = rule.getAttributes();
+        AttributeDescr module = ( AttributeDescr ) attributes.get( 0 );
+        assertEquals( "agenda-group", module.getName() );
+        assertEquals( "MAIN", module.getValue() );
+        
+        assertEquals("name", rule.getName() );
+        
+        AttributeDescr salience = ( AttributeDescr ) attributes.get( 1 );
+        assertEquals( "salience", salience.getName() );
+        assertEquals( "-100", salience.getValue() );
+        
+        
+    }
+    
+    private CLPParser parse(final String text) throws Exception {
+        this.parser = newParser( newTokenStream( newLexer( newCharStream( text ) ) ) );
+        return this.parser;
+    }
+
+    private CLPParser parse(final String source,
+                            final String text) throws Exception {
+        this.parser = newParser( newTokenStream( newLexer( newCharStream( text ) ) ) );
+        this.parser.setSource( source );
+        return this.parser;
+    }
+
+    private Reader getReader(final String name) throws Exception {
+        final InputStream in = getClass().getResourceAsStream( name );
+
+        return new InputStreamReader( in );
+    }
+
+    private CLPParser parseResource(final String name) throws Exception {
+
+        //        System.err.println( getClass().getResource( name ) );
+        Reader reader = getReader( name );
+
+        final StringBuffer text = new StringBuffer();
+
+        final char[] buf = new char[1024];
+        int len = 0;
+
+        while ( (len = reader.read( buf )) >= 0 ) {
+            text.append( buf,
+                         0,
+                         len );
+        }
+
+        return parse( name,
+                      text.toString() );
+    }
+
+    private CharStream newCharStream(final String text) {
+        return new ANTLRStringStream( text );
+    }
+
+    private CLPLexer newLexer(final CharStream charStream) {
+        return new CLPLexer( charStream );
+    }
+
+    private TokenStream newTokenStream(final Lexer lexer) {
+        return new SwitchingCommonTokenStream( lexer );
+    }
+
+    private CLPParser newParser(final TokenStream tokenStream) {
+        final CLPParser p = new CLPParser( tokenStream );
+        p.setFunctionRegistry( new FunctionRegistry( BuiltinFunctions.getInstance() )  );
+        //p.setParserDebug( true );
+        return p;
+    }
+
+    private void assertEqualsIgnoreWhitespace(final String expected,
+                                              final String actual) {
+        final String cleanExpected = expected.replaceAll( "\\s+",
+                                                          "" );
+        final String cleanActual = actual.replaceAll( "\\s+",
+                                                      "" );
+
+        assertEquals( cleanExpected,
+                      cleanActual );
+    }
+
+}

Copied: labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/CompiledParserTest.java (from rev 10525, labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/clp/CompiledParserTest.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/CompiledParserTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/CompiledParserTest.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,254 @@
+package org.drools.clp;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.math.BigDecimal;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.antlr.runtime.ANTLRStringStream;
+import org.antlr.runtime.CharStream;
+import org.antlr.runtime.Lexer;
+import org.antlr.runtime.TokenStream;
+import org.drools.Person;
+import org.drools.clp.valuehandlers.ListValueHandler;
+import org.drools.clp.valuehandlers.LocalVariableValue;
+import org.drools.clp.valuehandlers.LongValueHandler;
+import org.drools.clp.valuehandlers.ObjectValueHandler;
+import org.drools.compiler.SwitchingCommonTokenStream;
+
+import junit.framework.TestCase;
+
+public class CompiledParserTest extends TestCase {
+    private CLPParser parser;
+
+    public void testBindAndModify() throws Exception {
+        BlockExecutionEngine engine = (BlockExecutionEngine) parse( "(bind ?x (+ 20 11) ) (modify ?p (age ?x) )" ).rhs();
+        ExecutionContext context = new ExecutionContext( null,
+                                                         null,
+                                                         2 );
+
+        Map vars = new HashMap();
+        Person p = new Person( "mark" );
+        vars.put( "?p",
+                  new ObjectValueHandler( p ) );
+        engine.replaceTempTokens( vars );
+
+        engine.execute( context );
+
+        assertEquals( 31,
+                      p.getAge() );
+    }
+
+    public void testSimpleCreate$() throws Exception {
+        BlockExecutionEngine engine = (BlockExecutionEngine) parse( "(bind ?x (create$ 1 2 3) )" ).rhs();
+        ExecutionContext context = new ExecutionContext( null,
+                                                         null,
+                                                         1 );
+        engine.execute( context );
+
+        ListValueHandler list = (ListValueHandler) context.getLocalVariable( 0 );
+
+        assertEquals( 3,
+                      list.size() );
+
+        assertEquals( 1,
+                      list.getList()[0].getIntValue( context ) );
+        assertEquals( 2,
+                      list.getList()[1].getIntValue( context ) );
+        assertEquals( 3,
+                      list.getList()[2].getIntValue( context ) );
+    }
+
+    public void testNestedCreate$() throws Exception {
+        BlockExecutionEngine engine = (BlockExecutionEngine) parse( "(bind ?x (create$ 1 2 (+ 1 2) ) ) (bind ?y (create$ (+ 1 0) ?x (create$ a b ?x (+ 1 1) ) 3) )" ).rhs();
+        ExecutionContext context = new ExecutionContext( null,
+                                                         null,
+                                                         2 );
+        engine.execute( context );
+
+        // check ?x
+        ListValueHandler list = (ListValueHandler) context.getLocalVariable( 0 );
+        assertEquals( 3,
+                      list.size() );
+        assertEquals( 1,
+                      list.getList()[0].getIntValue( context ) );
+        assertEquals( 2,
+                      list.getList()[1].getIntValue( context ) );
+        assertEquals( new BigDecimal( 3 ),
+                      list.getList()[2].getBigDecimalValue( context ) );
+
+        // check ?y
+        list = (ListValueHandler) context.getLocalVariable( 1 );
+        assertEquals( 11,
+                      list.size() );
+
+        assertEquals( new BigDecimal( 1 ),
+                      list.getList()[0].getBigDecimalValue( context ) );
+        assertEquals( 1,
+                      list.getList()[1].getIntValue( context ) );
+        assertEquals( 2,
+                      list.getList()[2].getIntValue( context ) );
+        assertEquals( new BigDecimal( 3 ),
+                      list.getList()[3].getBigDecimalValue( context ) );
+        assertEquals( "a",
+                      list.getList()[4].getStringValue( context ) );
+        assertEquals( "b",
+                      list.getList()[5].getStringValue( context ) );
+        assertEquals( 1,
+                      list.getList()[6].getIntValue( context ) );
+        assertEquals( 2,
+                      list.getList()[7].getIntValue( context ) );
+        assertEquals( new BigDecimal( 3 ),
+                      list.getList()[8].getBigDecimalValue( context ) );
+        assertEquals( new BigDecimal( 2 ),
+                      list.getList()[9].getBigDecimalValue( context ) );
+        assertEquals( 3,
+                      list.getList()[10].getIntValue( context ) );
+    }
+
+    public void testIf() throws Exception {
+        BlockExecutionEngine engine = (BlockExecutionEngine) parse( "(if (< ?x ?y ) then (modify ?p (age 15) ) else (modify ?p (age 5)))" ).rhs();
+        ExecutionContext context = new ExecutionContext( null,
+                                                         null,
+                                                         2 );
+
+        Person p = new Person( "mark" );
+        Map vars = new HashMap();
+
+        vars.put( "?x",
+                  new LongValueHandler( 10 ) );
+        vars.put( "?y",
+                  new LocalVariableValue( "?y",
+                                          0 ) );
+        vars.put( "?p",
+                  new ObjectValueHandler( p ) );
+        engine.replaceTempTokens( vars );
+
+        context.setLocalVariable( 0,
+                                  new LongValueHandler( 20 ) );
+
+        engine.execute( context );
+        assertEquals( 15,
+                      p.getAge() );
+
+        context.setLocalVariable( 0,
+                                  new LongValueHandler( 7 ) );
+        engine.execute( context );
+        assertEquals( 5,
+                      p.getAge() );
+    }
+
+    public void testWhile() throws Exception {
+        BlockExecutionEngine engine = (BlockExecutionEngine) parse( "(while (< ?x ?y) do (bind ?x (+ ?x 1) ) )" ).rhs();
+        ExecutionContext context = new ExecutionContext( null,
+                                                         null,
+                                                         2 );
+
+        Map vars = new HashMap();
+
+        vars.put( "?x",
+                  new LocalVariableValue( "?x",
+                                          0 ) );
+        vars.put( "?y",
+                  new LocalVariableValue( "?y",
+                                          1 ) );
+        engine.replaceTempTokens( vars );
+
+        context.setLocalVariable( 0,
+                                  new LongValueHandler( 0 ) );
+        context.setLocalVariable( 1,
+                                  new LongValueHandler( 10 ) );
+
+        engine.execute( context );
+        assertEquals( new BigDecimal( 10 ),
+                      context.getLocalVariable( 0 ).getBigDecimalValue( context ) );
+    }
+
+    public void testForeach() throws Exception {
+        BlockExecutionEngine engine = (BlockExecutionEngine) parse( "(bind ?x 0) (foreach ?e (create$ 1 2 3) (bind ?x (+ ?x ?e) ) )" ).rhs();
+        ExecutionContext context = new ExecutionContext( null,
+                                                         null,
+                                                         2 );
+
+        Map vars = new HashMap();
+
+        vars.put( "?x",
+                  new LocalVariableValue( "?x",
+                                          0 ) );
+        engine.replaceTempTokens( vars );
+
+        context.setLocalVariable( 0,
+                                  new LongValueHandler( 0 ) );
+        engine.execute( context );
+        assertEquals( new BigDecimal( 6 ),
+                      context.getLocalVariable( 0 ).getBigDecimalValue( context ) );
+    }
+
+    private CLPParser parse(final String text) throws Exception {
+        this.parser = newParser( newTokenStream( newLexer( newCharStream( text ) ) ) );
+        return this.parser;
+    }
+
+    private CLPParser parse(final String source,
+                            final String text) throws Exception {
+        this.parser = newParser( newTokenStream( newLexer( newCharStream( text ) ) ) );
+        this.parser.setSource( source );
+        return this.parser;
+    }
+
+    private Reader getReader(final String name) throws Exception {
+        final InputStream in = getClass().getResourceAsStream( name );
+
+        return new InputStreamReader( in );
+    }
+
+    private CLPParser parseResource(final String name) throws Exception {
+        Reader reader = getReader( name );
+
+        final StringBuffer text = new StringBuffer();
+
+        final char[] buf = new char[1024];
+        int len = 0;
+
+        while ( (len = reader.read( buf )) >= 0 ) {
+            text.append( buf,
+                         0,
+                         len );
+        }
+
+        return parse( name,
+                      text.toString() );
+    }
+
+    private CharStream newCharStream(final String text) {
+        return new ANTLRStringStream( text );
+    }
+
+    private CLPLexer newLexer(final CharStream charStream) {
+        return new CLPLexer( charStream );
+    }
+
+    private TokenStream newTokenStream(final Lexer lexer) {
+        return new SwitchingCommonTokenStream( lexer );
+    }
+
+    private CLPParser newParser(final TokenStream tokenStream) {
+        final CLPParser p = new CLPParser( tokenStream );
+        p.setFunctionRegistry( new FunctionRegistry( BuiltinFunctions.getInstance() ) );
+        //p.setParserDebug( true );
+        return p;
+    }
+
+    private void assertEqualsIgnoreWhitespace(final String expected,
+                                              final String actual) {
+        final String cleanExpected = expected.replaceAll( "\\s+",
+                                                          "" );
+        final String cleanActual = actual.replaceAll( "\\s+",
+                                                      "" );
+
+        assertEquals( cleanExpected,
+                      cleanActual );
+    }
+}

Copied: labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/DeffunctionTest.java (from rev 10524, labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/clp/DeffunctionTest.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/DeffunctionTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/DeffunctionTest.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,40 @@
+package org.drools.clp;
+
+import java.math.BigDecimal;
+
+import org.drools.clp.functions.AddFunction;
+import org.drools.clp.valuehandlers.FunctionCaller;
+import org.drools.clp.valuehandlers.LocalVariableValue;
+import org.drools.clp.valuehandlers.LongValueHandler;
+
+import junit.framework.TestCase;
+
+public class DeffunctionTest extends TestCase {
+    public void test1() {
+        Deffunction function = new Deffunction("x");
+        
+        ValueHandler a = new LocalVariableValue("a", 0); 
+        function.addParameter( a );
+        
+        ValueHandler b = new LocalVariableValue("b", 1);
+        function.addParameter( b );
+        
+        Function add = new AddFunction();
+        FunctionCaller caller = new FunctionCaller(add);
+        caller.addParameter( a );
+        caller.addParameter( b );
+                
+        function.addFunction( caller );
+                
+        ExecutionContext context = new ExecutionContext(null, null, 2);
+        ValueHandler q = new LocalVariableValue("q", 0);
+        q.setValue( context, new LongValueHandler( 10 ) );
+        
+        ValueHandler w = new LocalVariableValue("w", 1);
+        w.setValue( context,  new LongValueHandler( 7 ) );
+        
+        assertEquals( new BigDecimal( 17 ), function.execute( new ValueHandler[] { q, w }, context ).getBigDecimalValue( context ) );
+    }
+    
+    
+}

Copied: labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/FunctionFactoryTest.java (from rev 10516, labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/clp/FunctionFactoryTest.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/FunctionFactoryTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/FunctionFactoryTest.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,14 @@
+package org.drools.clp;
+
+import junit.framework.TestCase;
+
+public class FunctionFactoryTest extends TestCase {
+    public void testInit() {
+        FunctionRegistry factory = new FunctionRegistry( BuiltinFunctions.getInstance() );
+        
+        // make sure some core functions are there
+        assertSame( "+", factory.getFunction( "+" ).getName() );
+        assertSame( "bind" , factory.getFunction( "bind" ).getName() );
+        assertSame( "modify" , factory.getFunction( "modify" ).getName() );
+    }
+}

Copied: labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/ModifyFunctionTest.java (from rev 10524, labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/clp/ModifyFunctionTest.java)
===================================================================
--- labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/ModifyFunctionTest.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-clips/src/test/java/org/drools/clp/ModifyFunctionTest.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -0,0 +1,31 @@
+package org.drools.clp;
+
+import org.drools.Person;
+import org.drools.clp.functions.ModifyFunction;
+import org.drools.clp.valuehandlers.ListValueHandler;
+import org.drools.clp.valuehandlers.LocalVariableValue;
+import org.drools.clp.valuehandlers.ObjectValueHandler;
+
+import junit.framework.TestCase;
+
+public class ModifyFunctionTest extends TestCase {
+    public void test1() {
+        Function function = new ModifyFunction();
+        
+       Person p = new Person("mark");
+       ExecutionContext context = new ExecutionContext(null, null, 1);
+       //context.setLocalVariable( 0, p );
+       
+       LocalVariableValue var = new LocalVariableValue("p", 0);
+       var.setValue( context, new ObjectValueHandler( p ) );
+       
+       ListValueHandler list = new ListValueHandler();
+       list.add( new ObjectValueHandler( "name") );
+       list.add( new ObjectValueHandler( "bob") );
+       
+       
+       function.execute( new ValueHandler[] { var, list }, context );
+       
+       assertEquals( "bob", p.getName() );
+    }
+}

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ValueType.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ValueType.java	2007-03-26 21:28:53 UTC (rev 10541)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/base/ValueType.java	2007-03-26 22:20:56 UTC (rev 10542)
@@ -33,91 +33,118 @@
 
     public static final ValueType  NULL_TYPE         = new ValueType( "null",
                                                                       null,
+                                                                      SimpleValueType.NULL,
                                                                       null );
     // wrapper types
     public static final ValueType  CHAR_TYPE         = new ValueType( "Character",
                                                                       Character.class,
+                                                                      SimpleValueType.CHAR,
                                                                       CharacterFactory.getInstance() );
     public static final ValueType  BYTE_TYPE         = new ValueType( "Byte",
                                                                       Byte.class,
+                                                                      SimpleValueType.INTEGER,
                                                                       ByteFactory.getInstance() );
     public static final ValueType  SHORT_TYPE        = new ValueType( "Short",
                                                                       Short.class,
+                                                                      SimpleValueType.INTEGER,
                                                                       ShortFactory.getInstance() );
     public static final ValueType  INTEGER_TYPE      = new ValueType( "Integer",
                                                                       Integer.class,
+                                                                      SimpleValueType.INTEGER,
                                                                       IntegerFactory.getInstance() );
     public static final ValueType  LONG_TYPE         = new ValueType( "Long",
                                                                       Long.class,
+                                                                      SimpleValueType.INTEGER,
                                                                       LongFactory.getInstance() );
     public static final ValueType  FLOAT_TYPE        = new ValueType( "Float",
                                                                       Float.class,
+                                                                      SimpleValueType.DECIMAL,
                                                                       FloatFactory.getInstance() );
     public static final ValueType  DOUBLE_TYPE       = new ValueType( "Double",
                                                                       Double.class,
+                                                                      SimpleValueType.DECIMAL,
                                                                       DoubleFactory.getInstance() );
     public static final ValueType  BOOLEAN_TYPE      = new ValueType( "Boolean",
                                                                       Boolean.class,
+                                                                      SimpleValueType.BOOLEAN,
                                                                       BooleanFactory.getInstance() );
     // primitive types
     public static final ValueType  PCHAR_TYPE        = new ValueType( "char",
                                                                       Character.TYPE,
+                                                                      SimpleValueType.CHAR,
                                                                       CharacterFactory.getInstance() );
     public static final ValueType  PBYTE_TYPE        = new ValueType( "byte",
                                                                       Byte.TYPE,
+                                                                      SimpleValueType.INTEGER,
                                                                       ByteFactory.getInstance() );
     public static final ValueType  PSHORT_TYPE       = new ValueType( "short",
                                                                       Short.TYPE,
+                                                                      SimpleValueType.INTEGER,
                                                                       ShortFactory.getInstance() );
     public static final ValueType  PINTEGER_TYPE     = new ValueType( "int",
                                                                       Integer.TYPE,
+                                                                      SimpleValueType.INTEGER,
                                                                       IntegerFactory.getInstance() );
     public static final ValueType  PLONG_TYPE        = new ValueType( "long",
                                                                       Long.TYPE,
+                                                                      SimpleValueType.INTEGER,
                                                                       LongFactory.getInstance() );
     public static final ValueType  PFLOAT_TYPE       = new ValueType( "float",
                                                                       Float.TYPE,
+                                                                      SimpleValueType.DECIMAL,
                                                                       FloatFactory.getInstance() );
     public static final ValueType  PDOUBLE_TYPE      = new ValueType( "double",
                                                                       Double.TYPE,
+                                                                      SimpleValueType.DECIMAL,
                                                                       DoubleFactory.getInstance() );
     public static final ValueType  PBOOLEAN_TYPE     = new ValueType( "boolean",
                                                                       Boolean.TYPE,
+                                                                      SimpleValueType.BOOLEAN,
                                                                       BooleanFactory.getInstance() );
     // other types
     public static final ValueType  DATE_TYPE         = new ValueType( "Date",
                                                                       Date.class,
+                                                                      SimpleValueType.DATE,
                                                                       DateFactory.getInstance() );
     public static final ValueType  ARRAY_TYPE        = new ValueType( "Array",
                                                                       Object[].class,
+                                                                      SimpleValueType.LIST,
                                                                       ArrayFactory.getInstance() );
     public static final ValueType  STRING_TYPE       = new ValueType( "String",
                                                                       String.class,
+                                                                      SimpleValueType.STRING,
                                                                       StringFactory.getInstance() );
     public static final ValueType  OBJECT_TYPE       = new ValueType( "Object",
                                                                       Object.class,
+                                                                      SimpleValueType.OBJECT,
                                                                       ObjectFactory.getInstance() );
     public static final ValueType  FACTTEMPLATE_TYPE = new ValueType( "FactTemplate",
                                                                       FactTemplate.class,
+                                                                      SimpleValueType.UNKNOWN,
                                                                       ObjectFactory.getInstance() );
     public static final ValueType  BIG_DECIMAL_TYPE  = new ValueType( "BigDecimal",
                                                                       BigDecimal.class,
+                                                                      SimpleValueType.OBJECT,
                                                                       BigDecimalFactory.getInstance() );
     public static final ValueType  BIG_INTEGER_TYPE  = new ValueType( "BigInteger",
                                                                       BigInteger.class,
+                                                                      SimpleValueType.OBJECT,
                                                                       BigIntegerFactory.getInstance() );
 
     private final String           name;
     private final Class            classType;
     private final EvaluatorFactory evaluatorFactory;
+    private final int              simpleType;
 
     private ValueType(final String name,
                       final Class classType,
+                      final int simpleType,
                       final EvaluatorFactory evaluatorFactory) {
         this.name = name;
         this.classType = classType;
+        this.simpleType = simpleType;
         this.evaluatorFactory = evaluatorFactory;
-    }
+    }    
 
     private Object readResolve() throws java.io.ObjectStreamException {
         return determineValueType( this.classType );
@@ -125,11 +152,15 @@
 
     public String getName() {
         return this.name;
-    }
+    }        
 
     public Class getClassType() {
         return this.classType;
     }
+    
+    public int getSimpleType() {
+        return this.simpleType;
+    }
 
     public Evaluator getEvaluator(final Operator operator) {
         return this.evaluatorFactory.getEvaluator( operator );
@@ -212,39 +243,43 @@
     }
 
     public boolean isNumber() {
-        return (this.classType == Integer.TYPE) || 
-               (this.classType == Long.TYPE) || 
-               (this.classType == Float.TYPE) || 
-               (this.classType == Double.TYPE) ||
-               (this.classType == Byte.TYPE) || 
-               (this.classType == Short.TYPE) || 
-               (this.classType == Character.TYPE) ||
-               (this.classType == Character.class) || 
-               (Number.class.isAssignableFrom( this.classType ));
+        return ( this.simpleType == SimpleValueType.INTEGER || this.simpleType == SimpleValueType.DECIMAL || this.simpleType == SimpleValueType.CHAR );
+//        return (this.classType == Integer.TYPE) || 
+//               (this.classType == Long.TYPE) || 
+//               (this.classType == Float.TYPE) || 
+//               (this.classType == Double.TYPE) ||
+//               (this.classType == Byte.TYPE) || 
+//               (this.classType == Short.TYPE) || 
+//               (this.classType == Character.TYPE) ||
+//               (this.classType == Character.class) || 
+//               (Number.class.isAssignableFrom( this.classType ));
     }
 
     public boolean isIntegerNumber() {
-        return (this.classType == Integer.TYPE) || 
-               (this.classType == Long.TYPE) || 
-               (this.classType == Integer.class) || 
-               (this.classType == Long.class) || 
-               (this.classType == Character.class) || 
-               (this.classType == Character.TYPE) ||
-               (this.classType == Byte.TYPE) ||
-               (this.classType == Short.TYPE) || 
-               (this.classType == Byte.class) || 
-               (this.classType == Short.class);
+        return this.simpleType == SimpleValueType.INTEGER;
+//        return (this.classType == Integer.TYPE) || 
+//               (this.classType == Long.TYPE) || 
+//               (this.classType == Integer.class) || 
+//               (this.classType == Long.class) || 
+//               (this.classType == Character.class) || 
+//               (this.classType == Character.TYPE) ||
+//               (this.classType == Byte.TYPE) ||
+//               (this.classType == Short.TYPE) || 
+//               (this.classType == Byte.class) || 
+//               (this.classType == Short.class);
     }
 
     public boolean isFloatNumber() {
-        return (this.classType == Float.TYPE) || 
-               (this.classType == Double.TYPE) || 
-               (this.classType == Float.class) || 
-               (this.classType == Double.class);
+        return this.simpleType == SimpleValueType.DECIMAL;
+//        return (this.classType == Float.TYPE) || 
+//               (this.classType == Double.TYPE) || 
+//               (this.classType == Float.class) || 
+//               (this.classType == Double.class);
     }
 
     public boolean isChar() {
-        return ((this.classType == Character.class) || (this.classType == Character.TYPE));
+        return this.simpleType == SimpleValueType.CHAR;
+//        return ((this.classType == Character.class) || (this.classType == Character.TYPE));
     }
 
 }




More information about the jboss-svn-commits mailing list