[jboss-svn-commits] JBL Code SVN: r36697 - in labs/jbossrules/tags/5.2.0.M1: drools-clips and 21 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Feb 24 10:26:37 EST 2011


Author: ge0ffrey
Date: 2011-02-24 10:26:37 -0500 (Thu, 24 Feb 2011)
New Revision: 36697

Added:
   labs/jbossrules/tags/5.2.0.M1/drools-clips/
   labs/jbossrules/tags/5.2.0.M1/drools-clips/.gitignore
   labs/jbossrules/tags/5.2.0.M1/drools-clips/build.properties
   labs/jbossrules/tags/5.2.0.M1/drools-clips/pom.xml
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/Appendable.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/BoolLispAtom.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/ClipsLexer.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/ClipsParser.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/ClipsShell.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/FloatLispAtom.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/Function.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/FunctionContext.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/FunctionHandlers.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/GeneralParseException.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/IntLispAtom.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/LispAtom.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/LispForm.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/NullLispAtom.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/ParserHandler.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/PrintRouterContext.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/SExpression.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/StringBuilderAppendable.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/StringLispAtom.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/SymbolLispAtom.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/VariableContext.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/VariableLispAtom.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/AssertFunction.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/BaseInfixFunction.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/BindFunction.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/CallFunction.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/CreateListFunction.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/EqFunction.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/GetFunction.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/IfFunction.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/LessThanFunction.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/LessThanOrEqFunction.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/MinusFunction.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/ModifyFunction.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/MoreThanFunction.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/MoreThanOrEqFunction.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/MultiplyFunction.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/NewFunction.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/PlusFunction.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/PrintoutFunction.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/PrognFunction.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/RetractFunction.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/ReturnFunction.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/RunFunction.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/SetFunction.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/SwitchFunction.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/rule/
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/rule/builder/
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/rule/builder/dialect/
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/rule/builder/dialect/clips/
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/rule/builder/dialect/clips/ClipsConsequenceBuilder.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/rule/builder/dialect/clips/ClipsDialect.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/rule/builder/dialect/clips/ClipsDialectConfiguration.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/rule/builder/dialect/clips/ClipsEvalBuilder.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/rule/builder/dialect/clips/ClipsPredicateBuilder.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/rule/builder/dialect/clips/ClipsReturnValueBuilder.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/resources/
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/resources/META-INF/
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/resources/META-INF/drools.default.packagebuilder.conf
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/resources/org/
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/resources/org/drools/
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/resources/org/drools/clips/
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/resources/org/drools/clips/Clips.g
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/resources/org/drools/clips/functions.conf
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/Cheese.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/Person.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/PersonInterface.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/clips/
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/clips/ClipsShellTest.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/clips/CompiledFunctionsTest.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/clips/FunctionFactoryTest.java
   labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/clips/LhsClpParserTest.java
Log:
All monolothic build versions (<= 5.2.0.M1) stay in subversion

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/.gitignore
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/.gitignore	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/.gitignore	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,10 @@
+/target
+/local
+
+# Eclipse, Netbeans and IntelliJ files
+/.*
+!.gitignore
+/nbproject
+/*.ipr
+/*.iws
+/*.iml

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/build.properties
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/build.properties	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/build.properties	2011-02-24 15:26:37 UTC (rev 36697)
@@ -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/tags/5.2.0.M1/drools-clips/pom.xml
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/pom.xml	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/pom.xml	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,25 @@
+<?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>
+    <groupId>org.drools</groupId>
+    <artifactId>drools</artifactId>
+    <version>5.2.0.M1</version>
+  </parent>
+
+  <artifactId>drools-clips</artifactId>
+  <packaging>jar</packaging>
+  <name>Drools :: Clips</name>
+
+  <build/>
+
+  <dependencies>
+    <!-- Internal dependencies -->
+    <dependency>
+      <groupId>org.drools</groupId>
+      <artifactId>drools-compiler</artifactId>
+    </dependency>
+  </dependencies>
+
+</project>

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/Appendable.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/Appendable.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/Appendable.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,23 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips;
+
+public interface Appendable {
+
+    public abstract void append(String string);
+
+}
\ No newline at end of file

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/BoolLispAtom.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/BoolLispAtom.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/BoolLispAtom.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,28 @@
+/**
+ * Copyright 2010 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.
+ */
+
+/**
+ * 
+ */
+package org.drools.clips;
+
+public class BoolLispAtom extends LispAtom {
+    
+    public BoolLispAtom(String value) {
+        super(value);
+    }
+    
+}
\ No newline at end of file

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/ClipsLexer.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/ClipsLexer.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/ClipsLexer.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,2360 @@
+/**
+ * Copyright 2010 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.
+ */
+
+// $ANTLR 3.1.1 /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g 2008-11-24 17:53:59
+
+	package org.drools.clips;
+
+
+import org.antlr.runtime.*;
+import java.util.Stack;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+public class ClipsLexer extends Lexer {
+    public static final int EXISTS=15;
+    public static final int DEFRULE=8;
+    public static final int SYMBOL_CHAR=35;
+    public static final int HexDigit=32;
+    public static final int FLOAT=24;
+    public static final int TILDE=21;
+    public static final int OR=13;
+    public static final int PIPE=19;
+    public static final int ASSIGN_OP=18;
+    public static final int AND=12;
+    public static final int T__46=46;
+    public static final int FIRST_SYMBOL_CHAR=44;
+    public static final int DEFTEMPLATE=27;
+    public static final int EscapeSequence=31;
+    public static final int INT=11;
+    public static final int SYMBOL=43;
+    public static final int LEFT_SQUARE=38;
+    public static final int SH_STYLE_SINGLE_LINE_COMMENT=36;
+    public static final int AMPERSAND=20;
+    public static final int DECLARE=30;
+    public static final int LEFT_CURLY=40;
+    public static final int LEFT_PAREN=4;
+    public static final int RIGHT_CURLY=41;
+    public static final int BOOL=25;
+    public static final int DEFFUNCTION=7;
+    public static final int WS=29;
+    public static final int STRING=9;
+    public static final int T__45=45;
+    public static final int VAR=17;
+    public static final int EQUALS=23;
+    public static final int UnicodeEscape=33;
+    public static final int EOF=-1;
+    public static final int NULL=26;
+    public static final int EOL=28;
+    public static final int COLON=22;
+    public static final int SALIENCE=10;
+    public static final int OctalEscape=34;
+    public static final int MULTI_LINE_COMMENT=42;
+    public static final int TEST=16;
+    public static final int NAME=5;
+    public static final int RIGHT_PAREN=6;
+    public static final int NOT=14;
+    public static final int RIGHT_SQUARE=39;
+    public static final int C_STYLE_SINGLE_LINE_COMMENT=37;
+
+    // delegates
+    // delegators
+
+    public ClipsLexer() {;} 
+    public ClipsLexer(CharStream input) {
+        this(input, new RecognizerSharedState());
+    }
+    public ClipsLexer(CharStream input, RecognizerSharedState state) {
+        super(input,state);
+
+    }
+    public String getGrammarFileName() { return "/Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g"; }
+
+    // $ANTLR start "T__45"
+    public final void mT__45() throws RecognitionException {
+        try {
+            int _type = T__45;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:7:7: ( 'import' )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:7:9: 'import'
+            {
+            match("import"); if (state.failed) return ;
+
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "T__45"
+
+    // $ANTLR start "T__46"
+    public final void mT__46() throws RecognitionException {
+        try {
+            int _type = T__46;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:8:7: ( '=>' )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:8:9: '=>'
+            {
+            match("=>"); if (state.failed) return ;
+
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "T__46"
+
+    // $ANTLR start "WS"
+    public final void mWS() throws RecognitionException {
+        try {
+            int _type = WS;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:802:9: ( ( ' ' | '\\t' | '\\f' | EOL ) )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:802:17: ( ' ' | '\\t' | '\\f' | EOL )
+            {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:802: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 (state.backtracking>0) {state.failed=true; return ;}
+                NoViableAltException nvae =
+                    new NoViableAltException("", 1, 0, input);
+
+                throw nvae;
+            }
+
+            switch (alt1) {
+                case 1 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:802:19: ' '
+                    {
+                    match(' '); if (state.failed) return ;
+
+                    }
+                    break;
+                case 2 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:803:19: '\\t'
+                    {
+                    match('\t'); if (state.failed) return ;
+
+                    }
+                    break;
+                case 3 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:804:19: '\\f'
+                    {
+                    match('\f'); if (state.failed) return ;
+
+                    }
+                    break;
+                case 4 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:805:19: EOL
+                    {
+                    mEOL(); if (state.failed) return ;
+
+                    }
+                    break;
+
+            }
+
+            if ( state.backtracking==0 ) {
+               _channel=HIDDEN; 
+            }
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "WS"
+
+    // $ANTLR start "DEFTEMPLATE"
+    public final void mDEFTEMPLATE() throws RecognitionException {
+        try {
+            int _type = DEFTEMPLATE;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:811:13: ( 'deftemplate' )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:811:17: 'deftemplate'
+            {
+            match("deftemplate"); if (state.failed) return ;
+
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "DEFTEMPLATE"
+
+    // $ANTLR start "DEFRULE"
+    public final void mDEFRULE() throws RecognitionException {
+        try {
+            int _type = DEFRULE;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:814:10: ( 'defrule' )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:814:12: 'defrule'
+            {
+            match("defrule"); if (state.failed) return ;
+
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "DEFRULE"
+
+    // $ANTLR start "DEFFUNCTION"
+    public final void mDEFFUNCTION() throws RecognitionException {
+        try {
+            int _type = DEFFUNCTION;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:815:13: ( 'deffunction' )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:815:15: 'deffunction'
+            {
+            match("deffunction"); if (state.failed) return ;
+
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "DEFFUNCTION"
+
+    // $ANTLR start "OR"
+    public final void mOR() throws RecognitionException {
+        try {
+            int _type = OR;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:816:7: ( 'or' )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:816:9: 'or'
+            {
+            match("or"); if (state.failed) return ;
+
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "OR"
+
+    // $ANTLR start "AND"
+    public final void mAND() throws RecognitionException {
+        try {
+            int _type = AND;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:817:7: ( 'and' )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:817:9: 'and'
+            {
+            match("and"); if (state.failed) return ;
+
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "AND"
+
+    // $ANTLR start "NOT"
+    public final void mNOT() throws RecognitionException {
+        try {
+            int _type = NOT;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:818:7: ( 'not' )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:818:9: 'not'
+            {
+            match("not"); if (state.failed) return ;
+
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "NOT"
+
+    // $ANTLR start "EXISTS"
+    public final void mEXISTS() throws RecognitionException {
+        try {
+            int _type = EXISTS;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:819:10: ( 'exists' )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:819:12: 'exists'
+            {
+            match("exists"); if (state.failed) return ;
+
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "EXISTS"
+
+    // $ANTLR start "TEST"
+    public final void mTEST() throws RecognitionException {
+        try {
+            int _type = TEST;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:820:8: ( 'test' )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:820:10: 'test'
+            {
+            match("test"); if (state.failed) return ;
+
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "TEST"
+
+    // $ANTLR start "NULL"
+    public final void mNULL() throws RecognitionException {
+        try {
+            int _type = NULL;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:821:7: ( 'null' )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:821:9: 'null'
+            {
+            match("null"); if (state.failed) return ;
+
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "NULL"
+
+    // $ANTLR start "DECLARE"
+    public final void mDECLARE() throws RecognitionException {
+        try {
+            int _type = DECLARE;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:823:10: ( 'declare' )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:823:12: 'declare'
+            {
+            match("declare"); if (state.failed) return ;
+
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "DECLARE"
+
+    // $ANTLR start "SALIENCE"
+    public final void mSALIENCE() throws RecognitionException {
+        try {
+            int _type = SALIENCE;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:825:10: ( 'salience' )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:825:12: 'salience'
+            {
+            match("salience"); if (state.failed) return ;
+
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "SALIENCE"
+
+    // $ANTLR start "EOL"
+    public final void mEOL() throws RecognitionException {
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:830:6: ( ( ( '\\r\\n' )=> '\\r\\n' | '\\r' | '\\n' ) )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:831:6: ( ( '\\r\\n' )=> '\\r\\n' | '\\r' | '\\n' )
+            {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:831: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') && (synpred1_Clips())) {
+                    alt2=1;
+                }
+                else {
+                    alt2=2;}
+            }
+            else if ( (LA2_0=='\n') ) {
+                alt2=3;
+            }
+            else {
+                if (state.backtracking>0) {state.failed=true; return ;}
+                NoViableAltException nvae =
+                    new NoViableAltException("", 2, 0, input);
+
+                throw nvae;
+            }
+            switch (alt2) {
+                case 1 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:831:14: ( '\\r\\n' )=> '\\r\\n'
+                    {
+                    match("\r\n"); if (state.failed) return ;
+
+
+                    }
+                    break;
+                case 2 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:832:25: '\\r'
+                    {
+                    match('\r'); if (state.failed) return ;
+
+                    }
+                    break;
+                case 3 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:833:25: '\\n'
+                    {
+                    match('\n'); if (state.failed) return ;
+
+                    }
+                    break;
+
+            }
+
+
+            }
+
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "EOL"
+
+    // $ANTLR start "INT"
+    public final void mINT() throws RecognitionException {
+        try {
+            int _type = INT;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:838:2: ( ( '-' )? ( '0' .. '9' )+ )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:838:4: ( '-' )? ( '0' .. '9' )+
+            {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:838:4: ( '-' )?
+            int alt3=2;
+            int LA3_0 = input.LA(1);
+
+            if ( (LA3_0=='-') ) {
+                alt3=1;
+            }
+            switch (alt3) {
+                case 1 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:838:5: '-'
+                    {
+                    match('-'); if (state.failed) return ;
+
+                    }
+                    break;
+
+            }
+
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:838: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 :
+            	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:838:11: '0' .. '9'
+            	    {
+            	    matchRange('0','9'); if (state.failed) return ;
+
+            	    }
+            	    break;
+
+            	default :
+            	    if ( cnt4 >= 1 ) break loop4;
+            	    if (state.backtracking>0) {state.failed=true; return ;}
+                        EarlyExitException eee =
+                            new EarlyExitException(4, input);
+                        throw eee;
+                }
+                cnt4++;
+            } while (true);
+
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "INT"
+
+    // $ANTLR start "FLOAT"
+    public final void mFLOAT() throws RecognitionException {
+        try {
+            int _type = FLOAT;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:842:2: ( ( '-' )? ( '0' .. '9' )+ '.' ( '0' .. '9' )+ )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:842:4: ( '-' )? ( '0' .. '9' )+ '.' ( '0' .. '9' )+
+            {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:842:4: ( '-' )?
+            int alt5=2;
+            int LA5_0 = input.LA(1);
+
+            if ( (LA5_0=='-') ) {
+                alt5=1;
+            }
+            switch (alt5) {
+                case 1 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:842:5: '-'
+                    {
+                    match('-'); if (state.failed) return ;
+
+                    }
+                    break;
+
+            }
+
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:842: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 :
+            	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:842:11: '0' .. '9'
+            	    {
+            	    matchRange('0','9'); if (state.failed) return ;
+
+            	    }
+            	    break;
+
+            	default :
+            	    if ( cnt6 >= 1 ) break loop6;
+            	    if (state.backtracking>0) {state.failed=true; return ;}
+                        EarlyExitException eee =
+                            new EarlyExitException(6, input);
+                        throw eee;
+                }
+                cnt6++;
+            } while (true);
+
+            match('.'); if (state.failed) return ;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:842: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 :
+            	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:842:27: '0' .. '9'
+            	    {
+            	    matchRange('0','9'); if (state.failed) return ;
+
+            	    }
+            	    break;
+
+            	default :
+            	    if ( cnt7 >= 1 ) break loop7;
+            	    if (state.backtracking>0) {state.failed=true; return ;}
+                        EarlyExitException eee =
+                            new EarlyExitException(7, input);
+                        throw eee;
+                }
+                cnt7++;
+            } while (true);
+
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "FLOAT"
+
+    // $ANTLR start "STRING"
+    public final void mSTRING() throws RecognitionException {
+        try {
+            int _type = STRING;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:846:5: ( ( '\"' ( EscapeSequence | ~ ( '\\\\' | '\"' ) )* '\"' ) | ( '\\'' ( EscapeSequence | ~ ( '\\\\' | '\\'' ) )* '\\'' ) )
+            int alt10=2;
+            int LA10_0 = input.LA(1);
+
+            if ( (LA10_0=='\"') ) {
+                alt10=1;
+            }
+            else if ( (LA10_0=='\'') ) {
+                alt10=2;
+            }
+            else {
+                if (state.backtracking>0) {state.failed=true; return ;}
+                NoViableAltException nvae =
+                    new NoViableAltException("", 10, 0, input);
+
+                throw nvae;
+            }
+            switch (alt10) {
+                case 1 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:846:8: ( '\"' ( EscapeSequence | ~ ( '\\\\' | '\"' ) )* '\"' )
+                    {
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:846:8: ( '\"' ( EscapeSequence | ~ ( '\\\\' | '\"' ) )* '\"' )
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:846:9: '\"' ( EscapeSequence | ~ ( '\\\\' | '\"' ) )* '\"'
+                    {
+                    match('\"'); if (state.failed) return ;
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:846: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<='\uFFFF')) ) {
+                            alt8=2;
+                        }
+
+
+                        switch (alt8) {
+                    	case 1 :
+                    	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:846:15: EscapeSequence
+                    	    {
+                    	    mEscapeSequence(); if (state.failed) return ;
+
+                    	    }
+                    	    break;
+                    	case 2 :
+                    	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:846:32: ~ ( '\\\\' | '\"' )
+                    	    {
+                    	    if ( (input.LA(1)>='\u0000' && input.LA(1)<='!')||(input.LA(1)>='#' && input.LA(1)<='[')||(input.LA(1)>=']' && input.LA(1)<='\uFFFF') ) {
+                    	        input.consume();
+                    	    state.failed=false;
+                    	    }
+                    	    else {
+                    	        if (state.backtracking>0) {state.failed=true; return ;}
+                    	        MismatchedSetException mse = new MismatchedSetException(null,input);
+                    	        recover(mse);
+                    	        throw mse;}
+
+
+                    	    }
+                    	    break;
+
+                    	default :
+                    	    break loop8;
+                        }
+                    } while (true);
+
+                    match('\"'); if (state.failed) return ;
+
+                    }
+
+
+                    }
+                    break;
+                case 2 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:847:8: ( '\\'' ( EscapeSequence | ~ ( '\\\\' | '\\'' ) )* '\\'' )
+                    {
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:847:8: ( '\\'' ( EscapeSequence | ~ ( '\\\\' | '\\'' ) )* '\\'' )
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:847:9: '\\'' ( EscapeSequence | ~ ( '\\\\' | '\\'' ) )* '\\''
+                    {
+                    match('\''); if (state.failed) return ;
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:847: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<='\uFFFF')) ) {
+                            alt9=2;
+                        }
+
+
+                        switch (alt9) {
+                    	case 1 :
+                    	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:847:16: EscapeSequence
+                    	    {
+                    	    mEscapeSequence(); if (state.failed) return ;
+
+                    	    }
+                    	    break;
+                    	case 2 :
+                    	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:847:33: ~ ( '\\\\' | '\\'' )
+                    	    {
+                    	    if ( (input.LA(1)>='\u0000' && input.LA(1)<='&')||(input.LA(1)>='(' && input.LA(1)<='[')||(input.LA(1)>=']' && input.LA(1)<='\uFFFF') ) {
+                    	        input.consume();
+                    	    state.failed=false;
+                    	    }
+                    	    else {
+                    	        if (state.backtracking>0) {state.failed=true; return ;}
+                    	        MismatchedSetException mse = new MismatchedSetException(null,input);
+                    	        recover(mse);
+                    	        throw mse;}
+
+
+                    	    }
+                    	    break;
+
+                    	default :
+                    	    break loop9;
+                        }
+                    } while (true);
+
+                    match('\''); if (state.failed) return ;
+
+                    }
+
+
+                    }
+                    break;
+
+            }
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "STRING"
+
+    // $ANTLR start "HexDigit"
+    public final void mHexDigit() throws RecognitionException {
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:851:10: ( ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' ) )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:851: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();
+            state.failed=false;
+            }
+            else {
+                if (state.backtracking>0) {state.failed=true; return ;}
+                MismatchedSetException mse = new MismatchedSetException(null,input);
+                recover(mse);
+                throw mse;}
+
+
+            }
+
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "HexDigit"
+
+    // $ANTLR start "EscapeSequence"
+    public final void mEscapeSequence() throws RecognitionException {
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:855:5: ( '\\\\' ( 'b' | 't' | 'n' | 'f' | 'r' | '\\\"' | '\\'' | '\\\\' ) | UnicodeEscape | OctalEscape )
+            int alt11=3;
+            int LA11_0 = input.LA(1);
+
+            if ( (LA11_0=='\\') ) {
+                switch ( input.LA(2) ) {
+                case '\"':
+                case '\'':
+                case '\\':
+                case 'b':
+                case 'f':
+                case 'n':
+                case 'r':
+                case 't':
+                    {
+                    alt11=1;
+                    }
+                    break;
+                case 'u':
+                    {
+                    alt11=2;
+                    }
+                    break;
+                case '0':
+                case '1':
+                case '2':
+                case '3':
+                case '4':
+                case '5':
+                case '6':
+                case '7':
+                    {
+                    alt11=3;
+                    }
+                    break;
+                default:
+                    if (state.backtracking>0) {state.failed=true; return ;}
+                    NoViableAltException nvae =
+                        new NoViableAltException("", 11, 1, input);
+
+                    throw nvae;
+                }
+
+            }
+            else {
+                if (state.backtracking>0) {state.failed=true; return ;}
+                NoViableAltException nvae =
+                    new NoViableAltException("", 11, 0, input);
+
+                throw nvae;
+            }
+            switch (alt11) {
+                case 1 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:855:9: '\\\\' ( 'b' | 't' | 'n' | 'f' | 'r' | '\\\"' | '\\'' | '\\\\' )
+                    {
+                    match('\\'); if (state.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();
+                    state.failed=false;
+                    }
+                    else {
+                        if (state.backtracking>0) {state.failed=true; return ;}
+                        MismatchedSetException mse = new MismatchedSetException(null,input);
+                        recover(mse);
+                        throw mse;}
+
+
+                    }
+                    break;
+                case 2 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:856:9: UnicodeEscape
+                    {
+                    mUnicodeEscape(); if (state.failed) return ;
+
+                    }
+                    break;
+                case 3 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:857:9: OctalEscape
+                    {
+                    mOctalEscape(); if (state.failed) return ;
+
+                    }
+                    break;
+
+            }
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "EscapeSequence"
+
+    // $ANTLR start "OctalEscape"
+    public final void mOctalEscape() throws RecognitionException {
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:862:5: ( '\\\\' ( '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_4 = input.LA(4);
+
+                        if ( ((LA12_4>='0' && LA12_4<='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 (state.backtracking>0) {state.failed=true; return ;}
+                    NoViableAltException nvae =
+                        new NoViableAltException("", 12, 1, input);
+
+                    throw nvae;
+                }
+            }
+            else {
+                if (state.backtracking>0) {state.failed=true; return ;}
+                NoViableAltException nvae =
+                    new NoViableAltException("", 12, 0, input);
+
+                throw nvae;
+            }
+            switch (alt12) {
+                case 1 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:862:9: '\\\\' ( '0' .. '3' ) ( '0' .. '7' ) ( '0' .. '7' )
+                    {
+                    match('\\'); if (state.failed) return ;
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:862:14: ( '0' .. '3' )
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:862:15: '0' .. '3'
+                    {
+                    matchRange('0','3'); if (state.failed) return ;
+
+                    }
+
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:862:25: ( '0' .. '7' )
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:862:26: '0' .. '7'
+                    {
+                    matchRange('0','7'); if (state.failed) return ;
+
+                    }
+
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:862:36: ( '0' .. '7' )
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:862:37: '0' .. '7'
+                    {
+                    matchRange('0','7'); if (state.failed) return ;
+
+                    }
+
+
+                    }
+                    break;
+                case 2 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:863:9: '\\\\' ( '0' .. '7' ) ( '0' .. '7' )
+                    {
+                    match('\\'); if (state.failed) return ;
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:863:14: ( '0' .. '7' )
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:863:15: '0' .. '7'
+                    {
+                    matchRange('0','7'); if (state.failed) return ;
+
+                    }
+
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:863:25: ( '0' .. '7' )
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:863:26: '0' .. '7'
+                    {
+                    matchRange('0','7'); if (state.failed) return ;
+
+                    }
+
+
+                    }
+                    break;
+                case 3 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:864:9: '\\\\' ( '0' .. '7' )
+                    {
+                    match('\\'); if (state.failed) return ;
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:864:14: ( '0' .. '7' )
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:864:15: '0' .. '7'
+                    {
+                    matchRange('0','7'); if (state.failed) return ;
+
+                    }
+
+
+                    }
+                    break;
+
+            }
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "OctalEscape"
+
+    // $ANTLR start "UnicodeEscape"
+    public final void mUnicodeEscape() throws RecognitionException {
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:869:5: ( '\\\\' 'u' HexDigit HexDigit HexDigit HexDigit )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:869:9: '\\\\' 'u' HexDigit HexDigit HexDigit HexDigit
+            {
+            match('\\'); if (state.failed) return ;
+            match('u'); if (state.failed) return ;
+            mHexDigit(); if (state.failed) return ;
+            mHexDigit(); if (state.failed) return ;
+            mHexDigit(); if (state.failed) return ;
+            mHexDigit(); if (state.failed) return ;
+
+            }
+
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "UnicodeEscape"
+
+    // $ANTLR start "BOOL"
+    public final void mBOOL() throws RecognitionException {
+        try {
+            int _type = BOOL;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:873:2: ( ( 'true' | 'false' ) )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:873:4: ( 'true' | 'false' )
+            {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:873: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 (state.backtracking>0) {state.failed=true; return ;}
+                NoViableAltException nvae =
+                    new NoViableAltException("", 13, 0, input);
+
+                throw nvae;
+            }
+            switch (alt13) {
+                case 1 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:873:5: 'true'
+                    {
+                    match("true"); if (state.failed) return ;
+
+
+                    }
+                    break;
+                case 2 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:873:12: 'false'
+                    {
+                    match("false"); if (state.failed) return ;
+
+
+                    }
+                    break;
+
+            }
+
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "BOOL"
+
+    // $ANTLR start "VAR"
+    public final void mVAR() throws RecognitionException {
+        try {
+            int _type = VAR;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:876:6: ( '?' ( SYMBOL_CHAR )+ )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:876:8: '?' ( SYMBOL_CHAR )+
+            {
+            match('?'); if (state.failed) return ;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:876:12: ( SYMBOL_CHAR )+
+            int cnt14=0;
+            loop14:
+            do {
+                int alt14=2;
+                int LA14_0 = input.LA(1);
+
+                if ( (LA14_0=='!'||(LA14_0>='#' && LA14_0<='%')||(LA14_0>='*' && LA14_0<=':')||(LA14_0>='=' && LA14_0<='_')||(LA14_0>='a' && LA14_0<='{')||LA14_0=='}') ) {
+                    alt14=1;
+                }
+
+
+                switch (alt14) {
+            	case 1 :
+            	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:876:12: SYMBOL_CHAR
+            	    {
+            	    mSYMBOL_CHAR(); if (state.failed) return ;
+
+            	    }
+            	    break;
+
+            	default :
+            	    if ( cnt14 >= 1 ) break loop14;
+            	    if (state.backtracking>0) {state.failed=true; return ;}
+                        EarlyExitException eee =
+                            new EarlyExitException(14, input);
+                        throw eee;
+                }
+                cnt14++;
+            } while (true);
+
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "VAR"
+
+    // $ANTLR start "SH_STYLE_SINGLE_LINE_COMMENT"
+    public final void mSH_STYLE_SINGLE_LINE_COMMENT() throws RecognitionException {
+        try {
+            int _type = SH_STYLE_SINGLE_LINE_COMMENT;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:880:2: ( '#' ( options {greedy=false; } : . )* EOL )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:880:4: '#' ( options {greedy=false; } : . )* EOL
+            {
+            match('#'); if (state.failed) return ;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:880: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<='\uFFFF')) ) {
+                    alt15=1;
+                }
+
+
+                switch (alt15) {
+            	case 1 :
+            	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:880:35: .
+            	    {
+            	    matchAny(); if (state.failed) return ;
+
+            	    }
+            	    break;
+
+            	default :
+            	    break loop15;
+                }
+            } while (true);
+
+            mEOL(); if (state.failed) return ;
+            if ( state.backtracking==0 ) {
+               _channel=HIDDEN; 
+            }
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "SH_STYLE_SINGLE_LINE_COMMENT"
+
+    // $ANTLR start "C_STYLE_SINGLE_LINE_COMMENT"
+    public final void mC_STYLE_SINGLE_LINE_COMMENT() throws RecognitionException {
+        try {
+            int _type = C_STYLE_SINGLE_LINE_COMMENT;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:886:2: ( '//' ( options {greedy=false; } : . )* EOL )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:886:4: '//' ( options {greedy=false; } : . )* EOL
+            {
+            match("//"); if (state.failed) return ;
+
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:886: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<='\uFFFF')) ) {
+                    alt16=1;
+                }
+
+
+                switch (alt16) {
+            	case 1 :
+            	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:886:36: .
+            	    {
+            	    matchAny(); if (state.failed) return ;
+
+            	    }
+            	    break;
+
+            	default :
+            	    break loop16;
+                }
+            } while (true);
+
+            mEOL(); if (state.failed) return ;
+            if ( state.backtracking==0 ) {
+               _channel=HIDDEN; 
+            }
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "C_STYLE_SINGLE_LINE_COMMENT"
+
+    // $ANTLR start "LEFT_PAREN"
+    public final void mLEFT_PAREN() throws RecognitionException {
+        try {
+            int _type = LEFT_PAREN;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:892:2: ( '(' )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:892:4: '('
+            {
+            match('('); if (state.failed) return ;
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "LEFT_PAREN"
+
+    // $ANTLR start "RIGHT_PAREN"
+    public final void mRIGHT_PAREN() throws RecognitionException {
+        try {
+            int _type = RIGHT_PAREN;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:896:2: ( ')' )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:896:4: ')'
+            {
+            match(')'); if (state.failed) return ;
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "RIGHT_PAREN"
+
+    // $ANTLR start "LEFT_SQUARE"
+    public final void mLEFT_SQUARE() throws RecognitionException {
+        try {
+            int _type = LEFT_SQUARE;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:900:2: ( '[' )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:900:4: '['
+            {
+            match('['); if (state.failed) return ;
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "LEFT_SQUARE"
+
+    // $ANTLR start "RIGHT_SQUARE"
+    public final void mRIGHT_SQUARE() throws RecognitionException {
+        try {
+            int _type = RIGHT_SQUARE;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:904:2: ( ']' )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:904:4: ']'
+            {
+            match(']'); if (state.failed) return ;
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "RIGHT_SQUARE"
+
+    // $ANTLR start "LEFT_CURLY"
+    public final void mLEFT_CURLY() throws RecognitionException {
+        try {
+            int _type = LEFT_CURLY;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:908:2: ( '{' )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:908:4: '{'
+            {
+            match('{'); if (state.failed) return ;
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "LEFT_CURLY"
+
+    // $ANTLR start "RIGHT_CURLY"
+    public final void mRIGHT_CURLY() throws RecognitionException {
+        try {
+            int _type = RIGHT_CURLY;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:912:2: ( '}' )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:912:4: '}'
+            {
+            match('}'); if (state.failed) return ;
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "RIGHT_CURLY"
+
+    // $ANTLR start "TILDE"
+    public final void mTILDE() throws RecognitionException {
+        try {
+            int _type = TILDE;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:915:7: ( '~' )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:915:9: '~'
+            {
+            match('~'); if (state.failed) return ;
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "TILDE"
+
+    // $ANTLR start "AMPERSAND"
+    public final void mAMPERSAND() throws RecognitionException {
+        try {
+            int _type = AMPERSAND;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:919:2: ( '&' )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:919:4: '&'
+            {
+            match('&'); if (state.failed) return ;
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "AMPERSAND"
+
+    // $ANTLR start "PIPE"
+    public final void mPIPE() throws RecognitionException {
+        try {
+            int _type = PIPE;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:923:2: ( '|' )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:923:4: '|'
+            {
+            match('|'); if (state.failed) return ;
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "PIPE"
+
+    // $ANTLR start "ASSIGN_OP"
+    public final void mASSIGN_OP() throws RecognitionException {
+        try {
+            int _type = ASSIGN_OP;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:927:2: ( '<-' )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:927:4: '<-'
+            {
+            match("<-"); if (state.failed) return ;
+
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "ASSIGN_OP"
+
+    // $ANTLR start "COLON"
+    public final void mCOLON() throws RecognitionException {
+        try {
+            int _type = COLON;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:930:7: ( ':' )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:930:9: ':'
+            {
+            match(':'); if (state.failed) return ;
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "COLON"
+
+    // $ANTLR start "EQUALS"
+    public final void mEQUALS() throws RecognitionException {
+        try {
+            int _type = EQUALS;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:932:8: ( '=' )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:932:10: '='
+            {
+            match('='); if (state.failed) return ;
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "EQUALS"
+
+    // $ANTLR start "MULTI_LINE_COMMENT"
+    public final void mMULTI_LINE_COMMENT() throws RecognitionException {
+        try {
+            int _type = MULTI_LINE_COMMENT;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:935:2: ( '/*' ( options {greedy=false; } : . )* '*/' )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:935:4: '/*' ( options {greedy=false; } : . )* '*/'
+            {
+            match("/*"); if (state.failed) return ;
+
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:935: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<='\uFFFF')) ) {
+                        alt17=1;
+                    }
+
+
+                }
+                else if ( ((LA17_0>='\u0000' && LA17_0<=')')||(LA17_0>='+' && LA17_0<='\uFFFF')) ) {
+                    alt17=1;
+                }
+
+
+                switch (alt17) {
+            	case 1 :
+            	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:935:35: .
+            	    {
+            	    matchAny(); if (state.failed) return ;
+
+            	    }
+            	    break;
+
+            	default :
+            	    break loop17;
+                }
+            } while (true);
+
+            match("*/"); if (state.failed) return ;
+
+            if ( state.backtracking==0 ) {
+               _channel=HIDDEN; 
+            }
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "MULTI_LINE_COMMENT"
+
+    // $ANTLR start "NAME"
+    public final void mNAME() throws RecognitionException {
+        try {
+            int _type = NAME;
+            int _channel = DEFAULT_TOKEN_CHANNEL;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:939:6: ( SYMBOL )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:939:8: SYMBOL
+            {
+            mSYMBOL(); if (state.failed) return ;
+
+            }
+
+            state.type = _type;
+            state.channel = _channel;
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "NAME"
+
+    // $ANTLR start "SYMBOL"
+    public final void mSYMBOL() throws RecognitionException {
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:942:8: ( FIRST_SYMBOL_CHAR ( SYMBOL_CHAR )* )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:942:10: FIRST_SYMBOL_CHAR ( SYMBOL_CHAR )*
+            {
+            mFIRST_SYMBOL_CHAR(); if (state.failed) return ;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:942:28: ( SYMBOL_CHAR )*
+            loop18:
+            do {
+                int alt18=2;
+                int LA18_0 = input.LA(1);
+
+                if ( (LA18_0=='!'||(LA18_0>='#' && LA18_0<='%')||(LA18_0>='*' && LA18_0<=':')||(LA18_0>='=' && LA18_0<='_')||(LA18_0>='a' && LA18_0<='{')||LA18_0=='}') ) {
+                    alt18=1;
+                }
+
+
+                switch (alt18) {
+            	case 1 :
+            	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:942:28: SYMBOL_CHAR
+            	    {
+            	    mSYMBOL_CHAR(); if (state.failed) return ;
+
+            	    }
+            	    break;
+
+            	default :
+            	    break loop18;
+                }
+            } while (true);
+
+
+            }
+
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "SYMBOL"
+
+    // $ANTLR start "FIRST_SYMBOL_CHAR"
+    public final void mFIRST_SYMBOL_CHAR() throws RecognitionException {
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:947:19: ( ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '!' | '$' | '%' | '^' | '*' | '_' | '-' | '+' | '=' | '\\\\' | '/' | '@' | '#' | ':' | '>' | '<' | ',' | '.' | '[' | ']' | '{' | '}' ) )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:947:21: ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '!' | '$' | '%' | '^' | '*' | '_' | '-' | '+' | '=' | '\\\\' | '/' | '@' | '#' | ':' | '>' | '<' | ',' | '.' | '[' | ']' | '{' | '}' )
+            {
+            if ( 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)>='a' && input.LA(1)<='{')||input.LA(1)=='}' ) {
+                input.consume();
+            state.failed=false;
+            }
+            else {
+                if (state.backtracking>0) {state.failed=true; return ;}
+                MismatchedSetException mse = new MismatchedSetException(null,input);
+                recover(mse);
+                throw mse;}
+
+
+            }
+
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "FIRST_SYMBOL_CHAR"
+
+    // $ANTLR start "SYMBOL_CHAR"
+    public final void mSYMBOL_CHAR() throws RecognitionException {
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:952:13: ( ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '!' | '$' | '%' | '^' | '*' | '_' | '-' | '+' | '=' | '\\\\' | '/' | '@' | '#' | ':' | '>' | ',' | '.' | '[' | ']' | '{' | '}' | '?' ) )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:952:15: ( 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '!' | '$' | '%' | '^' | '*' | '_' | '-' | '+' | '=' | '\\\\' | '/' | '@' | '#' | ':' | '>' | ',' | '.' | '[' | ']' | '{' | '}' | '?' )
+            {
+            if ( input.LA(1)=='!'||(input.LA(1)>='#' && input.LA(1)<='%')||(input.LA(1)>='*' && input.LA(1)<=':')||(input.LA(1)>='=' && input.LA(1)<='_')||(input.LA(1)>='a' && input.LA(1)<='{')||input.LA(1)=='}' ) {
+                input.consume();
+            state.failed=false;
+            }
+            else {
+                if (state.backtracking>0) {state.failed=true; return ;}
+                MismatchedSetException mse = new MismatchedSetException(null,input);
+                recover(mse);
+                throw mse;}
+
+
+            }
+
+        }
+        finally {
+        }
+    }
+    // $ANTLR end "SYMBOL_CHAR"
+
+    public void mTokens() throws RecognitionException {
+        // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:8: ( T__45 | T__46 | WS | DEFTEMPLATE | DEFRULE | DEFFUNCTION | 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 alt19=35;
+        alt19 = dfa19.predict(input);
+        switch (alt19) {
+            case 1 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:10: T__45
+                {
+                mT__45(); if (state.failed) return ;
+
+                }
+                break;
+            case 2 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:16: T__46
+                {
+                mT__46(); if (state.failed) return ;
+
+                }
+                break;
+            case 3 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:22: WS
+                {
+                mWS(); if (state.failed) return ;
+
+                }
+                break;
+            case 4 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:25: DEFTEMPLATE
+                {
+                mDEFTEMPLATE(); if (state.failed) return ;
+
+                }
+                break;
+            case 5 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:37: DEFRULE
+                {
+                mDEFRULE(); if (state.failed) return ;
+
+                }
+                break;
+            case 6 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:45: DEFFUNCTION
+                {
+                mDEFFUNCTION(); if (state.failed) return ;
+
+                }
+                break;
+            case 7 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:57: OR
+                {
+                mOR(); if (state.failed) return ;
+
+                }
+                break;
+            case 8 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:60: AND
+                {
+                mAND(); if (state.failed) return ;
+
+                }
+                break;
+            case 9 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:64: NOT
+                {
+                mNOT(); if (state.failed) return ;
+
+                }
+                break;
+            case 10 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:68: EXISTS
+                {
+                mEXISTS(); if (state.failed) return ;
+
+                }
+                break;
+            case 11 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:75: TEST
+                {
+                mTEST(); if (state.failed) return ;
+
+                }
+                break;
+            case 12 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:80: NULL
+                {
+                mNULL(); if (state.failed) return ;
+
+                }
+                break;
+            case 13 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:85: DECLARE
+                {
+                mDECLARE(); if (state.failed) return ;
+
+                }
+                break;
+            case 14 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:93: SALIENCE
+                {
+                mSALIENCE(); if (state.failed) return ;
+
+                }
+                break;
+            case 15 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:102: INT
+                {
+                mINT(); if (state.failed) return ;
+
+                }
+                break;
+            case 16 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:106: FLOAT
+                {
+                mFLOAT(); if (state.failed) return ;
+
+                }
+                break;
+            case 17 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:112: STRING
+                {
+                mSTRING(); if (state.failed) return ;
+
+                }
+                break;
+            case 18 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:119: BOOL
+                {
+                mBOOL(); if (state.failed) return ;
+
+                }
+                break;
+            case 19 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:124: VAR
+                {
+                mVAR(); if (state.failed) return ;
+
+                }
+                break;
+            case 20 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:128: SH_STYLE_SINGLE_LINE_COMMENT
+                {
+                mSH_STYLE_SINGLE_LINE_COMMENT(); if (state.failed) return ;
+
+                }
+                break;
+            case 21 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:157: C_STYLE_SINGLE_LINE_COMMENT
+                {
+                mC_STYLE_SINGLE_LINE_COMMENT(); if (state.failed) return ;
+
+                }
+                break;
+            case 22 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:185: LEFT_PAREN
+                {
+                mLEFT_PAREN(); if (state.failed) return ;
+
+                }
+                break;
+            case 23 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:196: RIGHT_PAREN
+                {
+                mRIGHT_PAREN(); if (state.failed) return ;
+
+                }
+                break;
+            case 24 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:208: LEFT_SQUARE
+                {
+                mLEFT_SQUARE(); if (state.failed) return ;
+
+                }
+                break;
+            case 25 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:220: RIGHT_SQUARE
+                {
+                mRIGHT_SQUARE(); if (state.failed) return ;
+
+                }
+                break;
+            case 26 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:233: LEFT_CURLY
+                {
+                mLEFT_CURLY(); if (state.failed) return ;
+
+                }
+                break;
+            case 27 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:244: RIGHT_CURLY
+                {
+                mRIGHT_CURLY(); if (state.failed) return ;
+
+                }
+                break;
+            case 28 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:256: TILDE
+                {
+                mTILDE(); if (state.failed) return ;
+
+                }
+                break;
+            case 29 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:262: AMPERSAND
+                {
+                mAMPERSAND(); if (state.failed) return ;
+
+                }
+                break;
+            case 30 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:272: PIPE
+                {
+                mPIPE(); if (state.failed) return ;
+
+                }
+                break;
+            case 31 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:277: ASSIGN_OP
+                {
+                mASSIGN_OP(); if (state.failed) return ;
+
+                }
+                break;
+            case 32 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:287: COLON
+                {
+                mCOLON(); if (state.failed) return ;
+
+                }
+                break;
+            case 33 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:293: EQUALS
+                {
+                mEQUALS(); if (state.failed) return ;
+
+                }
+                break;
+            case 34 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:300: MULTI_LINE_COMMENT
+                {
+                mMULTI_LINE_COMMENT(); if (state.failed) return ;
+
+                }
+                break;
+            case 35 :
+                // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:1:319: NAME
+                {
+                mNAME(); if (state.failed) return ;
+
+                }
+                break;
+
+        }
+
+    }
+
+    // $ANTLR start synpred1_Clips
+    public final void synpred1_Clips_fragment() throws RecognitionException {   
+        // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:831:14: ( '\\r\\n' )
+        // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:831:16: '\\r\\n'
+        {
+        match("\r\n"); if (state.failed) return ;
+
+
+        }
+    }
+    // $ANTLR end synpred1_Clips
+
+    public final boolean synpred1_Clips() {
+        state.backtracking++;
+        int start = input.mark();
+        try {
+            synpred1_Clips_fragment(); // can never throw exception
+        } catch (RecognitionException re) {
+            System.err.println("impossible: "+re);
+        }
+        boolean success = !state.failed;
+        input.rewind(start);
+        state.backtracking--;
+        state.failed=false;
+        return success;
+    }
+
+
+    protected DFA19 dfa19 = new DFA19(this);
+    static final String DFA19_eotS =
+        "\1\uffff\1\35\1\40\1\uffff\10\35\1\54\1\uffff\1\35\1\uffff\2\35"+
+        "\2\uffff\1\62\1\63\1\64\1\65\3\uffff\1\35\1\67\1\uffff\1\35\1\71"+
+        "\1\uffff\1\35\1\74\7\35\1\54\1\35\1\uffff\1\35\1\uffff\3\35\4\uffff"+
+        "\1\113\1\uffff\1\35\1\uffff\2\35\1\uffff\1\121\1\122\5\35\1\130"+
+        "\2\35\1\uffff\1\35\1\uffff\1\35\1\uffff\5\35\2\uffff\1\140\1\35"+
+        "\1\142\1\143\1\35\1\uffff\1\35\1\111\5\35\1\uffff\1\35\2\uffff\1"+
+        "\35\1\143\1\155\4\35\1\162\1\35\1\uffff\1\35\1\165\1\35\1\167\1"+
+        "\uffff\2\35\1\uffff\1\35\1\uffff\1\173\2\35\1\uffff\2\35\1\u0080"+
+        "\1\u0081\2\uffff";
+    static final String DFA19_eofS =
+        "\u0082\uffff";
+    static final String DFA19_minS =
+        "\1\11\1\155\1\41\1\uffff\1\145\1\162\1\156\1\157\1\170\1\145\1\141"+
+        "\1\60\1\41\1\uffff\1\141\1\uffff\1\0\1\52\2\uffff\4\41\3\uffff\1"+
+        "\55\1\41\1\uffff\1\160\1\41\1\uffff\1\143\1\41\1\144\1\164\1\154"+
+        "\1\151\1\163\1\165\1\154\1\41\1\60\1\uffff\1\154\1\uffff\3\0\4\uffff"+
+        "\1\41\1\uffff\1\157\1\uffff\1\146\1\154\1\uffff\2\41\1\154\1\163"+
+        "\1\164\1\145\1\151\1\41\1\163\1\0\1\uffff\1\0\1\uffff\1\0\1\uffff"+
+        "\1\162\1\145\2\165\1\141\2\uffff\1\41\1\164\2\41\1\145\1\uffff\1"+
+        "\145\1\41\1\164\1\155\1\154\1\156\1\162\1\uffff\1\163\2\uffff\1"+
+        "\156\2\41\1\160\1\145\1\143\1\145\1\41\1\143\1\uffff\1\154\1\41"+
+        "\1\164\1\41\1\uffff\1\145\1\141\1\uffff\1\151\1\uffff\1\41\1\164"+
+        "\1\157\1\uffff\1\145\1\156\2\41\2\uffff";
+    static final String DFA19_maxS =
+        "\1\176\1\155\1\175\1\uffff\1\145\1\162\1\156\1\165\1\170\1\162\1"+
+        "\141\1\71\1\175\1\uffff\1\141\1\uffff\1\uffff\1\57\2\uffff\4\175"+
+        "\3\uffff\1\55\1\175\1\uffff\1\160\1\175\1\uffff\1\146\1\175\1\144"+
+        "\1\164\1\154\1\151\1\163\1\165\1\154\1\175\1\71\1\uffff\1\154\1"+
+        "\uffff\3\uffff\4\uffff\1\175\1\uffff\1\157\1\uffff\1\164\1\154\1"+
+        "\uffff\2\175\1\154\1\163\1\164\1\145\1\151\1\175\1\163\1\uffff\1"+
+        "\uffff\1\uffff\1\uffff\1\uffff\1\uffff\1\162\1\145\2\165\1\141\2"+
+        "\uffff\1\175\1\164\2\175\1\145\1\uffff\1\145\1\175\1\164\1\155\1"+
+        "\154\1\156\1\162\1\uffff\1\163\2\uffff\1\156\2\175\1\160\1\145\1"+
+        "\143\1\145\1\175\1\143\1\uffff\1\154\1\175\1\164\1\175\1\uffff\1"+
+        "\145\1\141\1\uffff\1\151\1\uffff\1\175\1\164\1\157\1\uffff\1\145"+
+        "\1\156\2\175\2\uffff";
+    static final String DFA19_acceptS =
+        "\3\uffff\1\3\11\uffff\1\21\1\uffff\1\23\2\uffff\1\26\1\27\4\uffff"+
+        "\1\34\1\35\1\36\2\uffff\1\43\2\uffff\1\41\13\uffff\1\17\1\uffff"+
+        "\1\24\3\uffff\1\30\1\31\1\32\1\33\1\uffff\1\40\1\uffff\1\2\2\uffff"+
+        "\1\7\12\uffff\1\25\1\uffff\1\42\1\uffff\1\37\5\uffff\1\10\1\11\5"+
+        "\uffff\1\20\7\uffff\1\14\1\uffff\1\13\1\22\11\uffff\1\1\4\uffff"+
+        "\1\12\2\uffff\1\5\1\uffff\1\15\3\uffff\1\16\4\uffff\1\4\1\6";
+    static final String DFA19_specialS =
+        "\20\uffff\1\5\36\uffff\1\0\1\4\1\1\24\uffff\1\2\1\uffff\1\3\1\uffff"+
+        "\1\6\67\uffff}>";
+    static final String[] DFA19_transitionS = {
+            "\2\3\1\uffff\2\3\22\uffff\1\3\1\35\1\15\1\20\2\35\1\31\1\15"+
+            "\1\22\1\23\3\35\1\13\1\35\1\21\12\14\1\34\1\uffff\1\33\1\2\1"+
+            "\35\1\17\33\35\1\24\1\35\1\25\2\35\1\uffff\1\6\2\35\1\4\1\10"+
+            "\1\16\2\35\1\1\4\35\1\7\1\5\3\35\1\12\1\11\6\35\1\26\1\32\1"+
+            "\27\1\30",
+            "\1\36",
+            "\1\35\1\uffff\3\35\4\uffff\21\35\2\uffff\1\35\1\37\41\35\1"+
+            "\uffff\33\35\1\uffff\1\35",
+            "",
+            "\1\41",
+            "\1\42",
+            "\1\43",
+            "\1\44\5\uffff\1\45",
+            "\1\46",
+            "\1\47\14\uffff\1\50",
+            "\1\51",
+            "\12\52",
+            "\1\35\1\uffff\3\35\4\uffff\4\35\1\53\1\35\12\52\1\35\2\uffff"+
+            "\43\35\1\uffff\33\35\1\uffff\1\35",
+            "",
+            "\1\55",
+            "",
+            "\41\56\1\57\1\56\3\57\4\56\21\57\2\56\43\57\1\56\33\57\1\56"+
+            "\1\57\uff82\56",
+            "\1\61\4\uffff\1\60",
+            "",
+            "",
+            "\1\35\1\uffff\3\35\4\uffff\21\35\2\uffff\43\35\1\uffff\33\35"+
+            "\1\uffff\1\35",
+            "\1\35\1\uffff\3\35\4\uffff\21\35\2\uffff\43\35\1\uffff\33\35"+
+            "\1\uffff\1\35",
+            "\1\35\1\uffff\3\35\4\uffff\21\35\2\uffff\43\35\1\uffff\33\35"+
+            "\1\uffff\1\35",
+            "\1\35\1\uffff\3\35\4\uffff\21\35\2\uffff\43\35\1\uffff\33\35"+
+            "\1\uffff\1\35",
+            "",
+            "",
+            "",
+            "\1\66",
+            "\1\35\1\uffff\3\35\4\uffff\21\35\2\uffff\43\35\1\uffff\33\35"+
+            "\1\uffff\1\35",
+            "",
+            "\1\70",
+            "\1\35\1\uffff\3\35\4\uffff\21\35\2\uffff\43\35\1\uffff\33\35"+
+            "\1\uffff\1\35",
+            "",
+            "\1\73\2\uffff\1\72",
+            "\1\35\1\uffff\3\35\4\uffff\21\35\2\uffff\43\35\1\uffff\33\35"+
+            "\1\uffff\1\35",
+            "\1\75",
+            "\1\76",
+            "\1\77",
+            "\1\100",
+            "\1\101",
+            "\1\102",
+            "\1\103",
+            "\1\35\1\uffff\3\35\4\uffff\4\35\1\53\1\35\12\52\1\35\2\uffff"+
+            "\43\35\1\uffff\33\35\1\uffff\1\35",
+            "\12\104",
+            "",
+            "\1\105",
+            "",
+            "\41\56\1\57\1\56\3\57\4\56\21\57\2\56\43\57\1\56\33\57\1\56"+
+            "\1\57\uff82\56",
+            "\41\107\1\106\1\107\3\106\4\107\21\106\2\107\43\106\1\107\33"+
+            "\106\1\107\1\106\uff82\107",
+            "\41\111\1\112\1\111\3\112\4\111\1\110\20\112\2\111\43\112\1"+
+            "\111\33\112\1\111\1\112\uff82\111",
+            "",
+            "",
+            "",
+            "",
+            "\1\35\1\uffff\3\35\4\uffff\21\35\2\uffff\43\35\1\uffff\33\35"+
+            "\1\uffff\1\35",
+            "",
+            "\1\114",
+            "",
+            "\1\117\13\uffff\1\116\1\uffff\1\115",
+            "\1\120",
+            "",
+            "\1\35\1\uffff\3\35\4\uffff\21\35\2\uffff\43\35\1\uffff\33\35"+
+            "\1\uffff\1\35",
+            "\1\35\1\uffff\3\35\4\uffff\21\35\2\uffff\43\35\1\uffff\33\35"+
+            "\1\uffff\1\35",
+            "\1\123",
+            "\1\124",
+            "\1\125",
+            "\1\126",
+            "\1\127",
+            "\1\35\1\uffff\3\35\4\uffff\6\35\12\104\1\35\2\uffff\43\35\1"+
+            "\uffff\33\35\1\uffff\1\35",
+            "\1\131",
+            "\41\107\1\106\1\107\3\106\4\107\21\106\2\107\43\106\1\107\33"+
+            "\106\1\107\1\106\uff82\107",
+            "",
+            "\41\111\1\112\1\111\3\112\4\111\1\110\4\112\1\132\13\112\2"+
+            "\111\43\112\1\111\33\112\1\111\1\112\uff82\111",
+            "",
+            "\41\111\1\112\1\111\3\112\4\111\1\110\20\112\2\111\43\112\1"+
+            "\111\33\112\1\111\1\112\uff82\111",
+            "",
+            "\1\133",
+            "\1\134",
+            "\1\135",
+            "\1\136",
+            "\1\137",
+            "",
+            "",
+            "\1\35\1\uffff\3\35\4\uffff\21\35\2\uffff\43\35\1\uffff\33\35"+
+            "\1\uffff\1\35",
+            "\1\141",
+            "\1\35\1\uffff\3\35\4\uffff\21\35\2\uffff\43\35\1\uffff\33\35"+
+            "\1\uffff\1\35",
+            "\1\35\1\uffff\3\35\4\uffff\21\35\2\uffff\43\35\1\uffff\33\35"+
+            "\1\uffff\1\35",
+            "\1\144",
+            "",
+            "\1\145",
+            "\1\112\1\uffff\3\112\4\uffff\1\110\20\112\2\uffff\43\112\1"+
+            "\uffff\33\112\1\uffff\1\112",
+            "\1\146",
+            "\1\147",
+            "\1\150",
+            "\1\151",
+            "\1\152",
+            "",
+            "\1\153",
+            "",
+            "",
+            "\1\154",
+            "\1\35\1\uffff\3\35\4\uffff\21\35\2\uffff\43\35\1\uffff\33\35"+
+            "\1\uffff\1\35",
+            "\1\35\1\uffff\3\35\4\uffff\21\35\2\uffff\43\35\1\uffff\33\35"+
+            "\1\uffff\1\35",
+            "\1\156",
+            "\1\157",
+            "\1\160",
+            "\1\161",
+            "\1\35\1\uffff\3\35\4\uffff\21\35\2\uffff\43\35\1\uffff\33\35"+
+            "\1\uffff\1\35",
+            "\1\163",
+            "",
+            "\1\164",
+            "\1\35\1\uffff\3\35\4\uffff\21\35\2\uffff\43\35\1\uffff\33\35"+
+            "\1\uffff\1\35",
+            "\1\166",
+            "\1\35\1\uffff\3\35\4\uffff\21\35\2\uffff\43\35\1\uffff\33\35"+
+            "\1\uffff\1\35",
+            "",
+            "\1\170",
+            "\1\171",
+            "",
+            "\1\172",
+            "",
+            "\1\35\1\uffff\3\35\4\uffff\21\35\2\uffff\43\35\1\uffff\33\35"+
+            "\1\uffff\1\35",
+            "\1\174",
+            "\1\175",
+            "",
+            "\1\176",
+            "\1\177",
+            "\1\35\1\uffff\3\35\4\uffff\21\35\2\uffff\43\35\1\uffff\33\35"+
+            "\1\uffff\1\35",
+            "\1\35\1\uffff\3\35\4\uffff\21\35\2\uffff\43\35\1\uffff\33\35"+
+            "\1\uffff\1\35",
+            "",
+            ""
+    };
+
+    static final short[] DFA19_eot = DFA.unpackEncodedString(DFA19_eotS);
+    static final short[] DFA19_eof = DFA.unpackEncodedString(DFA19_eofS);
+    static final char[] DFA19_min = DFA.unpackEncodedStringToUnsignedChars(DFA19_minS);
+    static final char[] DFA19_max = DFA.unpackEncodedStringToUnsignedChars(DFA19_maxS);
+    static final short[] DFA19_accept = DFA.unpackEncodedString(DFA19_acceptS);
+    static final short[] DFA19_special = DFA.unpackEncodedString(DFA19_specialS);
+    static final short[][] DFA19_transition;
+
+    static {
+        int numStates = DFA19_transitionS.length;
+        DFA19_transition = new short[numStates][];
+        for (int i=0; i<numStates; i++) {
+            DFA19_transition[i] = DFA.unpackEncodedString(DFA19_transitionS[i]);
+        }
+    }
+
+    class DFA19 extends DFA {
+
+        public DFA19(BaseRecognizer recognizer) {
+            this.recognizer = recognizer;
+            this.decisionNumber = 19;
+            this.eot = DFA19_eot;
+            this.eof = DFA19_eof;
+            this.min = DFA19_min;
+            this.max = DFA19_max;
+            this.accept = DFA19_accept;
+            this.special = DFA19_special;
+            this.transition = DFA19_transition;
+        }
+        public String getDescription() {
+            return "1:1: Tokens : ( T__45 | T__46 | WS | DEFTEMPLATE | DEFRULE | DEFFUNCTION | 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 );";
+        }
+        public int specialStateTransition(int s, IntStream _input) throws NoViableAltException {
+            IntStream input = _input;
+        	int _s = s;
+            switch ( s ) {
+                    case 0 : 
+                        int LA19_47 = input.LA(1);
+
+                        s = -1;
+                        if ( ((LA19_47>='\u0000' && LA19_47<=' ')||LA19_47=='\"'||(LA19_47>='&' && LA19_47<=')')||(LA19_47>=';' && LA19_47<='<')||LA19_47=='`'||LA19_47=='|'||(LA19_47>='~' && LA19_47<='\uFFFF')) ) {s = 46;}
+
+                        else if ( (LA19_47=='!'||(LA19_47>='#' && LA19_47<='%')||(LA19_47>='*' && LA19_47<=':')||(LA19_47>='=' && LA19_47<='_')||(LA19_47>='a' && LA19_47<='{')||LA19_47=='}') ) {s = 47;}
+
+                        else s = 29;
+
+                        if ( s>=0 ) return s;
+                        break;
+                    case 1 : 
+                        int LA19_49 = input.LA(1);
+
+                        s = -1;
+                        if ( (LA19_49=='*') ) {s = 72;}
+
+                        else if ( ((LA19_49>='\u0000' && LA19_49<=' ')||LA19_49=='\"'||(LA19_49>='&' && LA19_49<=')')||(LA19_49>=';' && LA19_49<='<')||LA19_49=='`'||LA19_49=='|'||(LA19_49>='~' && LA19_49<='\uFFFF')) ) {s = 73;}
+
+                        else if ( (LA19_49=='!'||(LA19_49>='#' && LA19_49<='%')||(LA19_49>='+' && LA19_49<=':')||(LA19_49>='=' && LA19_49<='_')||(LA19_49>='a' && LA19_49<='{')||LA19_49=='}') ) {s = 74;}
+
+                        else s = 29;
+
+                        if ( s>=0 ) return s;
+                        break;
+                    case 2 : 
+                        int LA19_70 = input.LA(1);
+
+                        s = -1;
+                        if ( (LA19_70=='!'||(LA19_70>='#' && LA19_70<='%')||(LA19_70>='*' && LA19_70<=':')||(LA19_70>='=' && LA19_70<='_')||(LA19_70>='a' && LA19_70<='{')||LA19_70=='}') ) {s = 70;}
+
+                        else if ( ((LA19_70>='\u0000' && LA19_70<=' ')||LA19_70=='\"'||(LA19_70>='&' && LA19_70<=')')||(LA19_70>=';' && LA19_70<='<')||LA19_70=='`'||LA19_70=='|'||(LA19_70>='~' && LA19_70<='\uFFFF')) ) {s = 71;}
+
+                        else s = 29;
+
+                        if ( s>=0 ) return s;
+                        break;
+                    case 3 : 
+                        int LA19_72 = input.LA(1);
+
+                        s = -1;
+                        if ( (LA19_72=='/') ) {s = 90;}
+
+                        else if ( (LA19_72=='*') ) {s = 72;}
+
+                        else if ( (LA19_72=='!'||(LA19_72>='#' && LA19_72<='%')||(LA19_72>='+' && LA19_72<='.')||(LA19_72>='0' && LA19_72<=':')||(LA19_72>='=' && LA19_72<='_')||(LA19_72>='a' && LA19_72<='{')||LA19_72=='}') ) {s = 74;}
+
+                        else if ( ((LA19_72>='\u0000' && LA19_72<=' ')||LA19_72=='\"'||(LA19_72>='&' && LA19_72<=')')||(LA19_72>=';' && LA19_72<='<')||LA19_72=='`'||LA19_72=='|'||(LA19_72>='~' && LA19_72<='\uFFFF')) ) {s = 73;}
+
+                        else s = 29;
+
+                        if ( s>=0 ) return s;
+                        break;
+                    case 4 : 
+                        int LA19_48 = input.LA(1);
+
+                        s = -1;
+                        if ( (LA19_48=='!'||(LA19_48>='#' && LA19_48<='%')||(LA19_48>='*' && LA19_48<=':')||(LA19_48>='=' && LA19_48<='_')||(LA19_48>='a' && LA19_48<='{')||LA19_48=='}') ) {s = 70;}
+
+                        else if ( ((LA19_48>='\u0000' && LA19_48<=' ')||LA19_48=='\"'||(LA19_48>='&' && LA19_48<=')')||(LA19_48>=';' && LA19_48<='<')||LA19_48=='`'||LA19_48=='|'||(LA19_48>='~' && LA19_48<='\uFFFF')) ) {s = 71;}
+
+                        else s = 29;
+
+                        if ( s>=0 ) return s;
+                        break;
+                    case 5 : 
+                        int LA19_16 = input.LA(1);
+
+                        s = -1;
+                        if ( ((LA19_16>='\u0000' && LA19_16<=' ')||LA19_16=='\"'||(LA19_16>='&' && LA19_16<=')')||(LA19_16>=';' && LA19_16<='<')||LA19_16=='`'||LA19_16=='|'||(LA19_16>='~' && LA19_16<='\uFFFF')) ) {s = 46;}
+
+                        else if ( (LA19_16=='!'||(LA19_16>='#' && LA19_16<='%')||(LA19_16>='*' && LA19_16<=':')||(LA19_16>='=' && LA19_16<='_')||(LA19_16>='a' && LA19_16<='{')||LA19_16=='}') ) {s = 47;}
+
+                        else s = 29;
+
+                        if ( s>=0 ) return s;
+                        break;
+                    case 6 : 
+                        int LA19_74 = input.LA(1);
+
+                        s = -1;
+                        if ( (LA19_74=='*') ) {s = 72;}
+
+                        else if ( (LA19_74=='!'||(LA19_74>='#' && LA19_74<='%')||(LA19_74>='+' && LA19_74<=':')||(LA19_74>='=' && LA19_74<='_')||(LA19_74>='a' && LA19_74<='{')||LA19_74=='}') ) {s = 74;}
+
+                        else if ( ((LA19_74>='\u0000' && LA19_74<=' ')||LA19_74=='\"'||(LA19_74>='&' && LA19_74<=')')||(LA19_74>=';' && LA19_74<='<')||LA19_74=='`'||LA19_74=='|'||(LA19_74>='~' && LA19_74<='\uFFFF')) ) {s = 73;}
+
+                        else s = 29;
+
+                        if ( s>=0 ) return s;
+                        break;
+            }
+            if (state.backtracking>0) {state.failed=true; return -1;}
+            NoViableAltException nvae =
+                new NoViableAltException(getDescription(), 19, _s, input);
+            error(nvae);
+            throw nvae;
+        }
+    }
+ 
+
+}
\ No newline at end of file

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/ClipsParser.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/ClipsParser.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/ClipsParser.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,2533 @@
+/**
+ * Copyright 2010 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.
+ */
+
+// $ANTLR 3.1.1 /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g 2008-11-24 17:53:58
+
+	package org.drools.clips;
+
+    import org.drools.clips.*;		
+    
+	import java.util.List;
+	import java.util.ArrayList;
+	import java.util.Iterator;
+	import java.util.HashMap;	
+	import java.util.Set;	
+	import java.util.HashSet;			
+	import java.util.StringTokenizer;
+	import org.drools.lang.descr.*;
+	import org.drools.lang.Location;	
+
+
+import org.antlr.runtime.*;
+import java.util.Stack;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+public class ClipsParser extends Parser {
+    public static final String[] tokenNames = new String[] {
+        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "LEFT_PAREN", "NAME", "RIGHT_PAREN", "DEFFUNCTION", "DEFRULE", "STRING", "SALIENCE", "INT", "AND", "OR", "NOT", "EXISTS", "TEST", "VAR", "ASSIGN_OP", "PIPE", "AMPERSAND", "TILDE", "COLON", "EQUALS", "FLOAT", "BOOL", "NULL", "DEFTEMPLATE", "EOL", "WS", "DECLARE", "EscapeSequence", "HexDigit", "UnicodeEscape", "OctalEscape", "SYMBOL_CHAR", "SH_STYLE_SINGLE_LINE_COMMENT", "C_STYLE_SINGLE_LINE_COMMENT", "LEFT_SQUARE", "RIGHT_SQUARE", "LEFT_CURLY", "RIGHT_CURLY", "MULTI_LINE_COMMENT", "SYMBOL", "FIRST_SYMBOL_CHAR", "'import'", "'=>'"
+    };
+    public static final int EXISTS=15;
+    public static final int DEFRULE=8;
+    public static final int SYMBOL_CHAR=35;
+    public static final int HexDigit=32;
+    public static final int FLOAT=24;
+    public static final int TILDE=21;
+    public static final int OR=13;
+    public static final int PIPE=19;
+    public static final int ASSIGN_OP=18;
+    public static final int AND=12;
+    public static final int T__46=46;
+    public static final int FIRST_SYMBOL_CHAR=44;
+    public static final int DEFTEMPLATE=27;
+    public static final int EscapeSequence=31;
+    public static final int INT=11;
+    public static final int SYMBOL=43;
+    public static final int LEFT_SQUARE=38;
+    public static final int SH_STYLE_SINGLE_LINE_COMMENT=36;
+    public static final int AMPERSAND=20;
+    public static final int DECLARE=30;
+    public static final int LEFT_CURLY=40;
+    public static final int LEFT_PAREN=4;
+    public static final int RIGHT_CURLY=41;
+    public static final int BOOL=25;
+    public static final int DEFFUNCTION=7;
+    public static final int WS=29;
+    public static final int STRING=9;
+    public static final int T__45=45;
+    public static final int VAR=17;
+    public static final int EQUALS=23;
+    public static final int UnicodeEscape=33;
+    public static final int EOF=-1;
+    public static final int NULL=26;
+    public static final int EOL=28;
+    public static final int COLON=22;
+    public static final int SALIENCE=10;
+    public static final int OctalEscape=34;
+    public static final int MULTI_LINE_COMMENT=42;
+    public static final int TEST=16;
+    public static final int NAME=5;
+    public static final int NOT=14;
+    public static final int RIGHT_PAREN=6;
+    public static final int RIGHT_SQUARE=39;
+    public static final int C_STYLE_SINGLE_LINE_COMMENT=37;
+
+    // delegates
+    // delegators
+
+
+        public ClipsParser(TokenStream input) {
+            this(input, new RecognizerSharedState());
+        }
+        public ClipsParser(TokenStream input, RecognizerSharedState state) {
+            super(input, state);
+             
+        }
+        
+
+    public String[] getTokenNames() { return ClipsParser.tokenNames; }
+    public String getGrammarFileName() { return "/Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.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 Location location = new Location( Location.LOCATION_UNKNOWN );	
+    	
+    	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 ( state.errorRecovery ) {
+    			//System.err.print("[SPURIOUS] ");
+    			return;
+    		}
+    		state.syntaxErrors++; // don't count spurious
+    		state.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+ FIXME
+                                                               "; 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) ) );
+            	}
+            }
+            
+        		void addTypeFieldDescr(LispForm lispForm, TypeDeclarationDescr typeDescr) {
+        	        if ( !(lispForm.getSExpressions()[0] instanceof SymbolLispAtom) ) {
+        	            throw new RuntimeException("should specify a slot");
+        	        }
+        	        
+        	        SymbolLispAtom slot = (SymbolLispAtom) lispForm.getSExpressions()[0];
+        	        if ( !"slot".equals( slot.getValue().trim() )) {
+        	            throw new RuntimeException("should specify a slot");
+        	        }
+        	        
+        	        if ( !(lispForm.getSExpressions()[1] instanceof SymbolLispAtom) ) {
+        	            throw new RuntimeException("should specify a slot name");
+        	        }
+        	        SymbolLispAtom slotName = (SymbolLispAtom) lispForm.getSExpressions()[1];
+        	        
+        	        if ( !(lispForm.getSExpressions()[2] instanceof LispForm) ) {
+        	            throw new RuntimeException("should specify a type");
+        	        }
+        	        
+        	        LispForm typeForm = (LispForm) lispForm.getSExpressions()[2];
+        	        if ( !(typeForm.getSExpressions()[0] instanceof SymbolLispAtom) ) {
+        	            throw new RuntimeException("should specify a type");
+        	        }
+        	        SymbolLispAtom type = (SymbolLispAtom) typeForm.getSExpressions()[0];
+        	        if ( !"type".equals( type.getValue().trim() )) {
+        	            throw new RuntimeException("should specify a type");
+        	        }                
+        	        
+        	        if ( !(typeForm.getSExpressions()[1] instanceof SymbolLispAtom) ) {
+        	            throw new RuntimeException("should specify a slot name");
+        	        }
+        	        SymbolLispAtom typeName = (SymbolLispAtom) typeForm.getSExpressions()[1];        
+        	        
+        	        TypeFieldDescr fieldDescr = new TypeFieldDescr(removeQuotes(slotName.getValue()), new PatternDescr(removeQuotes(typeName.getValue())));        
+        	        typeDescr.addField( fieldDescr );
+                }
+        		
+        		String removeQuotes(String string) {
+        		    return string.substring( 1, string.length() -1 );
+        		}
+          
+
+
+
+    // $ANTLR start "eval"
+    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:265:1: eval[ParserHandler handler] : (i= importDescr | f= deffunction | t= deftemplate | r= defrule | form= lisp_form )* ;
+    public final void eval(ParserHandler handler) throws RecognitionException {
+        ImportDescr i = null;
+
+        FunctionDescr f = null;
+
+        TypeDeclarationDescr t = null;
+
+        RuleDescr r = null;
+
+        LispForm form = null;
+
+
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:266:2: ( (i= importDescr | f= deffunction | t= deftemplate | r= defrule | form= lisp_form )* )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:267:5: (i= importDescr | f= deffunction | t= deftemplate | r= defrule | form= lisp_form )*
+            {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:267:5: (i= importDescr | f= deffunction | t= deftemplate | r= defrule | form= lisp_form )*
+            loop1:
+            do {
+                int alt1=6;
+                int LA1_0 = input.LA(1);
+
+                if ( (LA1_0==LEFT_PAREN) ) {
+                    switch ( input.LA(2) ) {
+                    case 45:
+                        {
+                        alt1=1;
+                        }
+                        break;
+                    case DEFFUNCTION:
+                        {
+                        alt1=2;
+                        }
+                        break;
+                    case DEFTEMPLATE:
+                        {
+                        alt1=3;
+                        }
+                        break;
+                    case DEFRULE:
+                        {
+                        alt1=4;
+                        }
+                        break;
+                    case NAME:
+                    case VAR:
+                        {
+                        alt1=5;
+                        }
+                        break;
+
+                    }
+
+                }
+
+
+                switch (alt1) {
+            	case 1 :
+            	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:267:10: i= importDescr
+            	    {
+            	    pushFollow(FOLLOW_importDescr_in_eval60);
+            	    i=importDescr();
+
+            	    state._fsp--;
+            	    if (state.failed) return ;
+            	    if ( state.backtracking==0 ) {
+            	       handler.importHandler( i ); 
+            	    }
+
+            	    }
+            	    break;
+            	case 2 :
+            	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:268:7: f= deffunction
+            	    {
+            	    pushFollow(FOLLOW_deffunction_in_eval71);
+            	    f=deffunction();
+
+            	    state._fsp--;
+            	    if (state.failed) return ;
+            	    if ( state.backtracking==0 ) {
+            	       handler.functionHandler( f ); 
+            	    }
+
+            	    }
+            	    break;
+            	case 3 :
+            	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:269:7: t= deftemplate
+            	    {
+            	    pushFollow(FOLLOW_deftemplate_in_eval84);
+            	    t=deftemplate();
+
+            	    state._fsp--;
+            	    if (state.failed) return ;
+            	    if ( state.backtracking==0 ) {
+            	       handler.templateHandler( t ); 
+            	    }
+
+            	    }
+            	    break;
+            	case 4 :
+            	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:270:7: r= defrule
+            	    {
+            	    pushFollow(FOLLOW_defrule_in_eval100);
+            	    r=defrule();
+
+            	    state._fsp--;
+            	    if (state.failed) return ;
+            	    if ( state.backtracking==0 ) {
+            	       handler.ruleHandler( r ); 
+            	    }
+
+            	    }
+            	    break;
+            	case 5 :
+            	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:271:7: form= lisp_form
+            	    {
+            	    pushFollow(FOLLOW_lisp_form_in_eval112);
+            	    form=lisp_form();
+
+            	    state._fsp--;
+            	    if (state.failed) return ;
+            	    if ( state.backtracking==0 ) {
+            	       handler.lispFormHandler( form ); 
+            	    }
+
+            	    }
+            	    break;
+
+            	default :
+            	    break loop1;
+                }
+            } while (true);
+
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return ;
+    }
+    // $ANTLR end "eval"
+
+
+    // $ANTLR start "importDescr"
+    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:288:1: importDescr returns [ImportDescr importDescr] : LEFT_PAREN 'import' importName= NAME RIGHT_PAREN ;
+    public final ImportDescr importDescr() throws RecognitionException {
+        ImportDescr importDescr = null;
+
+        Token importName=null;
+
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:289:2: ( LEFT_PAREN 'import' importName= NAME RIGHT_PAREN )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:289:4: LEFT_PAREN 'import' importName= NAME RIGHT_PAREN
+            {
+            match(input,LEFT_PAREN,FOLLOW_LEFT_PAREN_in_importDescr140); if (state.failed) return importDescr;
+            match(input,45,FOLLOW_45_in_importDescr142); if (state.failed) return importDescr;
+            importName=(Token)match(input,NAME,FOLLOW_NAME_in_importDescr146); if (state.failed) return importDescr;
+            if ( state.backtracking==0 ) {
+               importDescr = new ImportDescr( importName.getText() ); 
+            }
+            match(input,RIGHT_PAREN,FOLLOW_RIGHT_PAREN_in_importDescr150); if (state.failed) return importDescr;
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return importDescr;
+    }
+    // $ANTLR end "importDescr"
+
+
+    // $ANTLR start "deffunction"
+    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:338:1: deffunction returns [FunctionDescr functionDescr] : LEFT_PAREN t= DEFFUNCTION name= lisp_atom params= lisp_form (form= lisp_form )+ RIGHT_PAREN ;
+    public final FunctionDescr deffunction() throws RecognitionException {
+        FunctionDescr functionDescr = null;
+
+        Token t=null;
+        SExpression name = null;
+
+        LispForm params = null;
+
+        LispForm form = null;
+
+
+
+                List content = null;
+                functionDescr = null;
+            
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:343:2: ( LEFT_PAREN t= DEFFUNCTION name= lisp_atom params= lisp_form (form= lisp_form )+ RIGHT_PAREN )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:343:4: LEFT_PAREN t= DEFFUNCTION name= lisp_atom params= lisp_form (form= lisp_form )+ RIGHT_PAREN
+            {
+            match(input,LEFT_PAREN,FOLLOW_LEFT_PAREN_in_deffunction185); if (state.failed) return functionDescr;
+            t=(Token)match(input,DEFFUNCTION,FOLLOW_DEFFUNCTION_in_deffunction195); if (state.failed) return functionDescr;
+            pushFollow(FOLLOW_lisp_atom_in_deffunction205);
+            name=lisp_atom();
+
+            state._fsp--;
+            if (state.failed) return functionDescr;
+            pushFollow(FOLLOW_lisp_form_in_deffunction215);
+            params=lisp_form();
+
+            state._fsp--;
+            if (state.failed) return functionDescr;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:347:3: (form= lisp_form )+
+            int cnt2=0;
+            loop2:
+            do {
+                int alt2=2;
+                int LA2_0 = input.LA(1);
+
+                if ( (LA2_0==LEFT_PAREN) ) {
+                    alt2=1;
+                }
+
+
+                switch (alt2) {
+            	case 1 :
+            	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:347:4: form= lisp_form
+            	    {
+            	    pushFollow(FOLLOW_lisp_form_in_deffunction224);
+            	    form=lisp_form();
+
+            	    state._fsp--;
+            	    if (state.failed) return functionDescr;
+            	    if ( state.backtracking==0 ) {
+            	       if ( content == null ) content = new ArrayList(); content.add( form ); 
+            	    }
+
+            	    }
+            	    break;
+
+            	default :
+            	    if ( cnt2 >= 1 ) break loop2;
+            	    if (state.backtracking>0) {state.failed=true; return functionDescr;}
+                        EarlyExitException eee =
+                            new EarlyExitException(2, input);
+                        throw eee;
+                }
+                cnt2++;
+            } while (true);
+
+            match(input,RIGHT_PAREN,FOLLOW_RIGHT_PAREN_in_deffunction246); if (state.failed) return functionDescr;
+            if ( state.backtracking==0 ) {
+               functionDescr = FunctionHandlers.createFunctionDescr( name, params, content ); 
+            }
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return functionDescr;
+    }
+    // $ANTLR end "deffunction"
+
+
+    // $ANTLR start "defrule"
+    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:353:1: defrule returns [RuleDescr rule] : loc= LEFT_PAREN DEFRULE ruleName= NAME documentation= STRING ruleAttribute[rule] ( ce[lhs, declarations] )* '=>' list= rule_consequence RIGHT_PAREN ;
+    public final RuleDescr defrule() throws RecognitionException {
+        RuleDescr rule = null;
+
+        Token loc=null;
+        Token ruleName=null;
+        Token documentation=null;
+        List list = null;
+
+
+         
+        	        rule = null; 
+        	        AndDescr lhs = null;
+        	        PatternDescr colum = null;  
+                    Set declarations = null;  
+        	      
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:360:2: (loc= LEFT_PAREN DEFRULE ruleName= NAME documentation= STRING ruleAttribute[rule] ( ce[lhs, declarations] )* '=>' list= rule_consequence RIGHT_PAREN )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:360:4: loc= LEFT_PAREN DEFRULE ruleName= NAME documentation= STRING ruleAttribute[rule] ( ce[lhs, declarations] )* '=>' list= rule_consequence RIGHT_PAREN
+            {
+            loc=(Token)match(input,LEFT_PAREN,FOLLOW_LEFT_PAREN_in_defrule283); if (state.failed) return rule;
+            match(input,DEFRULE,FOLLOW_DEFRULE_in_defrule291); if (state.failed) return rule;
+            ruleName=(Token)match(input,NAME,FOLLOW_NAME_in_defrule295); if (state.failed) return rule;
+            if ( state.backtracking==0 ) {
+               	  			  		
+              	  		debug( "start rule: " + ruleName.getText() );
+              	  		String ruleStr = ruleName.getText();
+              	  		AttributeDescr module = null;
+
+              	        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.setNamespace( module.getValue() );
+              		    	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() );	
+              			
+              			rule.addAttribute( new AttributeDescr( "dialect", "clips") );	
+              			
+              			declarations = new HashSet();  											
+              		
+            }
+            documentation=(Token)match(input,STRING,FOLLOW_STRING_in_defrule307); if (state.failed) return rule;
+            if ( state.backtracking==0 ) {
+
+              	    	// do nothing here for now
+              		
+            }
+            pushFollow(FOLLOW_ruleAttribute_in_defrule313);
+            ruleAttribute(rule);
+
+            state._fsp--;
+            if (state.failed) return rule;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:401:3: ( ce[lhs, declarations] )*
+            loop3:
+            do {
+                int alt3=2;
+                int LA3_0 = input.LA(1);
+
+                if ( (LA3_0==LEFT_PAREN||LA3_0==VAR) ) {
+                    alt3=1;
+                }
+
+
+                switch (alt3) {
+            	case 1 :
+            	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:401:3: ce[lhs, declarations]
+            	    {
+            	    pushFollow(FOLLOW_ce_in_defrule321);
+            	    ce(lhs, declarations);
+
+            	    state._fsp--;
+            	    if (state.failed) return rule;
+
+            	    }
+            	    break;
+
+            	default :
+            	    break loop3;
+                }
+            } while (true);
+
+            match(input,46,FOLLOW_46_in_defrule330); if (state.failed) return rule;
+            pushFollow(FOLLOW_rule_consequence_in_defrule339);
+            list=rule_consequence();
+
+            state._fsp--;
+            if (state.failed) return rule;
+            if ( state.backtracking==0 ) {
+               rule.setConsequence( list ); 
+            }
+            match(input,RIGHT_PAREN,FOLLOW_RIGHT_PAREN_in_defrule347); if (state.failed) return rule;
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return rule;
+    }
+    // $ANTLR end "defrule"
+
+
+    // $ANTLR start "rule_consequence"
+    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:410:1: rule_consequence returns [List list] : (l= lisp_form )* ;
+    public final List rule_consequence() throws RecognitionException {
+        List list = null;
+
+        LispForm l = null;
+
+
+
+                list = null;
+            
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:414:5: ( (l= lisp_form )* )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:415:3: (l= lisp_form )*
+            {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:415:3: (l= lisp_form )*
+            loop4:
+            do {
+                int alt4=2;
+                int LA4_0 = input.LA(1);
+
+                if ( (LA4_0==LEFT_PAREN) ) {
+                    alt4=1;
+                }
+
+
+                switch (alt4) {
+            	case 1 :
+            	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:415:4: l= lisp_form
+            	    {
+            	    pushFollow(FOLLOW_lisp_form_in_rule_consequence379);
+            	    l=lisp_form();
+
+            	    state._fsp--;
+            	    if (state.failed) return list;
+            	    if ( state.backtracking==0 ) {
+            	       if ( list == null ) list = new ArrayList(); list.add( l ); 
+            	    }
+
+            	    }
+            	    break;
+
+            	default :
+            	    break loop4;
+                }
+            } while (true);
+
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return list;
+    }
+    // $ANTLR end "rule_consequence"
+
+
+    // $ANTLR start "ruleAttribute"
+    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:418:1: ruleAttribute[RuleDescr rule] : ( LEFT_PAREN 'declare' ( LEFT_PAREN d= salience RIGHT_PAREN )? RIGHT_PAREN )? ;
+    public final void ruleAttribute(RuleDescr rule) throws RecognitionException {
+        AttributeDescr d = null;
+
+
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:419:2: ( ( LEFT_PAREN 'declare' ( LEFT_PAREN d= salience RIGHT_PAREN )? RIGHT_PAREN )? )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:420:3: ( LEFT_PAREN 'declare' ( LEFT_PAREN d= salience RIGHT_PAREN )? RIGHT_PAREN )?
+            {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:420:3: ( LEFT_PAREN 'declare' ( LEFT_PAREN d= salience RIGHT_PAREN )? RIGHT_PAREN )?
+            int alt6=2;
+            int LA6_0 = input.LA(1);
+
+            if ( (LA6_0==LEFT_PAREN) ) {
+                int LA6_1 = input.LA(2);
+
+                if ( (LA6_1==DECLARE) ) {
+                    alt6=1;
+                }
+            }
+            switch (alt6) {
+                case 1 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:420:5: LEFT_PAREN 'declare' ( LEFT_PAREN d= salience RIGHT_PAREN )? RIGHT_PAREN
+                    {
+                    match(input,LEFT_PAREN,FOLLOW_LEFT_PAREN_in_ruleAttribute412); if (state.failed) return ;
+                    match(input,DECLARE,FOLLOW_DECLARE_in_ruleAttribute414); if (state.failed) return ;
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:421:4: ( LEFT_PAREN d= salience RIGHT_PAREN )?
+                    int alt5=2;
+                    int LA5_0 = input.LA(1);
+
+                    if ( (LA5_0==LEFT_PAREN) ) {
+                        alt5=1;
+                    }
+                    switch (alt5) {
+                        case 1 :
+                            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:421:6: LEFT_PAREN d= salience RIGHT_PAREN
+                            {
+                            match(input,LEFT_PAREN,FOLLOW_LEFT_PAREN_in_ruleAttribute421); if (state.failed) return ;
+                            pushFollow(FOLLOW_salience_in_ruleAttribute425);
+                            d=salience();
+
+                            state._fsp--;
+                            if (state.failed) return ;
+                            if ( state.backtracking==0 ) {
+                               rule.addAttribute( d ); 
+                            }
+                            match(input,RIGHT_PAREN,FOLLOW_RIGHT_PAREN_in_ruleAttribute429); if (state.failed) return ;
+
+                            }
+                            break;
+
+                    }
+
+                    match(input,RIGHT_PAREN,FOLLOW_RIGHT_PAREN_in_ruleAttribute436); if (state.failed) return ;
+
+                    }
+                    break;
+
+            }
+
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return ;
+    }
+    // $ANTLR end "ruleAttribute"
+
+
+    // $ANTLR start "salience"
+    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:425:1: salience returns [AttributeDescr d ] : loc= SALIENCE i= INT ;
+    public final AttributeDescr salience() throws RecognitionException {
+        AttributeDescr d = null;
+
+        Token loc=null;
+        Token i=null;
+
+
+        		d = null;
+        	
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:429:2: (loc= SALIENCE i= INT )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:430:3: loc= SALIENCE i= INT
+            {
+            loc=(Token)match(input,SALIENCE,FOLLOW_SALIENCE_in_salience466); if (state.failed) return d;
+            i=(Token)match(input,INT,FOLLOW_INT_in_salience470); if (state.failed) return d;
+            if ( state.backtracking==0 ) {
+
+              			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"
+    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:440:1: ce[ConditionalElementDescr in_ce, Set declarations] : ( and_ce[in_ce, declarations] | or_ce[in_ce, declarations] | not_ce[in_ce, declarations] | exists_ce[in_ce, declarations] | eval_ce[in_ce, declarations] | normal_pattern[in_ce, declarations] | bound_pattern[in_ce, declarations] ) ;
+    public final void ce(ConditionalElementDescr in_ce, Set declarations) throws RecognitionException {
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:441:2: ( ( and_ce[in_ce, declarations] | or_ce[in_ce, declarations] | not_ce[in_ce, declarations] | exists_ce[in_ce, declarations] | eval_ce[in_ce, declarations] | normal_pattern[in_ce, declarations] | bound_pattern[in_ce, declarations] ) )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:441:4: ( and_ce[in_ce, declarations] | or_ce[in_ce, declarations] | not_ce[in_ce, declarations] | exists_ce[in_ce, declarations] | eval_ce[in_ce, declarations] | normal_pattern[in_ce, declarations] | bound_pattern[in_ce, declarations] )
+            {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:441:4: ( and_ce[in_ce, declarations] | or_ce[in_ce, declarations] | not_ce[in_ce, declarations] | exists_ce[in_ce, declarations] | eval_ce[in_ce, declarations] | normal_pattern[in_ce, declarations] | bound_pattern[in_ce, declarations] )
+            int alt7=7;
+            int LA7_0 = input.LA(1);
+
+            if ( (LA7_0==LEFT_PAREN) ) {
+                switch ( input.LA(2) ) {
+                case AND:
+                    {
+                    alt7=1;
+                    }
+                    break;
+                case OR:
+                    {
+                    alt7=2;
+                    }
+                    break;
+                case NOT:
+                    {
+                    alt7=3;
+                    }
+                    break;
+                case EXISTS:
+                    {
+                    alt7=4;
+                    }
+                    break;
+                case TEST:
+                    {
+                    alt7=5;
+                    }
+                    break;
+                case NAME:
+                    {
+                    alt7=6;
+                    }
+                    break;
+                default:
+                    if (state.backtracking>0) {state.failed=true; return ;}
+                    NoViableAltException nvae =
+                        new NoViableAltException("", 7, 1, input);
+
+                    throw nvae;
+                }
+
+            }
+            else if ( (LA7_0==VAR) ) {
+                alt7=7;
+            }
+            else {
+                if (state.backtracking>0) {state.failed=true; return ;}
+                NoViableAltException nvae =
+                    new NoViableAltException("", 7, 0, input);
+
+                throw nvae;
+            }
+            switch (alt7) {
+                case 1 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:441:8: and_ce[in_ce, declarations]
+                    {
+                    pushFollow(FOLLOW_and_ce_in_ce496);
+                    and_ce(in_ce, declarations);
+
+                    state._fsp--;
+                    if (state.failed) return ;
+
+                    }
+                    break;
+                case 2 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:442:7: or_ce[in_ce, declarations]
+                    {
+                    pushFollow(FOLLOW_or_ce_in_ce506);
+                    or_ce(in_ce, declarations);
+
+                    state._fsp--;
+                    if (state.failed) return ;
+
+                    }
+                    break;
+                case 3 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:443:7: not_ce[in_ce, declarations]
+                    {
+                    pushFollow(FOLLOW_not_ce_in_ce515);
+                    not_ce(in_ce, declarations);
+
+                    state._fsp--;
+                    if (state.failed) return ;
+
+                    }
+                    break;
+                case 4 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:444:7: exists_ce[in_ce, declarations]
+                    {
+                    pushFollow(FOLLOW_exists_ce_in_ce524);
+                    exists_ce(in_ce, declarations);
+
+                    state._fsp--;
+                    if (state.failed) return ;
+
+                    }
+                    break;
+                case 5 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:445:8: eval_ce[in_ce, declarations]
+                    {
+                    pushFollow(FOLLOW_eval_ce_in_ce538);
+                    eval_ce(in_ce, declarations);
+
+                    state._fsp--;
+                    if (state.failed) return ;
+
+                    }
+                    break;
+                case 6 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:446:7: normal_pattern[in_ce, declarations]
+                    {
+                    pushFollow(FOLLOW_normal_pattern_in_ce552);
+                    normal_pattern(in_ce, declarations);
+
+                    state._fsp--;
+                    if (state.failed) return ;
+
+                    }
+                    break;
+                case 7 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:447:7: bound_pattern[in_ce, declarations]
+                    {
+                    pushFollow(FOLLOW_bound_pattern_in_ce561);
+                    bound_pattern(in_ce, declarations);
+
+                    state._fsp--;
+                    if (state.failed) return ;
+
+                    }
+                    break;
+
+            }
+
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return ;
+    }
+    // $ANTLR end "ce"
+
+
+    // $ANTLR start "and_ce"
+    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:451:1: and_ce[ConditionalElementDescr in_ce, Set declarations] : LEFT_PAREN AND ( ce[andDescr, declarations] )+ RIGHT_PAREN ;
+    public final void and_ce(ConditionalElementDescr in_ce, Set declarations) throws RecognitionException {
+
+                AndDescr andDescr= null;        
+            
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:455:2: ( LEFT_PAREN AND ( ce[andDescr, declarations] )+ RIGHT_PAREN )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:455:4: LEFT_PAREN AND ( ce[andDescr, declarations] )+ RIGHT_PAREN
+            {
+            match(input,LEFT_PAREN,FOLLOW_LEFT_PAREN_in_and_ce588); if (state.failed) return ;
+            match(input,AND,FOLLOW_AND_in_and_ce593); if (state.failed) return ;
+            if ( state.backtracking==0 ) {
+
+              	    	andDescr = new AndDescr();
+              			in_ce.addDescr( andDescr );
+              		
+            }
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:460:3: ( ce[andDescr, declarations] )+
+            int cnt8=0;
+            loop8:
+            do {
+                int alt8=2;
+                int LA8_0 = input.LA(1);
+
+                if ( (LA8_0==LEFT_PAREN||LA8_0==VAR) ) {
+                    alt8=1;
+                }
+
+
+                switch (alt8) {
+            	case 1 :
+            	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:460:3: ce[andDescr, declarations]
+            	    {
+            	    pushFollow(FOLLOW_ce_in_and_ce599);
+            	    ce(andDescr, declarations);
+
+            	    state._fsp--;
+            	    if (state.failed) return ;
+
+            	    }
+            	    break;
+
+            	default :
+            	    if ( cnt8 >= 1 ) break loop8;
+            	    if (state.backtracking>0) {state.failed=true; return ;}
+                        EarlyExitException eee =
+                            new EarlyExitException(8, input);
+                        throw eee;
+                }
+                cnt8++;
+            } while (true);
+
+            match(input,RIGHT_PAREN,FOLLOW_RIGHT_PAREN_in_and_ce608); if (state.failed) return ;
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return ;
+    }
+    // $ANTLR end "and_ce"
+
+
+    // $ANTLR start "or_ce"
+    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:464:1: or_ce[ConditionalElementDescr in_ce, Set declarations] : LEFT_PAREN OR ( ce[orDescr, declarations] )+ RIGHT_PAREN ;
+    public final void or_ce(ConditionalElementDescr in_ce, Set declarations) throws RecognitionException {
+
+                OrDescr orDescr= null;         
+            
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:468:2: ( LEFT_PAREN OR ( ce[orDescr, declarations] )+ RIGHT_PAREN )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:468:4: LEFT_PAREN OR ( ce[orDescr, declarations] )+ RIGHT_PAREN
+            {
+            match(input,LEFT_PAREN,FOLLOW_LEFT_PAREN_in_or_ce636); if (state.failed) return ;
+            match(input,OR,FOLLOW_OR_in_or_ce641); if (state.failed) return ;
+            if ( state.backtracking==0 ) {
+
+              	    	orDescr = new OrDescr();
+              			in_ce.addDescr( orDescr );
+              		
+            }
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:473:3: ( ce[orDescr, declarations] )+
+            int cnt9=0;
+            loop9:
+            do {
+                int alt9=2;
+                int LA9_0 = input.LA(1);
+
+                if ( (LA9_0==LEFT_PAREN||LA9_0==VAR) ) {
+                    alt9=1;
+                }
+
+
+                switch (alt9) {
+            	case 1 :
+            	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:473:3: ce[orDescr, declarations]
+            	    {
+            	    pushFollow(FOLLOW_ce_in_or_ce647);
+            	    ce(orDescr, declarations);
+
+            	    state._fsp--;
+            	    if (state.failed) return ;
+
+            	    }
+            	    break;
+
+            	default :
+            	    if ( cnt9 >= 1 ) break loop9;
+            	    if (state.backtracking>0) {state.failed=true; return ;}
+                        EarlyExitException eee =
+                            new EarlyExitException(9, input);
+                        throw eee;
+                }
+                cnt9++;
+            } while (true);
+
+            match(input,RIGHT_PAREN,FOLLOW_RIGHT_PAREN_in_or_ce656); if (state.failed) return ;
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return ;
+    }
+    // $ANTLR end "or_ce"
+
+
+    // $ANTLR start "not_ce"
+    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:477:1: not_ce[ConditionalElementDescr in_ce, Set declarations] : LEFT_PAREN NOT ce[notDescr, declarations] RIGHT_PAREN ;
+    public final void not_ce(ConditionalElementDescr in_ce, Set declarations) throws RecognitionException {
+
+                NotDescr notDescr= null;         
+            
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:481:2: ( LEFT_PAREN NOT ce[notDescr, declarations] RIGHT_PAREN )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:481:4: LEFT_PAREN NOT ce[notDescr, declarations] RIGHT_PAREN
+            {
+            match(input,LEFT_PAREN,FOLLOW_LEFT_PAREN_in_not_ce684); if (state.failed) return ;
+            match(input,NOT,FOLLOW_NOT_in_not_ce689); if (state.failed) return ;
+            if ( state.backtracking==0 ) {
+
+              			notDescr = new NotDescr();
+              		    in_ce.addDescr( notDescr );
+              		
+            }
+            pushFollow(FOLLOW_ce_in_not_ce695);
+            ce(notDescr, declarations);
+
+            state._fsp--;
+            if (state.failed) return ;
+            match(input,RIGHT_PAREN,FOLLOW_RIGHT_PAREN_in_not_ce703); if (state.failed) return ;
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return ;
+    }
+    // $ANTLR end "not_ce"
+
+
+    // $ANTLR start "exists_ce"
+    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:490:1: exists_ce[ConditionalElementDescr in_ce, Set declarations] : LEFT_PAREN EXISTS ce[existsDescr, declarations] RIGHT_PAREN ;
+    public final void exists_ce(ConditionalElementDescr in_ce, Set declarations) throws RecognitionException {
+
+                ExistsDescr existsDescr= null;        
+            
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:494:2: ( LEFT_PAREN EXISTS ce[existsDescr, declarations] RIGHT_PAREN )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:494:4: LEFT_PAREN EXISTS ce[existsDescr, declarations] RIGHT_PAREN
+            {
+            match(input,LEFT_PAREN,FOLLOW_LEFT_PAREN_in_exists_ce732); if (state.failed) return ;
+            match(input,EXISTS,FOLLOW_EXISTS_in_exists_ce737); if (state.failed) return ;
+            if ( state.backtracking==0 ) {
+
+              		    existsDescr = new ExistsDescr();
+              		    in_ce.addDescr( existsDescr );
+              		
+            }
+            pushFollow(FOLLOW_ce_in_exists_ce743);
+            ce(existsDescr, declarations);
+
+            state._fsp--;
+            if (state.failed) return ;
+            match(input,RIGHT_PAREN,FOLLOW_RIGHT_PAREN_in_exists_ce751); if (state.failed) return ;
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return ;
+    }
+    // $ANTLR end "exists_ce"
+
+
+    // $ANTLR start "eval_ce"
+    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:503:1: eval_ce[ConditionalElementDescr in_ce, Set declarations] : LEFT_PAREN TEST t= lisp_form RIGHT_PAREN ;
+    public final void eval_ce(ConditionalElementDescr in_ce, Set declarations) throws RecognitionException {
+        LispForm t = null;
+
+
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:504:2: ( LEFT_PAREN TEST t= lisp_form RIGHT_PAREN )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:504:4: LEFT_PAREN TEST t= lisp_form RIGHT_PAREN
+            {
+            match(input,LEFT_PAREN,FOLLOW_LEFT_PAREN_in_eval_ce770); if (state.failed) return ;
+            match(input,TEST,FOLLOW_TEST_in_eval_ce775); if (state.failed) return ;
+            pushFollow(FOLLOW_lisp_form_in_eval_ce782);
+            t=lisp_form();
+
+            state._fsp--;
+            if (state.failed) return ;
+            if ( state.backtracking==0 ) {
+               EvalDescr evalDescr = new EvalDescr(); evalDescr.setContent( t ); in_ce.addDescr( evalDescr ); 
+            }
+            match(input,RIGHT_PAREN,FOLLOW_RIGHT_PAREN_in_eval_ce792); if (state.failed) return ;
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return ;
+    }
+    // $ANTLR end "eval_ce"
+
+
+    // $ANTLR start "normal_pattern"
+    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:510:1: normal_pattern[ConditionalElementDescr in_ce, Set declarations] : LEFT_PAREN name= NAME ( field_constriant[top, declarations] )* RIGHT_PAREN ;
+    public final void normal_pattern(ConditionalElementDescr in_ce, Set declarations) throws RecognitionException {
+        Token name=null;
+
+
+                PatternDescr pattern = null;
+                ConditionalElementDescr top = null;
+            
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:515:2: ( LEFT_PAREN name= NAME ( field_constriant[top, declarations] )* RIGHT_PAREN )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:515:4: LEFT_PAREN name= NAME ( field_constriant[top, declarations] )* RIGHT_PAREN
+            {
+            match(input,LEFT_PAREN,FOLLOW_LEFT_PAREN_in_normal_pattern820); if (state.failed) return ;
+            name=(Token)match(input,NAME,FOLLOW_NAME_in_normal_pattern827); if (state.failed) return ;
+            if ( state.backtracking==0 ) {
+
+              			pattern = new PatternDescr(name.getText());
+              			in_ce.addDescr( pattern );
+              			top = pattern.getConstraint();
+              			
+              		
+            }
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:522:3: ( field_constriant[top, declarations] )*
+            loop10:
+            do {
+                int alt10=2;
+                int LA10_0 = input.LA(1);
+
+                if ( (LA10_0==LEFT_PAREN) ) {
+                    alt10=1;
+                }
+
+
+                switch (alt10) {
+            	case 1 :
+            	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:522:3: field_constriant[top, declarations]
+            	    {
+            	    pushFollow(FOLLOW_field_constriant_in_normal_pattern833);
+            	    field_constriant(top, declarations);
+
+            	    state._fsp--;
+            	    if (state.failed) return ;
+
+            	    }
+            	    break;
+
+            	default :
+            	    break loop10;
+                }
+            } while (true);
+
+            match(input,RIGHT_PAREN,FOLLOW_RIGHT_PAREN_in_normal_pattern843); if (state.failed) return ;
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return ;
+    }
+    // $ANTLR end "normal_pattern"
+
+
+    // $ANTLR start "bound_pattern"
+    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:528:1: bound_pattern[ConditionalElementDescr in_ce, Set declarations] : var= VAR ASSIGN_OP LEFT_PAREN name= NAME ( field_constriant[top, declarations] )* RIGHT_PAREN ;
+    public final void bound_pattern(ConditionalElementDescr in_ce, Set declarations) throws RecognitionException {
+        Token var=null;
+        Token name=null;
+
+
+                PatternDescr pattern = null;
+                String identifier = null;
+                ConditionalElementDescr top = null;        
+            
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:534:2: (var= VAR ASSIGN_OP LEFT_PAREN name= NAME ( field_constriant[top, declarations] )* RIGHT_PAREN )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:534:4: var= VAR ASSIGN_OP LEFT_PAREN name= NAME ( field_constriant[top, declarations] )* RIGHT_PAREN
+            {
+            var=(Token)match(input,VAR,FOLLOW_VAR_in_bound_pattern871); if (state.failed) return ;
+            if ( state.backtracking==0 ) {
+
+              			identifier = var.getText();
+              		
+            }
+            match(input,ASSIGN_OP,FOLLOW_ASSIGN_OP_in_bound_pattern877); if (state.failed) return ;
+            match(input,LEFT_PAREN,FOLLOW_LEFT_PAREN_in_bound_pattern879); if (state.failed) return ;
+            name=(Token)match(input,NAME,FOLLOW_NAME_in_bound_pattern883); if (state.failed) return ;
+            if ( state.backtracking==0 ) {
+
+              			pattern = new PatternDescr(name.getText());
+              			pattern.setIdentifier( identifier.replace( '?', '$') );
+              			in_ce.addDescr( pattern );
+              			top = pattern.getConstraint();				    
+              		
+            }
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:544:3: ( field_constriant[top, declarations] )*
+            loop11:
+            do {
+                int alt11=2;
+                int LA11_0 = input.LA(1);
+
+                if ( (LA11_0==LEFT_PAREN) ) {
+                    alt11=1;
+                }
+
+
+                switch (alt11) {
+            	case 1 :
+            	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:544:3: field_constriant[top, declarations]
+            	    {
+            	    pushFollow(FOLLOW_field_constriant_in_bound_pattern892);
+            	    field_constriant(top, declarations);
+
+            	    state._fsp--;
+            	    if (state.failed) return ;
+
+            	    }
+            	    break;
+
+            	default :
+            	    break loop11;
+                }
+            } while (true);
+
+            match(input,RIGHT_PAREN,FOLLOW_RIGHT_PAREN_in_bound_pattern899); if (state.failed) return ;
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return ;
+    }
+    // $ANTLR end "bound_pattern"
+
+
+    // $ANTLR start "field_constriant"
+    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:548:1: field_constriant[ConditionalElementDescr base, Set declarations] : LEFT_PAREN f= NAME or_restr_connective[top, base, fc, declarations] RIGHT_PAREN ;
+    public final void field_constriant(ConditionalElementDescr base, Set declarations) throws RecognitionException {
+        Token f=null;
+
+
+             	List list = new ArrayList();
+        		FieldBindingDescr fbd = null;
+        		FieldConstraintDescr fc = null;
+        		RestrictionConnectiveDescr top = null;		
+        		String op = "==";
+        	
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:556:2: ( LEFT_PAREN f= NAME or_restr_connective[top, base, fc, declarations] RIGHT_PAREN )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:557:3: LEFT_PAREN f= NAME or_restr_connective[top, base, fc, declarations] RIGHT_PAREN
+            {
+            match(input,LEFT_PAREN,FOLLOW_LEFT_PAREN_in_field_constriant930); if (state.failed) return ;
+            f=(Token)match(input,NAME,FOLLOW_NAME_in_field_constriant934); if (state.failed) return ;
+            if ( state.backtracking==0 ) {
+
+              			fc = new FieldConstraintDescr(f.getText());
+              			fc.setLocation( offset(f.getLine()), f.getCharPositionInLine() );
+              			fc.setStartCharacter( ((CommonToken)f).getStartIndex() );
+              			//base.addDescr( fc );    
+              			top = fc.getRestriction();		
+              		
+            }
+            pushFollow(FOLLOW_or_restr_connective_in_field_constriant949);
+            or_restr_connective(top, base, fc, declarations);
+
+            state._fsp--;
+            if (state.failed) return ;
+            if ( state.backtracking==0 ) {
+               if ( top.getRestrictions().size() != 0 ) {
+              		    base.insertBeforeLast( PredicateDescr.class, fc ); 
+              		  }
+              		
+            }
+            match(input,RIGHT_PAREN,FOLLOW_RIGHT_PAREN_in_field_constriant959); if (state.failed) return ;
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return ;
+    }
+    // $ANTLR end "field_constriant"
+
+
+    // $ANTLR start "or_restr_connective"
+    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:588:1: or_restr_connective[ RestrictionConnectiveDescr rcBase, ConditionalElementDescr ceBase, FieldConstraintDescr fcBase, Set declarations ] options {backtrack=true; } : and_restr_connective[or, ceBase, fcBase, declarations] ( options {backtrack=true; } : PIPE and_restr_connective[or, ceBase, fcBase, declarations] )* ;
+    public final void or_restr_connective(RestrictionConnectiveDescr rcBase, ConditionalElementDescr ceBase, FieldConstraintDescr fcBase, Set declarations) throws RecognitionException {
+
+        		RestrictionConnectiveDescr or = new RestrictionConnectiveDescr(RestrictionConnectiveDescr.OR);
+        	
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:595:2: ( and_restr_connective[or, ceBase, fcBase, declarations] ( options {backtrack=true; } : PIPE and_restr_connective[or, ceBase, fcBase, declarations] )* )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:596:3: and_restr_connective[or, ceBase, fcBase, declarations] ( options {backtrack=true; } : PIPE and_restr_connective[or, ceBase, fcBase, declarations] )*
+            {
+            pushFollow(FOLLOW_and_restr_connective_in_or_restr_connective998);
+            and_restr_connective(or, ceBase, fcBase, declarations);
+
+            state._fsp--;
+            if (state.failed) return ;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:597:3: ( options {backtrack=true; } : PIPE and_restr_connective[or, ceBase, fcBase, declarations] )*
+            loop12:
+            do {
+                int alt12=2;
+                int LA12_0 = input.LA(1);
+
+                if ( (LA12_0==PIPE) ) {
+                    alt12=1;
+                }
+
+
+                switch (alt12) {
+            	case 1 :
+            	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:599:6: PIPE and_restr_connective[or, ceBase, fcBase, declarations]
+            	    {
+            	    match(input,PIPE,FOLLOW_PIPE_in_or_restr_connective1022); if (state.failed) return ;
+            	    if ( state.backtracking==0 ) {
+
+            	      				location.setType(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR);
+            	      			
+            	    }
+            	    pushFollow(FOLLOW_and_restr_connective_in_or_restr_connective1032);
+            	    and_restr_connective(or, ceBase, fcBase, declarations);
+
+            	    state._fsp--;
+            	    if (state.failed) return ;
+
+            	    }
+            	    break;
+
+            	default :
+            	    break loop12;
+                }
+            } while (true);
+
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+
+            	        if( or.getRestrictions().size() == 1 ) {
+            	                rcBase.addOrMerge( (RestrictionDescr) or.getRestrictions().get( 0 ) );
+            	        } else if ( or.getRestrictions().size() > 1 ) {
+            	        	rcBase.addRestriction( or );
+            	        }
+            	
+        }
+        return ;
+    }
+    // $ANTLR end "or_restr_connective"
+
+
+    // $ANTLR start "and_restr_connective"
+    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:614:1: and_restr_connective[ RestrictionConnectiveDescr rcBase, ConditionalElementDescr ceBase, FieldConstraintDescr fcBase, Set declarations ] : restriction[and, ceBase, fcBase, declarations] ( AMPERSAND restriction[and, ceBase, fcBase, declarations] )* ;
+    public final void and_restr_connective(RestrictionConnectiveDescr rcBase, ConditionalElementDescr ceBase, FieldConstraintDescr fcBase, Set declarations) throws RecognitionException {
+
+        		RestrictionConnectiveDescr and = new RestrictionConnectiveDescr(RestrictionConnectiveDescr.AND);
+        	
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:618:2: ( restriction[and, ceBase, fcBase, declarations] ( AMPERSAND restriction[and, ceBase, fcBase, declarations] )* )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:619:3: restriction[and, ceBase, fcBase, declarations] ( AMPERSAND restriction[and, ceBase, fcBase, declarations] )*
+            {
+            pushFollow(FOLLOW_restriction_in_and_restr_connective1064);
+            restriction(and, ceBase, fcBase, declarations);
+
+            state._fsp--;
+            if (state.failed) return ;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:620:3: ( AMPERSAND restriction[and, ceBase, fcBase, declarations] )*
+            loop13:
+            do {
+                int alt13=2;
+                int LA13_0 = input.LA(1);
+
+                if ( (LA13_0==AMPERSAND) ) {
+                    alt13=1;
+                }
+
+
+                switch (alt13) {
+            	case 1 :
+            	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:620:5: AMPERSAND restriction[and, ceBase, fcBase, declarations]
+            	    {
+            	    match(input,AMPERSAND,FOLLOW_AMPERSAND_in_and_restr_connective1072); if (state.failed) return ;
+            	    pushFollow(FOLLOW_restriction_in_and_restr_connective1074);
+            	    restriction(and, ceBase, fcBase, declarations);
+
+            	    state._fsp--;
+            	    if (state.failed) return ;
+
+            	    }
+            	    break;
+
+            	default :
+            	    break loop13;
+                }
+            } while (true);
+
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+
+            	        if( and.getRestrictions().size() == 1) {
+            	                rcBase.addOrMerge( (RestrictionDescr) and.getRestrictions().get( 0 ) );
+            	        } else if ( and.getRestrictions().size() > 1 ) {
+            	        	rcBase.addRestriction( and );
+            	        }
+            	
+        }
+        return ;
+    }
+    // $ANTLR end "and_restr_connective"
+
+
+    // $ANTLR start "restriction"
+    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:639:1: restriction[RestrictionConnectiveDescr rc, ConditionalElementDescr base, FieldConstraintDescr fcBase, Set declarations ] : ( TILDE )? ( predicate_constraint[rc, op, base] | return_value_restriction[op, rc] | variable_restriction[op, rc, base, fcBase, declarations] | lc= literal_restriction ) ;
+    public final void restriction(RestrictionConnectiveDescr rc, ConditionalElementDescr base, FieldConstraintDescr fcBase, Set declarations) throws RecognitionException {
+        String lc = null;
+
+
+
+        			String op = "==";
+        	
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:643:2: ( ( TILDE )? ( predicate_constraint[rc, op, base] | return_value_restriction[op, rc] | variable_restriction[op, rc, base, fcBase, declarations] | lc= literal_restriction ) )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:643:4: ( TILDE )? ( predicate_constraint[rc, op, base] | return_value_restriction[op, rc] | variable_restriction[op, rc, base, fcBase, declarations] | lc= literal_restriction )
+            {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:643:4: ( TILDE )?
+            int alt14=2;
+            int LA14_0 = input.LA(1);
+
+            if ( (LA14_0==TILDE) ) {
+                alt14=1;
+            }
+            switch (alt14) {
+                case 1 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:643:5: TILDE
+                    {
+                    match(input,TILDE,FOLLOW_TILDE_in_restriction1107); if (state.failed) return ;
+                    if ( state.backtracking==0 ) {
+                      op = "!=";
+                    }
+
+                    }
+                    break;
+
+            }
+
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:644:3: ( predicate_constraint[rc, op, base] | return_value_restriction[op, rc] | variable_restriction[op, rc, base, fcBase, declarations] | lc= literal_restriction )
+            int alt15=4;
+            switch ( input.LA(1) ) {
+            case COLON:
+                {
+                alt15=1;
+                }
+                break;
+            case EQUALS:
+                {
+                alt15=2;
+                }
+                break;
+            case VAR:
+                {
+                alt15=3;
+                }
+                break;
+            case NAME:
+            case STRING:
+            case INT:
+            case FLOAT:
+            case BOOL:
+            case NULL:
+                {
+                alt15=4;
+                }
+                break;
+            default:
+                if (state.backtracking>0) {state.failed=true; return ;}
+                NoViableAltException nvae =
+                    new NoViableAltException("", 15, 0, input);
+
+                throw nvae;
+            }
+
+            switch (alt15) {
+                case 1 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:644:5: predicate_constraint[rc, op, base]
+                    {
+                    pushFollow(FOLLOW_predicate_constraint_in_restriction1123);
+                    predicate_constraint(rc, op, base);
+
+                    state._fsp--;
+                    if (state.failed) return ;
+
+                    }
+                    break;
+                case 2 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:645:7: return_value_restriction[op, rc]
+                    {
+                    pushFollow(FOLLOW_return_value_restriction_in_restriction1139);
+                    return_value_restriction(op, rc);
+
+                    state._fsp--;
+                    if (state.failed) return ;
+
+                    }
+                    break;
+                case 3 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:646:7: variable_restriction[op, rc, base, fcBase, declarations]
+                    {
+                    pushFollow(FOLLOW_variable_restriction_in_restriction1148);
+                    variable_restriction(op, rc, base, fcBase, declarations);
+
+                    state._fsp--;
+                    if (state.failed) return ;
+
+                    }
+                    break;
+                case 4 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:647:8: lc= literal_restriction
+                    {
+                    pushFollow(FOLLOW_literal_restriction_in_restriction1160);
+                    lc=literal_restriction();
+
+                    state._fsp--;
+                    if (state.failed) return ;
+                    if ( state.backtracking==0 ) {
+
+                           	    			rc.addRestriction( new LiteralRestrictionDescr(op, lc) );
+                      		      		op = "==";
+                      		        
+                    }
+
+                    }
+                    break;
+
+            }
+
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return ;
+    }
+    // $ANTLR end "restriction"
+
+
+    // $ANTLR start "predicate_constraint"
+    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:654:1: predicate_constraint[RestrictionConnectiveDescr rc, String op, ConditionalElementDescr base] : COLON t= lisp_form ;
+    public final void predicate_constraint(RestrictionConnectiveDescr rc, String op, ConditionalElementDescr base) throws RecognitionException {
+        LispForm t = null;
+
+
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:655:2: ( COLON t= lisp_form )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:655:4: COLON t= lisp_form
+            {
+            match(input,COLON,FOLLOW_COLON_in_predicate_constraint1193); if (state.failed) return ;
+            pushFollow(FOLLOW_lisp_form_in_predicate_constraint1199);
+            t=lisp_form();
+
+            state._fsp--;
+            if (state.failed) return ;
+            if ( state.backtracking==0 ) {
+               base.addDescr( new PredicateDescr( t ) ); 
+            }
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return ;
+    }
+    // $ANTLR end "predicate_constraint"
+
+
+    // $ANTLR start "return_value_restriction"
+    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:661:1: return_value_restriction[String op, RestrictionConnectiveDescr rc] : EQUALS t= lisp_form ;
+    public final void return_value_restriction(String op, RestrictionConnectiveDescr rc) throws RecognitionException {
+        LispForm t = null;
+
+
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:662:2: ( EQUALS t= lisp_form )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:662:4: EQUALS t= lisp_form
+            {
+            match(input,EQUALS,FOLLOW_EQUALS_in_return_value_restriction1218); if (state.failed) return ;
+            pushFollow(FOLLOW_lisp_form_in_return_value_restriction1225);
+            t=lisp_form();
+
+            state._fsp--;
+            if (state.failed) return ;
+            if ( state.backtracking==0 ) {
+              rc.addRestriction( new ReturnValueRestrictionDescr (op, t ) ); 
+            }
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return ;
+    }
+    // $ANTLR end "return_value_restriction"
+
+
+    // $ANTLR start "variable_restriction"
+    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:667:1: variable_restriction[String op, RestrictionConnectiveDescr rc, ConditionalElementDescr ceBase, FieldConstraintDescr fcBase, Set declarations ] : VAR ;
+    public final void variable_restriction(String op, RestrictionConnectiveDescr rc, ConditionalElementDescr ceBase, FieldConstraintDescr fcBase, Set declarations) throws RecognitionException {
+        Token VAR1=null;
+
+         String identifier = null;
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:669:2: ( VAR )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:669:4: VAR
+            {
+            VAR1=(Token)match(input,VAR,FOLLOW_VAR_in_variable_restriction1253); if (state.failed) return ;
+            if ( state.backtracking==0 ) {
+
+              	        identifier =  (VAR1!=null?VAR1.getText():null).replace( '?', '$');
+              	        if ( declarations.contains( identifier) ) {
+              				rc.addRestriction( new VariableRestrictionDescr(op, identifier ) );
+              		 	} else {
+              		 		FieldBindingDescr fbd = new FieldBindingDescr();
+              		 		fbd.setIdentifier( identifier );		
+              		 		fbd.setFieldName( fcBase.getFieldName() ); 		
+              		 		ceBase.addDescr( fbd );
+              		 		declarations.add( identifier );
+              		 	}
+              		
+            }
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return ;
+    }
+    // $ANTLR end "variable_restriction"
+
+
+    // $ANTLR start "literal_restriction"
+    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:684:1: literal_restriction returns [String text] : t= literal ;
+    public final String literal_restriction() throws RecognitionException {
+        String text = null;
+
+        String t = null;
+
+
+
+        		text = null;
+        	
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:688:2: (t= literal )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:689:6: t= literal
+            {
+            pushFollow(FOLLOW_literal_in_literal_restriction1286);
+            t=literal();
+
+            state._fsp--;
+            if (state.failed) return text;
+            if ( state.backtracking==0 ) {
+
+              	    	text = t;
+              	    
+            }
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return text;
+    }
+    // $ANTLR end "literal_restriction"
+
+
+    // $ANTLR start "lisp_form"
+    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:706:1: lisp_form returns [LispForm lispForm] : LEFT_PAREN (t= NAME | t= VAR ) (a= lisp_atom | l= lisp_form )* RIGHT_PAREN ;
+    public final LispForm lisp_form() throws RecognitionException {
+        LispForm lispForm = null;
+
+        Token t=null;
+        SExpression a = null;
+
+        LispForm l = null;
+
+
+
+                List list = new ArrayList();
+                lispForm = null;
+            
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:711:2: ( LEFT_PAREN (t= NAME | t= VAR ) (a= lisp_atom | l= lisp_form )* RIGHT_PAREN )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:711:4: LEFT_PAREN (t= NAME | t= VAR ) (a= lisp_atom | l= lisp_form )* RIGHT_PAREN
+            {
+            match(input,LEFT_PAREN,FOLLOW_LEFT_PAREN_in_lisp_form1314); if (state.failed) return lispForm;
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:713:3: (t= NAME | t= VAR )
+            int alt16=2;
+            int LA16_0 = input.LA(1);
+
+            if ( (LA16_0==NAME) ) {
+                alt16=1;
+            }
+            else if ( (LA16_0==VAR) ) {
+                alt16=2;
+            }
+            else {
+                if (state.backtracking>0) {state.failed=true; return lispForm;}
+                NoViableAltException nvae =
+                    new NoViableAltException("", 16, 0, input);
+
+                throw nvae;
+            }
+            switch (alt16) {
+                case 1 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:714:7: t= NAME
+                    {
+                    t=(Token)match(input,NAME,FOLLOW_NAME_in_lisp_form1331); if (state.failed) return lispForm;
+                    if ( state.backtracking==0 ) {
+                       list.add( new SymbolLispAtom( t.getText() ) ); 
+                    }
+
+                    }
+                    break;
+                case 2 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:716:7: t= VAR
+                    {
+                    t=(Token)match(input,VAR,FOLLOW_VAR_in_lisp_form1351); if (state.failed) return lispForm;
+                    if ( state.backtracking==0 ) {
+                       list.add( new VariableLispAtom( t.getText() ) ); 
+                    }
+
+                    }
+                    break;
+
+            }
+
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:718:3: (a= lisp_atom | l= lisp_form )*
+            loop17:
+            do {
+                int alt17=3;
+                int LA17_0 = input.LA(1);
+
+                if ( (LA17_0==NAME||LA17_0==STRING||LA17_0==INT||LA17_0==VAR||(LA17_0>=FLOAT && LA17_0<=NULL)) ) {
+                    alt17=1;
+                }
+                else if ( (LA17_0==LEFT_PAREN) ) {
+                    alt17=2;
+                }
+
+
+                switch (alt17) {
+            	case 1 :
+            	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:718:6: a= lisp_atom
+            	    {
+            	    pushFollow(FOLLOW_lisp_atom_in_lisp_form1374);
+            	    a=lisp_atom();
+
+            	    state._fsp--;
+            	    if (state.failed) return lispForm;
+            	    if ( state.backtracking==0 ) {
+            	       list.add( a ); 
+            	    }
+
+            	    }
+            	    break;
+            	case 2 :
+            	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:719:6: l= lisp_form
+            	    {
+            	    pushFollow(FOLLOW_lisp_form_in_lisp_form1385);
+            	    l=lisp_form();
+
+            	    state._fsp--;
+            	    if (state.failed) return lispForm;
+            	    if ( state.backtracking==0 ) {
+            	       list.add( l ); 
+            	    }
+
+            	    }
+            	    break;
+
+            	default :
+            	    break loop17;
+                }
+            } while (true);
+
+            match(input,RIGHT_PAREN,FOLLOW_RIGHT_PAREN_in_lisp_form1412); if (state.failed) return lispForm;
+            if ( state.backtracking==0 ) {
+               lispForm = new LispForm( ( SExpression[] ) list.toArray( new SExpression[ list.size () ] ) ); 
+            }
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return lispForm;
+    }
+    // $ANTLR end "lisp_form"
+
+
+    // $ANTLR start "lisp_atom"
+    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:725:1: lisp_atom returns [SExpression sExpression] : (t= VAR | t= STRING | t= FLOAT | t= INT | t= BOOL | t= NULL | t= NAME ) ;
+    public final SExpression lisp_atom() throws RecognitionException {
+        SExpression sExpression = null;
+
+        Token t=null;
+
+
+        		sExpression  =  null;		
+        	
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:729:2: ( (t= VAR | t= STRING | t= FLOAT | t= INT | t= BOOL | t= NULL | t= NAME ) )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:730:3: (t= VAR | t= STRING | t= FLOAT | t= INT | t= BOOL | t= NULL | t= NAME )
+            {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:730:3: (t= VAR | t= STRING | t= FLOAT | t= INT | t= BOOL | t= NULL | t= NAME )
+            int alt18=7;
+            switch ( input.LA(1) ) {
+            case VAR:
+                {
+                alt18=1;
+                }
+                break;
+            case STRING:
+                {
+                alt18=2;
+                }
+                break;
+            case FLOAT:
+                {
+                alt18=3;
+                }
+                break;
+            case INT:
+                {
+                alt18=4;
+                }
+                break;
+            case BOOL:
+                {
+                alt18=5;
+                }
+                break;
+            case NULL:
+                {
+                alt18=6;
+                }
+                break;
+            case NAME:
+                {
+                alt18=7;
+                }
+                break;
+            default:
+                if (state.backtracking>0) {state.failed=true; return sExpression;}
+                NoViableAltException nvae =
+                    new NoViableAltException("", 18, 0, input);
+
+                throw nvae;
+            }
+
+            switch (alt18) {
+                case 1 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:731:6: t= VAR
+                    {
+                    t=(Token)match(input,VAR,FOLLOW_VAR_in_lisp_atom1456); if (state.failed) return sExpression;
+                    if ( state.backtracking==0 ) {
+                       sExpression = new VariableLispAtom( t.getText() ); 
+                    }
+
+                    }
+                    break;
+                case 2 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:732:6: t= STRING
+                    {
+                    t=(Token)match(input,STRING,FOLLOW_STRING_in_lisp_atom1468); if (state.failed) return sExpression;
+                    if ( state.backtracking==0 ) {
+                       sExpression = new StringLispAtom( getString( t ) ); 
+                    }
+
+                    }
+                    break;
+                case 3 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:733:6: t= FLOAT
+                    {
+                    t=(Token)match(input,FLOAT,FOLLOW_FLOAT_in_lisp_atom1490); if (state.failed) return sExpression;
+                    if ( state.backtracking==0 ) {
+                       sExpression = new FloatLispAtom( t.getText() ); 
+                    }
+
+                    }
+                    break;
+                case 4 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:734:6: t= INT
+                    {
+                    t=(Token)match(input,INT,FOLLOW_INT_in_lisp_atom1502); if (state.failed) return sExpression;
+                    if ( state.backtracking==0 ) {
+                       sExpression = new IntLispAtom( t.getText() ); 
+                    }
+
+                    }
+                    break;
+                case 5 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:735:7: t= BOOL
+                    {
+                    t=(Token)match(input,BOOL,FOLLOW_BOOL_in_lisp_atom1515); if (state.failed) return sExpression;
+                    if ( state.backtracking==0 ) {
+                       sExpression = new BoolLispAtom( t.getText() ); 
+                    }
+
+                    }
+                    break;
+                case 6 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:736:7: t= NULL
+                    {
+                    t=(Token)match(input,NULL,FOLLOW_NULL_in_lisp_atom1531); if (state.failed) return sExpression;
+                    if ( state.backtracking==0 ) {
+                       sExpression = new NullLispAtom( null ); 
+                    }
+
+                    }
+                    break;
+                case 7 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:737:14: t= NAME
+                    {
+                    t=(Token)match(input,NAME,FOLLOW_NAME_in_lisp_atom1557); if (state.failed) return sExpression;
+                    if ( state.backtracking==0 ) {
+                       sExpression = new SymbolLispAtom( "\"" +t.getText() + "\""); 
+                    }
+
+                    }
+                    break;
+
+            }
+
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return sExpression;
+    }
+    // $ANTLR end "lisp_atom"
+
+
+    // $ANTLR start "deftemplate"
+    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:743:1: deftemplate returns [TypeDeclarationDescr typeDescr] : loc= LEFT_PAREN DEFTEMPLATE deftemplateName= NAME documentation= STRING (list= lisp_form )* RIGHT_PAREN ;
+    public final TypeDeclarationDescr deftemplate() throws RecognitionException {
+        TypeDeclarationDescr typeDescr = null;
+
+        Token loc=null;
+        Token deftemplateName=null;
+        Token documentation=null;
+        LispForm list = null;
+
+
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:744:5: (loc= LEFT_PAREN DEFTEMPLATE deftemplateName= NAME documentation= STRING (list= lisp_form )* RIGHT_PAREN )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:745:5: loc= LEFT_PAREN DEFTEMPLATE deftemplateName= NAME documentation= STRING (list= lisp_form )* RIGHT_PAREN
+            {
+            loc=(Token)match(input,LEFT_PAREN,FOLLOW_LEFT_PAREN_in_deftemplate1598); if (state.failed) return typeDescr;
+            match(input,DEFTEMPLATE,FOLLOW_DEFTEMPLATE_in_deftemplate1605); if (state.failed) return typeDescr;
+            deftemplateName=(Token)match(input,NAME,FOLLOW_NAME_in_deftemplate1609); if (state.failed) return typeDescr;
+            if ( state.backtracking==0 ) {
+               	  			  		
+              	  		debug( "start rule: " + deftemplateName.getText() );
+              	  		String templateStr = deftemplateName.getText();
+
+                          String mod = null;
+              	        if ( templateStr.indexOf("::") >= 0 ) {
+                              mod = templateStr.substring(0, templateStr.indexOf("::"));
+              	            templateStr = templateStr.substring(templateStr.indexOf("::")+2);
+              			}		    
+              		    
+              		    typeDescr = new TypeDeclarationDescr( templateStr );
+              		    if( mod != null ) {
+              		        typeDescr.setNamespace( mod );
+              		    }		    
+              		        
+              			typeDescr.setLocation( offset(loc.getLine()), loc.getCharPositionInLine() );
+              			typeDescr.setStartCharacter( ((CommonToken)loc).getStartIndex() ); 
+              		
+              											
+              		
+            }
+            documentation=(Token)match(input,STRING,FOLLOW_STRING_in_deftemplate1623); if (state.failed) return typeDescr;
+            if ( state.backtracking==0 ) {
+
+              		// do nothing here for now
+              	
+            }
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:783:2: (list= lisp_form )*
+            loop19:
+            do {
+                int alt19=2;
+                int LA19_0 = input.LA(1);
+
+                if ( (LA19_0==LEFT_PAREN) ) {
+                    alt19=1;
+                }
+
+
+                switch (alt19) {
+            	case 1 :
+            	    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:783:3: list= lisp_form
+            	    {
+            	    pushFollow(FOLLOW_lisp_form_in_deftemplate1645);
+            	    list=lisp_form();
+
+            	    state._fsp--;
+            	    if (state.failed) return typeDescr;
+            	    if ( state.backtracking==0 ) {
+            	       addTypeFieldDescr(list, typeDescr); 
+            	    }
+
+            	    }
+            	    break;
+
+            	default :
+            	    break loop19;
+                }
+            } while (true);
+
+            match(input,RIGHT_PAREN,FOLLOW_RIGHT_PAREN_in_deftemplate1656); if (state.failed) return typeDescr;
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return typeDescr;
+    }
+    // $ANTLR end "deftemplate"
+
+
+    // $ANTLR start "literal"
+    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:789:1: literal returns [String text] : (t= STRING | t= NAME | t= INT | t= FLOAT | t= BOOL | t= NULL ) ;
+    public final String literal() throws RecognitionException {
+        String text = null;
+
+        Token t=null;
+
+
+        		text = null;
+        	
+        try {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:793:2: ( (t= STRING | t= NAME | t= INT | t= FLOAT | t= BOOL | t= NULL ) )
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:793:4: (t= STRING | t= NAME | t= INT | t= FLOAT | t= BOOL | t= NULL )
+            {
+            // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:793:4: (t= STRING | t= NAME | t= INT | t= FLOAT | t= BOOL | t= NULL )
+            int alt20=6;
+            switch ( input.LA(1) ) {
+            case STRING:
+                {
+                alt20=1;
+                }
+                break;
+            case NAME:
+                {
+                alt20=2;
+                }
+                break;
+            case INT:
+                {
+                alt20=3;
+                }
+                break;
+            case FLOAT:
+                {
+                alt20=4;
+                }
+                break;
+            case BOOL:
+                {
+                alt20=5;
+                }
+                break;
+            case NULL:
+                {
+                alt20=6;
+                }
+                break;
+            default:
+                if (state.backtracking>0) {state.failed=true; return text;}
+                NoViableAltException nvae =
+                    new NoViableAltException("", 20, 0, input);
+
+                throw nvae;
+            }
+
+            switch (alt20) {
+                case 1 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:793:8: t= STRING
+                    {
+                    t=(Token)match(input,STRING,FOLLOW_STRING_in_literal1692); if (state.failed) return text;
+                    if ( state.backtracking==0 ) {
+                       text = getString( t ); 
+                    }
+
+                    }
+                    break;
+                case 2 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:794:7: t= NAME
+                    {
+                    t=(Token)match(input,NAME,FOLLOW_NAME_in_literal1705); if (state.failed) return text;
+                    if ( state.backtracking==0 ) {
+                       text = t.getText(); 
+                    }
+
+                    }
+                    break;
+                case 3 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:795:7: t= INT
+                    {
+                    t=(Token)match(input,INT,FOLLOW_INT_in_literal1721); if (state.failed) return text;
+                    if ( state.backtracking==0 ) {
+                       text = t.getText(); 
+                    }
+
+                    }
+                    break;
+                case 4 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:796:7: t= FLOAT
+                    {
+                    t=(Token)match(input,FLOAT,FOLLOW_FLOAT_in_literal1736); if (state.failed) return text;
+                    if ( state.backtracking==0 ) {
+                       text = t.getText(); 
+                    }
+
+                    }
+                    break;
+                case 5 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:797:7: t= BOOL
+                    {
+                    t=(Token)match(input,BOOL,FOLLOW_BOOL_in_literal1749); if (state.failed) return text;
+                    if ( state.backtracking==0 ) {
+                       text = t.getText(); 
+                    }
+
+                    }
+                    break;
+                case 6 :
+                    // /Users/porcelli/Documents/dev/drools-trunk/drools-clips/src/main/resources/org/drools/clips/Clips.g:798:7: t= NULL
+                    {
+                    t=(Token)match(input,NULL,FOLLOW_NULL_in_literal1763); if (state.failed) return text;
+                    if ( state.backtracking==0 ) {
+                       text = null; 
+                    }
+
+                    }
+                    break;
+
+            }
+
+
+            }
+
+        }
+        catch (RecognitionException re) {
+            reportError(re);
+            recover(input,re);
+        }
+        finally {
+        }
+        return text;
+    }
+    // $ANTLR end "literal"
+
+    // Delegated rules
+
+
+ 
+
+    public static final BitSet FOLLOW_importDescr_in_eval60 = new BitSet(new long[]{0x0000000000000012L});
+    public static final BitSet FOLLOW_deffunction_in_eval71 = new BitSet(new long[]{0x0000000000000012L});
+    public static final BitSet FOLLOW_deftemplate_in_eval84 = new BitSet(new long[]{0x0000000000000012L});
+    public static final BitSet FOLLOW_defrule_in_eval100 = new BitSet(new long[]{0x0000000000000012L});
+    public static final BitSet FOLLOW_lisp_form_in_eval112 = new BitSet(new long[]{0x0000000000000012L});
+    public static final BitSet FOLLOW_LEFT_PAREN_in_importDescr140 = new BitSet(new long[]{0x0000200000000000L});
+    public static final BitSet FOLLOW_45_in_importDescr142 = new BitSet(new long[]{0x0000000000000020L});
+    public static final BitSet FOLLOW_NAME_in_importDescr146 = new BitSet(new long[]{0x0000000000000040L});
+    public static final BitSet FOLLOW_RIGHT_PAREN_in_importDescr150 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_LEFT_PAREN_in_deffunction185 = new BitSet(new long[]{0x0000000000000080L});
+    public static final BitSet FOLLOW_DEFFUNCTION_in_deffunction195 = new BitSet(new long[]{0x0000000007020A20L});
+    public static final BitSet FOLLOW_lisp_atom_in_deffunction205 = new BitSet(new long[]{0x0000000000000050L});
+    public static final BitSet FOLLOW_lisp_form_in_deffunction215 = new BitSet(new long[]{0x0000000000000050L});
+    public static final BitSet FOLLOW_lisp_form_in_deffunction224 = new BitSet(new long[]{0x0000000000000050L});
+    public static final BitSet FOLLOW_RIGHT_PAREN_in_deffunction246 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_LEFT_PAREN_in_defrule283 = new BitSet(new long[]{0x0000000000000100L});
+    public static final BitSet FOLLOW_DEFRULE_in_defrule291 = new BitSet(new long[]{0x0000000000000020L});
+    public static final BitSet FOLLOW_NAME_in_defrule295 = new BitSet(new long[]{0x0000000000000200L});
+    public static final BitSet FOLLOW_STRING_in_defrule307 = new BitSet(new long[]{0x0000400000020010L});
+    public static final BitSet FOLLOW_ruleAttribute_in_defrule313 = new BitSet(new long[]{0x0000400000020010L});
+    public static final BitSet FOLLOW_ce_in_defrule321 = new BitSet(new long[]{0x0000400000020010L});
+    public static final BitSet FOLLOW_46_in_defrule330 = new BitSet(new long[]{0x0000000000000010L});
+    public static final BitSet FOLLOW_rule_consequence_in_defrule339 = new BitSet(new long[]{0x0000000000000040L});
+    public static final BitSet FOLLOW_RIGHT_PAREN_in_defrule347 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_lisp_form_in_rule_consequence379 = new BitSet(new long[]{0x0000000000000012L});
+    public static final BitSet FOLLOW_LEFT_PAREN_in_ruleAttribute412 = new BitSet(new long[]{0x0000000040000000L});
+    public static final BitSet FOLLOW_DECLARE_in_ruleAttribute414 = new BitSet(new long[]{0x0000000000000050L});
+    public static final BitSet FOLLOW_LEFT_PAREN_in_ruleAttribute421 = new BitSet(new long[]{0x0000000000000400L});
+    public static final BitSet FOLLOW_salience_in_ruleAttribute425 = new BitSet(new long[]{0x0000000000000040L});
+    public static final BitSet FOLLOW_RIGHT_PAREN_in_ruleAttribute429 = new BitSet(new long[]{0x0000000000000040L});
+    public static final BitSet FOLLOW_RIGHT_PAREN_in_ruleAttribute436 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_SALIENCE_in_salience466 = new BitSet(new long[]{0x0000000000000800L});
+    public static final BitSet FOLLOW_INT_in_salience470 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_and_ce_in_ce496 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_or_ce_in_ce506 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_not_ce_in_ce515 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_exists_ce_in_ce524 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_eval_ce_in_ce538 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_normal_pattern_in_ce552 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_bound_pattern_in_ce561 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_LEFT_PAREN_in_and_ce588 = new BitSet(new long[]{0x0000000000001000L});
+    public static final BitSet FOLLOW_AND_in_and_ce593 = new BitSet(new long[]{0x0000000000020010L});
+    public static final BitSet FOLLOW_ce_in_and_ce599 = new BitSet(new long[]{0x0000000000020050L});
+    public static final BitSet FOLLOW_RIGHT_PAREN_in_and_ce608 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_LEFT_PAREN_in_or_ce636 = new BitSet(new long[]{0x0000000000002000L});
+    public static final BitSet FOLLOW_OR_in_or_ce641 = new BitSet(new long[]{0x0000000000020010L});
+    public static final BitSet FOLLOW_ce_in_or_ce647 = new BitSet(new long[]{0x0000000000020050L});
+    public static final BitSet FOLLOW_RIGHT_PAREN_in_or_ce656 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_LEFT_PAREN_in_not_ce684 = new BitSet(new long[]{0x0000000000004000L});
+    public static final BitSet FOLLOW_NOT_in_not_ce689 = new BitSet(new long[]{0x0000000000020010L});
+    public static final BitSet FOLLOW_ce_in_not_ce695 = new BitSet(new long[]{0x0000000000000040L});
+    public static final BitSet FOLLOW_RIGHT_PAREN_in_not_ce703 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_LEFT_PAREN_in_exists_ce732 = new BitSet(new long[]{0x0000000000008000L});
+    public static final BitSet FOLLOW_EXISTS_in_exists_ce737 = new BitSet(new long[]{0x0000000000020010L});
+    public static final BitSet FOLLOW_ce_in_exists_ce743 = new BitSet(new long[]{0x0000000000000040L});
+    public static final BitSet FOLLOW_RIGHT_PAREN_in_exists_ce751 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_LEFT_PAREN_in_eval_ce770 = new BitSet(new long[]{0x0000000000010000L});
+    public static final BitSet FOLLOW_TEST_in_eval_ce775 = new BitSet(new long[]{0x0000000000000050L});
+    public static final BitSet FOLLOW_lisp_form_in_eval_ce782 = new BitSet(new long[]{0x0000000000000040L});
+    public static final BitSet FOLLOW_RIGHT_PAREN_in_eval_ce792 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_LEFT_PAREN_in_normal_pattern820 = new BitSet(new long[]{0x0000000000000020L});
+    public static final BitSet FOLLOW_NAME_in_normal_pattern827 = new BitSet(new long[]{0x0000000000000050L});
+    public static final BitSet FOLLOW_field_constriant_in_normal_pattern833 = new BitSet(new long[]{0x0000000000000050L});
+    public static final BitSet FOLLOW_RIGHT_PAREN_in_normal_pattern843 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_VAR_in_bound_pattern871 = new BitSet(new long[]{0x0000000000040000L});
+    public static final BitSet FOLLOW_ASSIGN_OP_in_bound_pattern877 = new BitSet(new long[]{0x0000000000000010L});
+    public static final BitSet FOLLOW_LEFT_PAREN_in_bound_pattern879 = new BitSet(new long[]{0x0000000000000020L});
+    public static final BitSet FOLLOW_NAME_in_bound_pattern883 = new BitSet(new long[]{0x0000000000000050L});
+    public static final BitSet FOLLOW_field_constriant_in_bound_pattern892 = new BitSet(new long[]{0x0000000000000050L});
+    public static final BitSet FOLLOW_RIGHT_PAREN_in_bound_pattern899 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_LEFT_PAREN_in_field_constriant930 = new BitSet(new long[]{0x0000000000000020L});
+    public static final BitSet FOLLOW_NAME_in_field_constriant934 = new BitSet(new long[]{0x0000000007E20A20L});
+    public static final BitSet FOLLOW_or_restr_connective_in_field_constriant949 = new BitSet(new long[]{0x0000000000000040L});
+    public static final BitSet FOLLOW_RIGHT_PAREN_in_field_constriant959 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_and_restr_connective_in_or_restr_connective998 = new BitSet(new long[]{0x0000000000080002L});
+    public static final BitSet FOLLOW_PIPE_in_or_restr_connective1022 = new BitSet(new long[]{0x0000000007E20A20L});
+    public static final BitSet FOLLOW_and_restr_connective_in_or_restr_connective1032 = new BitSet(new long[]{0x0000000000080002L});
+    public static final BitSet FOLLOW_restriction_in_and_restr_connective1064 = new BitSet(new long[]{0x0000000000100002L});
+    public static final BitSet FOLLOW_AMPERSAND_in_and_restr_connective1072 = new BitSet(new long[]{0x0000000007E20A20L});
+    public static final BitSet FOLLOW_restriction_in_and_restr_connective1074 = new BitSet(new long[]{0x0000000000100002L});
+    public static final BitSet FOLLOW_TILDE_in_restriction1107 = new BitSet(new long[]{0x0000000007E20A20L});
+    public static final BitSet FOLLOW_predicate_constraint_in_restriction1123 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_return_value_restriction_in_restriction1139 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_variable_restriction_in_restriction1148 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_literal_restriction_in_restriction1160 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_COLON_in_predicate_constraint1193 = new BitSet(new long[]{0x0000000000000010L});
+    public static final BitSet FOLLOW_lisp_form_in_predicate_constraint1199 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_EQUALS_in_return_value_restriction1218 = new BitSet(new long[]{0x0000000000000010L});
+    public static final BitSet FOLLOW_lisp_form_in_return_value_restriction1225 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_VAR_in_variable_restriction1253 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_literal_in_literal_restriction1286 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_LEFT_PAREN_in_lisp_form1314 = new BitSet(new long[]{0x0000000000020020L});
+    public static final BitSet FOLLOW_NAME_in_lisp_form1331 = new BitSet(new long[]{0x0000000007020A70L});
+    public static final BitSet FOLLOW_VAR_in_lisp_form1351 = new BitSet(new long[]{0x0000000007020A70L});
+    public static final BitSet FOLLOW_lisp_atom_in_lisp_form1374 = new BitSet(new long[]{0x0000000007020A70L});
+    public static final BitSet FOLLOW_lisp_form_in_lisp_form1385 = new BitSet(new long[]{0x0000000007020A70L});
+    public static final BitSet FOLLOW_RIGHT_PAREN_in_lisp_form1412 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_VAR_in_lisp_atom1456 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_STRING_in_lisp_atom1468 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_FLOAT_in_lisp_atom1490 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_INT_in_lisp_atom1502 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_BOOL_in_lisp_atom1515 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_NULL_in_lisp_atom1531 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_NAME_in_lisp_atom1557 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_LEFT_PAREN_in_deftemplate1598 = new BitSet(new long[]{0x0000000008000000L});
+    public static final BitSet FOLLOW_DEFTEMPLATE_in_deftemplate1605 = new BitSet(new long[]{0x0000000000000020L});
+    public static final BitSet FOLLOW_NAME_in_deftemplate1609 = new BitSet(new long[]{0x0000000000000200L});
+    public static final BitSet FOLLOW_STRING_in_deftemplate1623 = new BitSet(new long[]{0x0000000000000050L});
+    public static final BitSet FOLLOW_lisp_form_in_deftemplate1645 = new BitSet(new long[]{0x0000000000000050L});
+    public static final BitSet FOLLOW_RIGHT_PAREN_in_deftemplate1656 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_STRING_in_literal1692 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_NAME_in_literal1705 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_INT_in_literal1721 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_FLOAT_in_literal1736 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_BOOL_in_literal1749 = new BitSet(new long[]{0x0000000000000002L});
+    public static final BitSet FOLLOW_NULL_in_literal1763 = new BitSet(new long[]{0x0000000000000002L});
+
+}
\ No newline at end of file

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/ClipsShell.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/ClipsShell.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/ClipsShell.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,608 @@
+/**
+ * Copyright 2010 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.
+ */
+
+/**
+ *
+ */
+package org.drools.clips;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.io.PrintStream;
+import java.io.Reader;
+import java.io.Serializable;
+import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.antlr.runtime.ANTLRReaderStream;
+import org.antlr.runtime.CommonTokenStream;
+import org.drools.RuleBase;
+import org.drools.RuleBaseFactory;
+import org.drools.StatefulSession;
+import org.drools.base.ClassTypeResolver;
+import org.drools.base.mvel.DroolsMVELFactory;
+import org.drools.clips.functions.AssertFunction;
+import org.drools.clips.functions.BindFunction;
+import org.drools.clips.functions.CallFunction;
+import org.drools.clips.functions.CreateListFunction;
+import org.drools.clips.functions.EqFunction;
+import org.drools.clips.functions.GetFunction;
+import org.drools.clips.functions.IfFunction;
+import org.drools.clips.functions.LessThanFunction;
+import org.drools.clips.functions.LessThanOrEqFunction;
+import org.drools.clips.functions.MinusFunction;
+import org.drools.clips.functions.ModifyFunction;
+import org.drools.clips.functions.MoreThanFunction;
+import org.drools.clips.functions.MoreThanOrEqFunction;
+import org.drools.clips.functions.MultiplyFunction;
+import org.drools.clips.functions.NewFunction;
+import org.drools.clips.functions.PlusFunction;
+import org.drools.clips.functions.PrintoutFunction;
+import org.drools.clips.functions.PrognFunction;
+import org.drools.clips.functions.ReturnFunction;
+import org.drools.clips.functions.RunFunction;
+import org.drools.clips.functions.SetFunction;
+import org.drools.clips.functions.SwitchFunction;
+import org.drools.common.InternalRuleBase;
+import org.drools.compiler.PackageBuilder;
+import org.drools.lang.descr.AttributeDescr;
+import org.drools.lang.descr.FunctionDescr;
+import org.drools.lang.descr.ImportDescr;
+import org.drools.lang.descr.PackageDescr;
+import org.drools.lang.descr.RuleDescr;
+import org.drools.lang.descr.TypeDeclarationDescr;
+import org.drools.rule.ImportDeclaration;
+import org.drools.rule.MVELDialectRuntimeData;
+import org.drools.rule.Namespaceable;
+import org.drools.rule.Package;
+import org.drools.runtime.Globals;
+import org.drools.runtime.rule.FactHandle;
+import org.drools.spi.GlobalResolver;
+import org.mvel2.MVEL;
+import org.mvel2.ParserContext;
+import org.mvel2.compiler.ExpressionCompiler;
+
+/**
+ * An interactive Clips session shell.
+ * You can launch this as a Main class, no parameters are required.
+ * @author Michael Neale
+ *
+ */
+public class ClipsShell
+    implements
+    ParserHandler,
+    VariableContext,
+    FunctionContext,
+    PrintRouterContext {
+    private Map<String, Object> vars;
+
+    private PackageBuilder      packageBuilder;
+    private RuleBase            ruleBase;
+    private StatefulSession     session;
+
+    // private Map                 functions;
+
+    //    private Map                 directImports;
+    //    private Set                 dynamicImports;
+
+    private ClassTypeResolver   typeResolver;
+
+    private String              moduleName;
+    private static final String MAIN = "MAIN";
+
+    private DroolsMVELFactory   factory;
+
+    public ClipsShell() {
+        this( RuleBaseFactory.newRuleBase() );
+    }
+
+    public static void main(String[] args) throws Exception {
+
+
+        StringBuffer buf = new StringBuffer();
+        FunctionHandlers handlers = FunctionHandlers.getInstance();
+        handlers.registerFunction( new PlusFunction() );
+        handlers.registerFunction( new MinusFunction() );
+        handlers.registerFunction( new MultiplyFunction() );
+        handlers.registerFunction( new ModifyFunction() );
+        handlers.registerFunction( new CreateListFunction() );
+        handlers.registerFunction( new PrintoutFunction() );
+        handlers.registerFunction( new PrognFunction() );
+        handlers.registerFunction( new IfFunction() );
+        handlers.registerFunction( new LessThanFunction() );
+        handlers.registerFunction( new LessThanOrEqFunction() );
+        handlers.registerFunction( new MoreThanFunction() );
+        handlers.registerFunction( new MoreThanOrEqFunction() );
+        handlers.registerFunction( new EqFunction() );
+        handlers.registerFunction( new SwitchFunction() );
+        //handlers.registerFunction( new DeffunctionFunction() );
+        handlers.registerFunction( new ReturnFunction() );
+        handlers.registerFunction( new RunFunction() );
+        handlers.registerFunction( new BindFunction() );
+        handlers.registerFunction( new NewFunction() );
+        handlers.registerFunction( new SetFunction() );
+        handlers.registerFunction( new GetFunction() );
+        handlers.registerFunction( new CallFunction() );
+        handlers.registerFunction( new AssertFunction() );
+        ClipsShell shell = new ClipsShell();
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        shell.addRouter( "t", new PrintStream( out ) );
+
+        System.out.print("Drools>");
+
+        StringBuffer sessionLog = new StringBuffer();
+        while(true) {
+            byte name[] = new byte[256];
+
+	        System.in.read(name);
+	        String cmd = (new String(name)).trim();
+
+	        //System.out.println("ECHO:" + cmd);
+
+	        if (cmd.equals("(exit)") || cmd.equals("(quit)")) {
+	        	sessionLog.append(cmd);
+	        	break;
+	        }
+	        buf.append(cmd);
+
+	        if (isBalancedBrackets(buf)) {
+	        	String exp = buf.toString();
+	        	if (exp.startsWith("(save ")) {
+	        		String file = getFileName(exp);
+	        		System.out.println("Saving transcript to [" + file + "]");
+	        		writeFile(file, sessionLog);
+	        		sessionLog = new StringBuffer();
+	        		System.out.print("Drools>");
+	        	} else {
+	        		sessionLog.append(cmd + "\n");
+
+	        		if (exp.startsWith("(load ")) {
+	        			String file = getFileName(exp);
+	        			System.out.println("Loading transcript from [" + file + "]");
+	        			exp = loadFile(file);
+	        		}
+
+		        	shell.eval(exp);
+		        	String output = new String(out.toByteArray());
+		        	if (output != null && output.trim().length() > 0) {
+		        		System.out.println(output);
+		        	}
+		        	out.reset();
+		        	System.out.print("Drools>");
+		        	buf = new StringBuffer();
+	        	}
+	        }
+        }
+
+        System.out.println("Goodbye, and good luck !");
+
+    }
+
+	private static String loadFile(String fileName) throws IOException {
+		File f = new File(fileName);
+        InputStream is = new FileInputStream(f);
+
+        long length = f.length();
+        byte[] bytes = new byte[(int)length];
+
+        int offset = 0;
+        int numRead = 0;
+        while (offset < bytes.length
+               && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
+            offset += numRead;
+        }
+
+        if (offset < bytes.length) {
+            throw new IOException("Could not completely read file "+f.getName());
+        }
+
+        is.close();
+		return new String(bytes);
+	}
+
+	private static String getFileName(String exp) {
+		char qt = '\'';
+		if (exp.contains("\"")) {
+			qt = '"';
+		}
+		String file = exp.substring(exp.indexOf(qt) + 1, exp.lastIndexOf(qt));
+		return file;
+	}
+
+    private static void writeFile(String file, StringBuffer sessionLog) {
+    	FileOutputStream fout;
+		try {
+			File f = new File(file);
+			if (!f.exists()) {
+				f.createNewFile();
+			}
+			fout = new FileOutputStream(f);
+			fout.write(sessionLog.toString().getBytes());
+			fout.flush();
+			fout.close();
+		} catch (FileNotFoundException e) {
+			System.err.println("File " + file + " does not exist.");
+		} catch (IOException e) {
+			e.printStackTrace();
+		}
+
+
+	}
+
+	private static boolean isBalancedBrackets(StringBuffer buf) {
+		char[] cs = buf.toString().toCharArray();
+		int stack = 0;
+		for (int i = 0; i < cs.length; i++) {
+			if (cs[i] == '(') stack++;
+			if (cs[i] == ')') stack--;
+		}
+		return stack == 0;
+	}
+
+	public ClipsShell(RuleBase ruleBase) {
+        this.moduleName = MAIN;
+        this.ruleBase = ruleBase;
+
+        this.packageBuilder = new PackageBuilder( this.ruleBase );
+
+        this.session = this.ruleBase.newStatefulSession();
+        // this.functions = new HashMap();
+        //        this.directImports = new HashMap();
+        //        this.dynamicImports = new HashSet();
+
+        //        this.typeResolver = new ClassTypeResolver( new HashSet(),
+        //                                                   ((InternalRuleBase) this.ruleBase).getConfiguration().getClassLoader() );
+
+        this.factory = (DroolsMVELFactory) new DroolsMVELFactory( null,
+                                                                  null,
+                                                                  ((InternalRuleBase) this.ruleBase).getGlobals() );
+
+        this.vars = new HashMap<String, Object>();
+        GlobalResolver2 globalResolver = new GlobalResolver2( this.vars,
+                                                              this.session.getGlobalResolver() );
+        this.session.setGlobalResolver( globalResolver );
+
+        this.factory.setContext( null,
+                                 null,
+                                 null,
+                                 this.session,
+                                 this.vars );
+
+        addRouter( "t",
+                   System.out );
+    }
+
+    public StatefulSession getStatefulSession() {
+        return this.session;
+    }
+
+    public static class GlobalResolver2
+        implements
+        GlobalResolver {
+        private Map<String, Object> vars;
+        private GlobalResolver      delegate;
+
+        public GlobalResolver2() {
+        }
+
+        public GlobalResolver2(Map<String, Object> vars,
+                               GlobalResolver delegate) {
+            this.vars = vars;
+            this.delegate = delegate;
+        }
+
+        public void readExternal(ObjectInput in) throws IOException,
+                                                ClassNotFoundException {
+            vars = (Map<String, Object>) in.readObject();
+            delegate = (GlobalResolver) in.readObject();
+        }
+
+        public void writeExternal(ObjectOutput out) throws IOException {
+            out.writeObject( vars );
+            out.writeObject( delegate );
+        }
+
+        public Object resolveGlobal(String identifier) {
+            Object object = this.vars.get( identifier );
+            if ( object == null ) {
+                object = delegate.resolveGlobal( identifier );
+            }
+            return object;
+        }
+
+        public void setGlobal(String identifier,
+                              Object value) {
+            this.delegate.setGlobal( identifier,
+                                     value );
+        }
+    }
+
+    public void importHandler(ImportDescr descr) {
+        // use the current focus as the default namespace for these imports
+        PackageDescr pkgDescr = createPackageDescr( this.session.getAgenda().getFocusName() );
+        pkgDescr.addImport( descr );
+        this.packageBuilder.addPackage( pkgDescr );
+    }
+
+    public void functionHandler(FunctionDescr functionDescr) {
+        // for now all functions are in MAIN
+        //setModuleName( functionDescr );
+        functionDescr.setNamespace( "MAIN" );
+        Appendable builder = new StringBuilderAppendable();
+
+        // strip lead/trailing quotes
+        String name = functionDescr.getName().trim();
+        if ( name.charAt( 0 ) == '"' ) {
+            name = name.substring( 1 );
+        }
+
+        if ( name.charAt( name.length() - 1 ) == '"' ) {
+            name = name.substring( 0,
+                                   name.length() - 1 );
+        }
+        builder.append( "function " + name + "(" );
+
+        for ( int i = 0, length = functionDescr.getParameterNames().size(); i < length; i++ ) {
+            builder.append( functionDescr.getParameterNames().get( i ) );
+            if ( i < length - 1 ) {
+                builder.append( ", " );
+            }
+        }
+
+        builder.append( ") {\n" );
+        List list = (List) functionDescr.getContent();
+        for ( Iterator it = list.iterator(); it.hasNext(); ) {
+            FunctionHandlers.dump( (LispForm) it.next(),
+                                   builder, 
+                                   true );
+        }
+        builder.append( "}" );
+
+        functionDescr.setText( builder.toString() );
+        functionDescr.setDialect( "clips" );
+
+        PackageDescr pkgDescr = createPackageDescr( functionDescr.getNamespace() );
+        pkgDescr.addFunction( functionDescr );
+
+        this.packageBuilder.addPackage( pkgDescr );
+    }
+
+    public void lispFormHandler(LispForm lispForm) {
+        StringBuilderAppendable appendable = new StringBuilderAppendable();
+        FunctionHandlers.dump( lispForm,
+                               appendable,
+                               true );
+
+        ParserContext context = new ParserContext();
+        
+
+        String namespace = this.session.getAgenda().getFocusName();
+
+        Package pkg = this.ruleBase.getPackage( namespace );
+        if ( pkg == null ) {
+            this.packageBuilder.addPackage( createPackageDescr( namespace ) );
+            pkg = this.ruleBase.getPackage( namespace );
+            
+        }
+
+        if ( pkg != null ) {
+            // only time this will be null is if we have yet to do any packagedescr work
+
+            try {
+                for ( Iterator it = pkg.getImports().entrySet().iterator(); it.hasNext(); ) {
+                    Entry entry = (Entry) it.next();
+                    String importName = ((ImportDeclaration) entry.getValue()).getTarget();
+                    if ( importName.endsWith( "*" )) {
+                        context.addPackageImport( importName.substring( 0,
+                                                                        importName.length() - 2 ) );
+                    } else {
+                    	
+                        Class cls = ((InternalRuleBase)ruleBase).getRootClassLoader().loadClass( importName );
+                        context.addImport( cls.getSimpleName(),
+                                           (Class) cls );
+                    }
+                }
+
+            } catch ( Exception e ) {
+                e.printStackTrace();
+            }
+
+            MVELDialectRuntimeData data = (MVELDialectRuntimeData) pkg.getDialectRuntimeRegistry().getDialectData( "clips" );
+            this.factory.setNextFactory( data.getFunctionFactory() );
+        }
+
+        ClassLoader tempClassLoader = Thread.currentThread().getContextClassLoader();
+        Thread.currentThread().setContextClassLoader( ((InternalRuleBase)ruleBase).getRootClassLoader() );
+        
+        System.out.println( "mvel expr:" + appendable.toString() );
+        
+        ExpressionCompiler expr = new ExpressionCompiler( appendable.toString() );
+        Serializable executable = expr.compile( context );
+
+        MVEL.executeExpression( executable,
+                                this,
+                                this.factory );
+        Thread.currentThread().setContextClassLoader( tempClassLoader );
+    }
+
+    public void templateHandler(TypeDeclarationDescr typeDescr) {
+        setModuleName( typeDescr );
+
+        PackageDescr pkg = createPackageDescr( typeDescr.getNamespace() );
+        //pkg.addRule( ruleDescr );
+        pkg.addTypeDeclaration( typeDescr );
+
+        this.packageBuilder.addPackage( pkg );
+
+        //        try {
+        //            this.ruleBase.addPackage( builder.getPackage() );
+        //        } catch ( Exception e ) {
+        //            e.printStackTrace();
+        //        }
+    }
+
+    public void ruleHandler(RuleDescr ruleDescr) {
+        setModuleName( ruleDescr );
+        PackageDescr pkg = createPackageDescr( ruleDescr.getNamespace() );
+        pkg.addRule( ruleDescr );
+
+        this.packageBuilder.addPackage( pkg );
+
+        this.session.fireAllRules();
+
+        //        try {
+        //            this.ruleBase.addPackage( builder.getPackage() );
+        //        } catch ( Exception e ) {
+        //            e.printStackTrace();
+        //        }
+    }
+
+    public void setModuleName(Namespaceable namespaceable) {
+        // if the namespace is not set, set it to the current focus module
+        if ( isEmpty( namespaceable.getNamespace() ) ) {
+            namespaceable.setNamespace( this.session.getAgenda().getFocusName() );
+        }
+    }
+
+    public boolean isEmpty(String string) {
+        return (string == null || string.trim().length() == 0);
+    }
+
+    public void eval(String string) {
+        eval( new StringReader( string ) );
+    }
+
+    public void eval(Reader reader) {
+        ClipsParser parser;
+        try {
+            parser = new ClipsParser( new CommonTokenStream( new ClipsLexer( new ANTLRReaderStream( reader ) ) ) );
+            parser.eval( this );
+        } catch ( Exception e ) {
+            e.printStackTrace();
+        }
+    }
+
+    public void run() {
+        this.session.fireAllRules();
+    }
+
+    public void run(int fireLimit) {
+        this.session.fireAllRules( fireLimit );
+    }
+
+    public FactHandle insert(Object object) {
+        return this.session.insert( object );
+    }
+
+    public void importEntry(String importEntry) {
+
+    }
+
+    public void addFunction(Function function) {
+        this.factory.createVariable( function.getName(),
+                                     function );
+    }
+
+    public boolean removeFunction(String functionName) {
+        return false; //(this.vars.remove( functionName ) != null);
+    }
+
+    public Map<String, Function> getFunctions() {
+        Map<String, Function> map = new HashMap<String, Function>();
+        //        for ( Iterator it = this.vars.entrySet().iterator(); it.hasNext(); ) {
+        //            Entry entry = (Entry) it.next();
+        //            if ( entry.getValue() instanceof Function ) {
+        //                map.put( (String) entry.getKey(),
+        //                         (Function) entry.getValue() );
+        //            }
+        //        }
+        return map;
+    }
+
+    public void addRouter(String name,
+                          PrintStream out) {
+
+        Map routers = (Map) this.vars.get( "printrouters" );
+        if ( routers == null ) {
+            routers = new HashMap();
+            this.factory.createVariable( "printrouters",
+                                         routers );
+        }
+
+        routers.put( name,
+                     out );
+
+    }
+
+    public boolean removeRouter(String name) {
+        return false; //(this.vars.remove( name ) != null);
+    }
+
+    //    public Map<String, PrintStream> getRouters() {
+    //        Map<String, PrintStream> map = new HashMap<String, PrintStream>();
+    //        for ( Iterator it = this.vars.entrySet().iterator(); it.hasNext(); ) {
+    //            Entry entry = (Entry) it.next();
+    //            if ( entry.getValue() instanceof Function ) {
+    //                map.put( (String) entry.getKey(),
+    //                         (PrintStream) entry.getValue() );
+    //            }
+    //        }
+    //        return map;
+    //    }
+
+    public void addVariable(String name,
+                            Object value) {
+        if ( name.startsWith( "?" ) ) {
+            name = name.substring( 1 );
+        }
+        this.factory.createVariable( name,
+                                     value );
+        //        this.session.setGlobal( name,
+        //                                value );
+    }
+
+    //    public void removeVariable(String name) {
+    //        String temp = this.varNameMap.get( name );
+    //        if ( temp != null ) {
+    //            name = temp;
+    //        }
+    //        this.session.getGlobal( identifier ).remove( name );
+    //    }
+
+    private PackageDescr createPackageDescr(String moduleName) {
+        PackageDescr pkg = new PackageDescr( moduleName );
+        pkg.addAttribute( new AttributeDescr( "dialect",
+                                              "clips" ) );
+
+        //        for ( Iterator it = this.typeResolver.getImports().iterator(); it.hasNext(); ) {
+        //            pkg.addImport( new ImportDescr( (String) it.next() ) );
+        //        }
+
+        return pkg;
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/FloatLispAtom.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/FloatLispAtom.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/FloatLispAtom.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,28 @@
+/**
+ * Copyright 2010 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.
+ */
+
+/**
+ * 
+ */
+package org.drools.clips;
+
+public class FloatLispAtom extends LispAtom {
+    
+    public FloatLispAtom(String value) {
+        super(value);
+    }
+    
+}
\ No newline at end of file

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/Function.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/Function.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/Function.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,25 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips;
+
+public interface Function {
+
+    public abstract String getName();
+
+    public abstract void dump(LispForm lispForm, Appendable appendable);
+
+}
\ No newline at end of file

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/FunctionContext.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/FunctionContext.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/FunctionContext.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,29 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips;
+
+import java.util.Map;
+
+public interface FunctionContext {
+
+    public abstract void addFunction(Function function);
+
+    public abstract boolean removeFunction(String functionName);
+
+    public abstract Map<String, Function> getFunctions();
+
+}
\ No newline at end of file

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/FunctionHandlers.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/FunctionHandlers.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/FunctionHandlers.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,99 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.lang.descr.FunctionDescr;
+
+public class FunctionHandlers {
+    public static final FunctionHandlers INSTANCE = new FunctionHandlers();
+    
+    public static FunctionHandlers getInstance() {
+        return INSTANCE;
+    }
+    
+    private Map<String, Function> map = new HashMap<String, Function>();
+    
+    private FunctionHandlers() {
+        
+    }
+    
+    public Function getFunction(String name) {
+        return this.map.get( name );
+    }
+    
+    public void registerFunction(Function function) {
+        this.map.put( function.getName(), function );
+    }
+    public static void dump(SExpression sExpression, Appendable appendable) {
+        dump(sExpression,
+             appendable,
+             false);
+    }
+    public static void dump(SExpression sExpression, Appendable appendable, boolean root) {              
+        if ( sExpression instanceof LispAtom ) {
+            appendable.append( ( ( LispAtom ) sExpression).getValue() );
+        } else {
+            LispForm form = (LispForm) sExpression;
+            String functionName =  ( (LispAtom) form.getSExpressions()[0]).getValue();
+            Function function = FunctionHandlers.getInstance().getFunction( functionName );
+            if ( function != null ) {
+                function.dump(form, appendable );                
+            } else if ( form.getSExpressions()[0] instanceof VariableLispAtom ){
+                // try and execute this as a java call
+                function = FunctionHandlers.getInstance().getFunction( "call" );
+                function.dump(form, appendable );                
+            } else {
+                // execute as user function
+                appendable.append( functionName + "(" );
+                for ( int i = 1, length = form.getSExpressions().length; i < length; i++ ) {
+                    dump( form.getSExpressions()[i], appendable, false );
+                    if ( i < length -1 ) {
+                        appendable.append( ", " );
+                    }
+                }
+                appendable.append( ")" );                
+            }
+        }    
+        if ( root ) {
+            appendable.append( ";\n" );
+        }
+    }
+    
+    public static FunctionDescr createFunctionDescr(SExpression name, LispForm params, List<SExpression> content) {
+        FunctionDescr descr = new FunctionDescr(((LispAtom)name).getValue(), "Object" );
+        for ( SExpression sExpr  : params.getSExpressions() ) {
+            String param = ((LispAtom)sExpr).getValue().trim();
+            if ( param.charAt( 0 ) == '"' ) {
+                param = param.substring( 1 );
+            }
+            
+            if ( param.charAt( param.length()-1 ) == '"' ) {
+                param = param.substring( 0, param.length()-1 );
+            }
+            descr.addParameter(  "Object",  param );
+        }
+        
+        descr.setContent( content );
+        
+        return descr;
+    }
+    
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/GeneralParseException.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/GeneralParseException.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/GeneralParseException.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,39 @@
+/**
+ * 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.
+ */
+
+package org.drools.clips;
+
+import org.antlr.runtime.RecognitionException;
+
+public class GeneralParseException extends RecognitionException {
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 510l;
+    private String            message;
+
+    public GeneralParseException(final String message,
+                                 final int line) {
+        this.message = message;
+        this.line = line;
+    }
+
+    public String getMessage() {
+        return this.message;
+    }
+
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/IntLispAtom.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/IntLispAtom.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/IntLispAtom.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,28 @@
+/**
+ * Copyright 2010 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.
+ */
+
+/**
+ * 
+ */
+package org.drools.clips;
+
+public class IntLispAtom extends LispAtom {
+    
+    public IntLispAtom(String value) {
+        super(value);
+    }
+    
+}
\ No newline at end of file

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/LispAtom.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/LispAtom.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/LispAtom.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,40 @@
+/**
+ * Copyright 2010 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.
+ */
+
+/**
+ * 
+ */
+package org.drools.clips;
+
+public class LispAtom implements SExpression {
+    private String value;
+
+    public LispAtom(String value) {
+        this.value = value;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }    
+    
+    public String toString() {
+        return value;
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/LispForm.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/LispForm.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/LispForm.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,65 @@
+/**
+ * Copyright 2010 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.
+ */
+
+/**
+ * 
+ */
+package org.drools.clips;
+
+public class LispForm
+ implements SExpression {
+    private SExpression[] sExpressions;
+    
+    public LispForm(SExpression[] sExpressions) {
+        this.sExpressions = sExpressions;
+    }
+
+    public SExpression[] getSExpressions() {
+        return sExpressions;
+    }
+
+    public void setSExpressions(SExpression[] sExpressions) {
+        this.sExpressions = sExpressions;
+    }
+    
+//    public String toString() {
+//        StringBuilder builder = new StringBuilder();
+//        
+//        builder.append("(");
+//        for ( int i = 0, length = sExpressions.length; i < length; i++) {
+//            builder.append(" " + sExpressions[i] + " ");
+//        }
+//        builder.append(")");
+//        return builder.toString();
+//    }    
+    public int size() {
+        return this.sExpressions.length;
+    }
+    public String toString() {
+        StringBuilder builder = new StringBuilder();
+        
+        builder.append("(");
+        for ( int i = 0, length = sExpressions.length; i < length; i++ ) {
+            builder.append(sExpressions[i]);
+            if ( i < length - 1 ) {
+                builder.append( " " );
+            }
+        }
+        builder.append(")");
+        return builder.toString();
+    }  
+    
+}
\ No newline at end of file

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/NullLispAtom.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/NullLispAtom.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/NullLispAtom.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,28 @@
+/**
+ * Copyright 2010 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.
+ */
+
+/**
+ * 
+ */
+package org.drools.clips;
+
+public class NullLispAtom extends LispAtom {
+    
+    public NullLispAtom(String value) {
+        super(value);
+    }
+    
+}
\ No newline at end of file

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/ParserHandler.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/ParserHandler.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/ParserHandler.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,35 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips;
+
+import org.drools.lang.descr.FunctionDescr;
+import org.drools.lang.descr.ImportDescr;
+import org.drools.lang.descr.RuleDescr;
+import org.drools.lang.descr.TypeDeclarationDescr;
+
+public interface ParserHandler {  
+    
+    public void importHandler(ImportDescr descr);
+    
+    public void functionHandler(FunctionDescr ruleDescr);
+    
+    public void templateHandler(TypeDeclarationDescr typeDescr);
+    
+    public void ruleHandler(RuleDescr ruleDescr);
+    
+    public void lispFormHandler(LispForm lispForm);  
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/PrintRouterContext.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/PrintRouterContext.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/PrintRouterContext.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,29 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips;
+
+import java.io.PrintStream;
+
+public interface PrintRouterContext {
+
+    public abstract void addRouter(String name, PrintStream out);
+
+    public abstract boolean removeRouter(String name);
+
+//    public abstract Map<String, PrintStream> getRouters();
+
+}
\ No newline at end of file

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/SExpression.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/SExpression.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/SExpression.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,24 @@
+/**
+ * Copyright 2010 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.
+ */
+
+/**
+ * 
+ */
+package org.drools.clips;
+
+public interface SExpression {
+    
+}
\ No newline at end of file

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/StringBuilderAppendable.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/StringBuilderAppendable.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/StringBuilderAppendable.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips;
+
+public class StringBuilderAppendable implements Appendable {
+    public StringBuilder builder = new StringBuilder();
+    
+
+    public void append(String string) {
+        this.builder.append(  string );
+    }
+    
+    public String toString() {
+        return builder.toString();
+    }
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/StringLispAtom.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/StringLispAtom.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/StringLispAtom.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,29 @@
+/**
+ * Copyright 2010 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.
+ */
+
+/**
+ * 
+ */
+package org.drools.clips;
+
+public class StringLispAtom extends LispAtom {
+    
+    public StringLispAtom(String value) {
+        super("\"" + value + "\"");
+    }
+    
+    
+}
\ No newline at end of file

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/SymbolLispAtom.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/SymbolLispAtom.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/SymbolLispAtom.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,28 @@
+/**
+ * Copyright 2010 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.
+ */
+
+/**
+ * 
+ */
+package org.drools.clips;
+
+public class SymbolLispAtom extends LispAtom {
+    
+    public SymbolLispAtom(String value) {
+        super(value);
+    }
+    
+}
\ No newline at end of file

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/VariableContext.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/VariableContext.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/VariableContext.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,23 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips;
+
+public interface VariableContext {
+    public void addVariable(String name, Object value);
+    
+    //public void removeVariable(String name);
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/VariableLispAtom.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/VariableLispAtom.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/VariableLispAtom.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,31 @@
+/**
+ * Copyright 2010 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.
+ */
+
+/**
+ * 
+ */
+package org.drools.clips;
+
+
+public class VariableLispAtom extends LispAtom {
+    
+    public VariableLispAtom(String var) {
+        super( var.replace( '?', '$' ) );
+        //super( ( var.startsWith( "?" ) ) ? var.substring( 1 ) : var ); // strip leading ?   
+    }
+
+    
+}
\ No newline at end of file

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/AssertFunction.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/AssertFunction.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/AssertFunction.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,54 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips.functions;
+
+import org.drools.clips.Appendable;
+import org.drools.clips.Function;
+import org.drools.clips.FunctionHandlers;
+import org.drools.clips.LispAtom;
+import org.drools.clips.LispForm;
+
+public class AssertFunction implements Function {
+    private static final String name = "assert";
+
+    public String getName() {
+        return name;
+    }
+    
+    public void dump(LispForm lispForm, Appendable appendable) {
+        LispForm form = ( LispForm) lispForm.getSExpressions()[1];
+        
+        String type = ((LispAtom) form.getSExpressions()[0]).getValue();
+        
+        appendable.append("insert( with ( new " + type + "() ) {");        
+        
+        for ( int i = 1, length = form.getSExpressions().length; i < length; i++) {
+            LispForm slot =  ( LispForm) form.getSExpressions()[i];
+                                                                                
+            appendable.append( ( ( LispAtom ) slot.getSExpressions()[0]).getValue() );            
+            
+            appendable.append( " = " );
+            
+            FunctionHandlers.dump( slot.getSExpressions()[1], appendable);  
+            
+            if ( i != length -1 ) { 
+                appendable.append( "," );
+            }
+        }
+        appendable.append("} )");
+    }
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/BaseInfixFunction.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/BaseInfixFunction.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/BaseInfixFunction.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,42 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips.functions;
+
+import org.drools.clips.Appendable;
+import org.drools.clips.Function;
+import org.drools.clips.FunctionHandlers;
+import org.drools.clips.LispForm;
+import org.drools.clips.SExpression;
+
+public abstract class BaseInfixFunction implements Function {
+    public abstract String getMappedSymbol();
+    
+    public void dump(LispForm lispForm, Appendable appendable) {
+        SExpression[] sExpressions = lispForm.getSExpressions();        
+        
+        appendable.append("(");
+        for ( int i = 1, length = sExpressions.length; i < length; i++) {
+            
+            FunctionHandlers.dump( sExpressions[i], appendable );          
+            
+            if ( i != length -1 ) { 
+                appendable.append( getMappedSymbol() );
+            }
+        }
+        appendable.append(")");
+    }
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/BindFunction.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/BindFunction.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/BindFunction.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,39 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips.functions;
+
+import org.drools.clips.Appendable;
+import org.drools.clips.Function;
+import org.drools.clips.FunctionHandlers;
+import org.drools.clips.LispAtom;
+import org.drools.clips.LispForm;
+import org.drools.clips.SExpression;
+
+public class BindFunction implements Function {
+    private static final String name = "bind";
+
+    public String getName() {
+        return name;
+    }
+    
+    public void dump(LispForm lispForm, Appendable appendable) {
+        SExpression[] sExpressions = lispForm.getSExpressions();
+        
+        appendable.append(( (LispAtom) lispForm.getSExpressions()[1]).getValue() + " = " );
+        FunctionHandlers.dump( lispForm.getSExpressions()[2], appendable);
+    }
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/CallFunction.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/CallFunction.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/CallFunction.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,63 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips.functions;
+
+import org.drools.clips.Appendable;
+import org.drools.clips.Function;
+import org.drools.clips.FunctionHandlers;
+import org.drools.clips.LispAtom;
+import org.drools.clips.LispForm;
+import org.drools.clips.SExpression;
+
+public class CallFunction
+    implements
+    Function {
+    private static final String name = "call";
+
+    public String getName() {
+        return name;
+    }
+
+    public void dump(LispForm lispForm,
+                     Appendable appendable) {
+        SExpression[] sExpressions = lispForm.getSExpressions();
+
+        int offset = 0;
+        if ( !"call".equals( ((LispAtom) sExpressions[0]).getValue().trim()) ) {
+            offset = -1;
+        }
+        
+        String name = ((LispAtom) sExpressions[offset+1]).getValue();
+
+        String field = ((LispAtom) sExpressions[offset+2]).getValue().trim();
+        field = field.substring( 1, field.length() -1  );                
+
+        appendable.append( name );
+        appendable.append( "." );
+        appendable.append( field );
+        
+        appendable.append( "(" );
+        for ( int i = offset+3, length = sExpressions.length; i < length; i++) {            
+            FunctionHandlers.dump( sExpressions[i], appendable );         
+            
+            if ( i != length -1 ) { 
+                appendable.append( ", " );
+            }
+        }        
+        appendable.append( ")" );        
+    }
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/CreateListFunction.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/CreateListFunction.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/CreateListFunction.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,47 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips.functions;
+
+import org.drools.clips.Appendable;
+import org.drools.clips.Function;
+import org.drools.clips.FunctionHandlers;
+import org.drools.clips.LispForm;
+import org.drools.clips.SExpression;
+
+public class CreateListFunction implements Function {
+    private static final String name = "create$";
+
+    public String getName() {
+        return name;
+    }
+    
+    public void dump(LispForm lispForm, Appendable appendable) {
+        SExpression[] sExpressions = lispForm.getSExpressions();
+        
+        appendable.append("[");
+        
+        for ( int i = 1, length = sExpressions.length; i < length; i++) {
+            
+            FunctionHandlers.dump( sExpressions[i], appendable );        
+            
+            if ( i != length -1 ) { 
+                appendable.append( "," );
+            }
+        }
+        appendable.append("]");
+    }
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/EqFunction.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/EqFunction.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/EqFunction.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,31 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips.functions;
+
+
+public class EqFunction  extends BaseInfixFunction  {
+    private static final String name = "eq";
+    private static final String mappedSymbol = "==";
+        
+    public String getName() {
+        return name;
+    }
+
+    public String getMappedSymbol() {
+        return mappedSymbol;
+    }
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/GetFunction.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/GetFunction.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/GetFunction.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,47 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips.functions;
+
+import org.drools.clips.Appendable;
+import org.drools.clips.Function;
+import org.drools.clips.LispAtom;
+import org.drools.clips.LispForm;
+import org.drools.clips.SExpression;
+
+public class GetFunction
+    implements
+    Function {
+    private static final String name = "get";
+
+    public String getName() {
+        return name;
+    }
+
+    public void dump(LispForm lispForm,
+                     Appendable appendable) {
+        SExpression[] sExpressions = lispForm.getSExpressions();
+
+        String name = ((LispAtom) sExpressions[1]).getValue();
+
+        String field = ((LispAtom) sExpressions[2]).getValue().trim();
+        field = field.substring( 1, field.length() -1  );                
+
+        appendable.append( name );
+        appendable.append( "." );
+        appendable.append( field );
+    }
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/IfFunction.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/IfFunction.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/IfFunction.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,66 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips.functions;
+
+import org.drools.clips.Appendable;
+import org.drools.clips.Function;
+import org.drools.clips.FunctionHandlers;
+import org.drools.clips.LispAtom;
+import org.drools.clips.LispForm;
+import org.drools.clips.SExpression;
+
+public class IfFunction implements Function {
+    private static final String name = "if";       
+
+    public String getName() {
+        return name;
+    }
+    
+    public void dump(LispForm lispForm, Appendable appendable) {
+        SExpression[] sExpressions = lispForm.getSExpressions();
+
+        appendable.append( "if " );
+        
+        FunctionHandlers.dump( sExpressions[1], appendable );
+        
+        appendable.append( "{" );
+        int i = 3;
+        for ( int length = sExpressions.length; i < length; i++ ) {
+            SExpression sExpr = ( SExpression ) sExpressions[i];
+            if ( ( sExpr instanceof LispAtom ) && "\"else\"".equals( ((LispAtom)sExpr).getValue() ) ) {
+                i++;
+                break;
+            }
+            FunctionHandlers.dump( sExpressions[i], appendable, true );
+        }  
+        appendable.append( "}" );
+        
+        
+        while ( i < sExpressions.length ) {        
+            appendable.append( " else {" );
+            for ( int length = sExpressions.length; i < length; i++ ) {
+                SExpression sExpr = ( SExpression ) sExpressions[i];
+                if ( ( sExpr instanceof LispAtom ) && "\"else\"".equals( ((LispAtom)sExpr).getValue() ) ) {
+                    i++;
+                    break;
+                }
+                FunctionHandlers.dump( sExpressions[i], appendable, true );
+            }        
+            appendable.append( "}" );  
+        }             
+    }
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/LessThanFunction.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/LessThanFunction.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/LessThanFunction.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips.functions;
+
+public class LessThanFunction  extends BaseInfixFunction  {
+    private static final String name = "<";
+    private static final String mappedSymbol = "<";
+
+    public String getName() {
+        return name;
+    }
+    
+    public String getMappedSymbol() {
+        return mappedSymbol;
+    }    
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/LessThanOrEqFunction.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/LessThanOrEqFunction.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/LessThanOrEqFunction.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips.functions;
+
+public class LessThanOrEqFunction  extends BaseInfixFunction  {
+    private static final String name = "<=";
+    private static final String mappedSymbol = "<=";
+    
+    public String getName() {
+        return name;
+    }
+    
+    public String getMappedSymbol() {
+        return mappedSymbol;
+    }    
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/MinusFunction.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/MinusFunction.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/MinusFunction.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips.functions;
+
+public class MinusFunction  extends BaseInfixFunction {
+    private static final String name = "-";
+    private static final String mappedSymbol = "-";
+
+    public String getName() {
+        return name;
+    }  
+    
+    public String getMappedSymbol() {
+        return mappedSymbol;
+    }    
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/ModifyFunction.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/ModifyFunction.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/ModifyFunction.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,52 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips.functions;
+
+import org.drools.clips.Appendable;
+import org.drools.clips.Function;
+import org.drools.clips.FunctionHandlers;
+import org.drools.clips.LispAtom;
+import org.drools.clips.LispForm;
+import org.drools.clips.SExpression;
+
+public class ModifyFunction implements Function {
+    private static final String name = "modify";
+
+    public String getName() {
+        return name;
+    }
+    
+    public void dump(LispForm lispForm, Appendable appendable) {
+        SExpression[] sExpressions = lispForm.getSExpressions();
+        
+        appendable.append("modify (" + ( (LispAtom) lispForm.getSExpressions()[1]).getValue() + ") {");
+        
+        for ( int i = 2, length = sExpressions.length; i < length; i++) {
+            LispForm setter = (LispForm) sExpressions[i];
+            appendable.append( ( ( LispAtom ) setter.getSExpressions()[0]).getValue() );            
+            
+            appendable.append( " = " );
+            
+            FunctionHandlers.dump( setter.getSExpressions()[1], appendable);  
+            
+            if ( i != length -1 ) { 
+                appendable.append( "," );
+            }
+        }
+        appendable.append("}");
+    }
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/MoreThanFunction.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/MoreThanFunction.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/MoreThanFunction.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips.functions;
+
+public class MoreThanFunction  extends BaseInfixFunction  {
+    private static final String name = ">";
+    private static final String mappedSymbol = ">";
+
+    public String getName() {
+        return name;
+    }
+    
+    public String getMappedSymbol() {
+        return mappedSymbol;
+    }    
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/MoreThanOrEqFunction.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/MoreThanOrEqFunction.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/MoreThanOrEqFunction.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips.functions;
+
+public class MoreThanOrEqFunction  extends BaseInfixFunction  {
+    private static final String name = ">=";
+    private static final String mappedSymbol = ">=";
+
+    public String getName() {
+        return name;
+    }
+    
+    public String getMappedSymbol() {
+        return mappedSymbol;
+    }    
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/MultiplyFunction.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/MultiplyFunction.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/MultiplyFunction.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips.functions;
+
+public class MultiplyFunction  extends BaseInfixFunction  {
+    private static final String name = "*";
+    private static final String mappedSymbol = "*";
+
+    public String getName() {
+        return name;
+    }
+    
+    public String getMappedSymbol() {
+        return mappedSymbol;
+    }    
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/NewFunction.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/NewFunction.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/NewFunction.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,51 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips.functions;
+
+import org.drools.clips.Appendable;
+import org.drools.clips.Function;
+import org.drools.clips.FunctionHandlers;
+import org.drools.clips.LispAtom;
+import org.drools.clips.LispForm;
+import org.drools.clips.SExpression;
+
+public class NewFunction implements Function {
+    private static final String name = "new";    
+
+    public String getName() {
+        return name;
+    }
+    
+    public void dump(LispForm lispForm, Appendable appendable) {
+        SExpression[] sExpressions = lispForm.getSExpressions();
+        appendable.append( "new " );
+        
+        String name = ( ( LispAtom ) sExpressions[1] ).getValue().trim();
+        name = name.substring( 1, name.length() -1  );                
+        appendable.append( name );
+        appendable.append( "(" );
+        
+        for ( int i = 2, length = sExpressions.length; i < length; i++) {            
+            FunctionHandlers.dump( sExpressions[i], appendable );         
+            
+            if ( i != length -1 ) { 
+                appendable.append( ", " );
+            }
+        }        
+        appendable.append( ")" );
+    }
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/PlusFunction.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/PlusFunction.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/PlusFunction.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,30 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips.functions;
+
+public class PlusFunction  extends BaseInfixFunction {
+    private static final String name = "+";
+    private static final String mappedSymbol = "+";
+
+    public String getName() {
+        return name;
+    }  
+    
+    public String getMappedSymbol() {
+        return mappedSymbol;
+    }    
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/PrintoutFunction.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/PrintoutFunction.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/PrintoutFunction.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,48 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips.functions;
+
+import org.drools.clips.Appendable;
+import org.drools.clips.Function;
+import org.drools.clips.FunctionHandlers;
+import org.drools.clips.LispAtom;
+import org.drools.clips.LispForm;
+import org.drools.clips.SExpression;
+
+public class PrintoutFunction implements Function {
+    private static final String name = "printout";
+    
+    private static final int route = 1;
+
+    public String getName() {
+        return name;
+    }
+    
+    public void dump(LispForm lispForm, Appendable appendable) {
+        SExpression[] sExpressions = lispForm.getSExpressions();
+        appendable.append( "printrouters.get(" + ( ( LispAtom ) lispForm.getSExpressions()[route]).getValue()+ ").print(" );
+        //appendable.append( "routers.get(" + ( ( LispAtom2 ) lispForm.getSExpressions()[route]).getValue()+ ").print(" );
+        for ( int i = 2, length = sExpressions.length; i < length; i++) {            
+            FunctionHandlers.dump( sExpressions[i], appendable );         
+            
+            if ( i != length -1 ) { 
+                appendable.append( "+" );
+            }
+        }        
+        appendable.append( ")" );
+    }
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/PrognFunction.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/PrognFunction.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/PrognFunction.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,55 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips.functions;
+
+import org.drools.clips.Appendable;
+import org.drools.clips.Function;
+import org.drools.clips.FunctionHandlers;
+import org.drools.clips.LispAtom;
+import org.drools.clips.LispForm;
+import org.drools.clips.SExpression;
+
+public class PrognFunction implements Function {
+    private static final String name = "progn";       
+
+    public String getName() {
+        return name;
+    }
+    
+    public void dump(LispForm lispForm, Appendable appendable) {
+        Function createList = FunctionHandlers.getInstance().getFunction( "create$" );
+        
+        SExpression[] sExpressions = lispForm.getSExpressions();
+        
+        LispForm listSpec = (LispForm) sExpressions[1];
+        
+        String var = ( ( LispAtom ) listSpec.getSExpressions()[0] ).getValue();        
+        
+        appendable.append( "foreach( " + var + " : " );        
+        
+        createList.dump( (LispForm) listSpec.getSExpressions()[1], appendable );
+        
+        appendable.append( " ) {" );
+        
+        for ( int i = 2, length = sExpressions.length; i < length; i++ ) {
+            FunctionHandlers.dump( sExpressions[i], appendable, true );
+        }          
+        
+        appendable.append( "}" );
+                        
+    }
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/RetractFunction.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/RetractFunction.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/RetractFunction.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,38 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips.functions;
+
+import org.drools.clips.Appendable;
+import org.drools.clips.Function;
+import org.drools.clips.LispAtom;
+import org.drools.clips.LispForm;
+
+public class RetractFunction implements Function {
+    private static final String name = "retract";
+
+    public String getName() {
+        return name;
+    }
+    
+    public void dump(LispForm lispForm, Appendable appendable) {
+        LispForm form = ( LispForm) lispForm.getSExpressions()[1];
+        
+        String var = ((LispAtom) form.getSExpressions()[0]).getValue();
+        
+        appendable.append("retract( " + var + " )");
+    }
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/ReturnFunction.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/ReturnFunction.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/ReturnFunction.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,35 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips.functions;
+
+import org.drools.clips.Appendable;
+import org.drools.clips.Function;
+import org.drools.clips.FunctionHandlers;
+import org.drools.clips.LispForm;
+
+public class ReturnFunction implements Function {
+    private static final String name = "return";
+
+    public String getName() {
+        return name;
+    }
+    
+    public void dump(LispForm lispForm, Appendable appendable) {
+        appendable.append( "return " );
+        FunctionHandlers.dump( lispForm.getSExpressions()[1], appendable );
+    }
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/RunFunction.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/RunFunction.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/RunFunction.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,38 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips.functions;
+
+import org.drools.clips.Appendable;
+import org.drools.clips.Function;
+import org.drools.clips.LispAtom;
+import org.drools.clips.LispForm;
+
+public class RunFunction implements Function {
+    private static final String name = "run";
+
+    public String getName() {
+        return name;
+    }
+    
+    public void dump(LispForm lispForm, Appendable appendable) {
+        if ( lispForm.getSExpressions().length == 3 ) {
+            appendable.append( "run(" + ((LispAtom)lispForm.getSExpressions()[2]).getValue() + ");\n " );
+        } else {
+            appendable.append( "run()" );
+        }
+    }
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/SetFunction.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/SetFunction.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/SetFunction.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,52 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips.functions;
+
+import org.drools.clips.Appendable;
+import org.drools.clips.Function;
+import org.drools.clips.FunctionHandlers;
+import org.drools.clips.LispAtom;
+import org.drools.clips.LispForm;
+import org.drools.clips.SExpression;
+
+public class SetFunction
+    implements
+    Function {
+    private static final String name = "set";
+
+    public String getName() {
+        return name;
+    }
+
+    public void dump(LispForm lispForm,
+                     Appendable appendable) {
+        SExpression[] sExpressions = lispForm.getSExpressions();
+
+        String name = ((LispAtom) sExpressions[1]).getValue();
+
+        String field = ((LispAtom) sExpressions[2]).getValue().trim();
+        field = field.substring( 1, field.length() -1  );                
+
+        appendable.append( name );
+        appendable.append( "." );
+        appendable.append( field );
+        appendable.append( " = " );
+
+        FunctionHandlers.dump( sExpressions[3],
+                               appendable );
+    }
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/SwitchFunction.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/SwitchFunction.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/clips/functions/SwitchFunction.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,87 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips.functions;
+
+import org.drools.clips.Appendable;
+import org.drools.clips.Function;
+import org.drools.clips.FunctionHandlers;
+import org.drools.clips.LispAtom;
+import org.drools.clips.LispForm;
+import org.drools.clips.SExpression;
+
+public class SwitchFunction implements Function {     
+    private static String name = "switch";
+    
+    public String getName() {
+        return name;
+    }
+    
+    public void dump(LispForm lispForm, Appendable appendable) {
+        SExpression[] sExpressions = lispForm.getSExpressions();
+
+        appendable.append( "switchvar = " );
+        LispForm expr = ( LispForm ) sExpressions[1];
+        if ( expr.getSExpressions().length > 1 ) {
+            FunctionHandlers.dump( expr, appendable );
+        } else {
+            FunctionHandlers.dump( expr.getSExpressions()[0], appendable );
+        }
+        appendable.append( ";\n" );
+        
+        LispForm caseForm = ( LispForm ) sExpressions[2];
+        
+        appendable.append( "if ( switchvar == " );            
+        
+        FunctionHandlers.dump( caseForm.getSExpressions()[1], appendable );            
+        appendable.append( ") {" );
+        for ( int j = 3, jlength = caseForm.getSExpressions().length; j < jlength; j++ ) {
+            FunctionHandlers.dump( caseForm.getSExpressions()[j], appendable, true );
+        }        
+        appendable.append( "}" );
+        
+        for ( int i = 3, length = sExpressions.length-1; i < length; i++ ) {
+            caseForm = ( LispForm ) sExpressions[i];
+            
+            appendable.append( " else if ( switchvar == " );            
+            FunctionHandlers.dump( caseForm.getSExpressions()[1], appendable );            
+            appendable.append( ") {" );
+            
+            for ( int j = 3, jlength = caseForm.getSExpressions().length; j < jlength; j++ ) {
+                FunctionHandlers.dump( caseForm.getSExpressions()[j], appendable, true );
+            }
+            appendable.append( "}" );
+        }
+        
+        caseForm = ( LispForm ) sExpressions[ sExpressions.length-1 ];
+        if ( "case".equals( ((LispAtom)caseForm.getSExpressions()[0]).getValue() ) ) {
+            appendable.append( " else if ( switchvar == " );            
+            FunctionHandlers.dump( caseForm.getSExpressions()[1], appendable );            
+            appendable.append( ") {" );
+            for ( int j = 3, length = caseForm.getSExpressions().length; j < length; j++ ) {
+                FunctionHandlers.dump( caseForm.getSExpressions()[j], appendable, true );
+            }        
+            appendable.append( "}" );            
+        } else {
+            appendable.append( " else { " ); 
+            for ( int j = 1, length = caseForm.getSExpressions().length; j < length; j++ ) {
+                FunctionHandlers.dump( caseForm.getSExpressions()[j], appendable, true );
+            }        
+            appendable.append( "}" );            
+        }  
+    }
+    
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/rule/builder/dialect/clips/ClipsConsequenceBuilder.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/rule/builder/dialect/clips/ClipsConsequenceBuilder.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/rule/builder/dialect/clips/ClipsConsequenceBuilder.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,58 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.rule.builder.dialect.clips;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.clips.Appendable;
+import org.drools.clips.FunctionHandlers;
+import org.drools.clips.LispForm;
+import org.drools.clips.StringBuilderAppendable;
+import org.drools.rule.builder.RuleBuildContext;
+import org.drools.rule.builder.dialect.mvel.MVELConsequenceBuilder;
+
+public class ClipsConsequenceBuilder extends MVELConsequenceBuilder  {
+
+	public void build(final RuleBuildContext context, String consequenceName) {
+		// TODO does not support named consequences
+        Appendable builder = new StringBuilderAppendable();
+        
+        List list = (List) context.getRuleDescr().getConsequence();
+        for ( Iterator it = list.iterator(); it.hasNext(); ) {
+            FunctionHandlers.dump( (LispForm) it.next(),
+                                   builder,
+                                   true );
+        }
+        
+        context.getRuleDescr().setConsequence( builder.toString() );      
+        
+        super.build(  context, consequenceName );
+        
+//        Rule rule = context.getRule();
+//        BlockExecutionEngine rhs = ( BlockExecutionEngine ) context.getRuleDescr().getConsequence();
+//        Map vars = new HashMap();
+//        
+//        for(Declaration declaration : rule.getDeclarations() ) {
+//            vars.put( declaration.getIdentifier(), declaration );
+//        }
+//        
+//        rhs.replaceTempTokens( vars );
+//        rule.setConsequence( rhs );        
+    }
+
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/rule/builder/dialect/clips/ClipsDialect.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/rule/builder/dialect/clips/ClipsDialect.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/rule/builder/dialect/clips/ClipsDialect.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,190 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.rule.builder.dialect.clips;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.drools.clips.Appendable;
+import org.drools.clips.FunctionHandlers;
+import org.drools.clips.LispForm;
+import org.drools.clips.StringBuilderAppendable;
+import org.drools.compiler.Dialect;
+import org.drools.compiler.PackageBuilder;
+import org.drools.compiler.PackageRegistry;
+import org.drools.lang.descr.AccumulateDescr;
+import org.drools.lang.descr.AndDescr;
+import org.drools.lang.descr.BaseDescr;
+import org.drools.lang.descr.CollectDescr;
+import org.drools.lang.descr.EntryPointDescr;
+import org.drools.lang.descr.EvalDescr;
+import org.drools.lang.descr.ExistsDescr;
+import org.drools.lang.descr.ForallDescr;
+import org.drools.lang.descr.FromDescr;
+import org.drools.lang.descr.FunctionDescr;
+import org.drools.lang.descr.NotDescr;
+import org.drools.lang.descr.OrDescr;
+import org.drools.lang.descr.PatternDescr;
+import org.drools.lang.descr.PredicateDescr;
+import org.drools.lang.descr.QueryDescr;
+import org.drools.lang.descr.ReturnValueRestrictionDescr;
+import org.drools.rule.Package;
+import org.drools.rule.builder.ConsequenceBuilder;
+import org.drools.rule.builder.PackageBuildContext;
+import org.drools.rule.builder.PredicateBuilder;
+import org.drools.rule.builder.ReturnValueBuilder;
+import org.drools.rule.builder.RuleConditionBuilder;
+import org.drools.rule.builder.dialect.mvel.MVELDialect;
+
+public class ClipsDialect extends MVELDialect {
+
+    private static final ClipsConsequenceBuilder CONSEQUENCE_BUILDER  = new ClipsConsequenceBuilder();
+    private static final ClipsEvalBuilder        EVAL_BUILDER         = new ClipsEvalBuilder();
+    private static final ClipsReturnValueBuilder RETURN_VALUE_BUILDER = new ClipsReturnValueBuilder();
+    private static final ClipsPredicateBuilder   PREDICATE_BUILDER    = new ClipsPredicateBuilder();
+    
+    // a map of registered builders
+    private static Map                           builders;
+    static {
+        initBuilder();
+    }    
+
+    public final static String                   ID                   = "clips";
+
+    public ClipsDialect(PackageBuilder builder,
+                        PackageRegistry pkgRegistry,
+                        Package pkg) {
+        super( builder,
+               pkgRegistry,
+               pkg,
+               ID );
+        setLanguageLevel( 5 );
+    }
+    
+    public static void initBuilder() {
+        if ( builders != null ) {
+            return;
+        }
+
+        // statically adding all builders to the map
+        // but in the future we can move that to a configuration
+        // if we want to
+        builders = new HashMap();
+
+        builders.put( AndDescr.class,
+                      GE_BUILDER );
+
+        builders.put( OrDescr.class,
+                      GE_BUILDER );
+
+        builders.put( NotDescr.class,
+                      GE_BUILDER );
+
+        builders.put( ExistsDescr.class,
+                      GE_BUILDER );
+
+        builders.put( PatternDescr.class,
+                      PATTERN_BUILDER );
+
+        builders.put( FromDescr.class,
+                      FROM_BUILDER );
+
+        builders.put( QueryDescr.class,
+                      QUERY_BUILDER );
+
+        builders.put( AccumulateDescr.class,
+                      ACCUMULATE_BUILDER );
+
+        builders.put( EvalDescr.class,
+                      EVAL_BUILDER );
+
+        builders.put( CollectDescr.class,
+                      COLLECT_BUILDER );
+
+        builders.put( ForallDescr.class,
+                      FORALL_BUILDER );
+
+        builders.put( FunctionDescr.class,
+                      FUNCTION_BUILDER );
+
+        builders.put( EntryPointDescr.class,
+                      ENTRY_POINT_BUILDER );
+    }    
+
+    public String getId() {
+        return ID;
+    }
+
+    public Map getBuilders() {
+        return this.builders;
+    }
+    
+    public RuleConditionBuilder getBuilder(final Class clazz) {
+        return (RuleConditionBuilder) this.builders.get( clazz );
+    }    
+
+    public ConsequenceBuilder getConsequenceBuilder() {
+        return this.CONSEQUENCE_BUILDER;
+    }
+
+    public RuleConditionBuilder getEvalBuilder() {
+        return this.EVAL_BUILDER;
+    }
+
+    public ReturnValueBuilder getReturnValueBuilder() {
+        return this.RETURN_VALUE_BUILDER;
+    }
+
+    public PredicateBuilder getPredicateBuilder() {
+        return this.PREDICATE_BUILDER;
+    }
+
+    public Dialect.AnalysisResult analyzeExpression(PackageBuildContext context,
+                                                    BaseDescr descr,
+                                                    Object content,
+                                                    final Map<String,Class<?>>[] availableIdentifiers,
+                                                    Map<String,Class<?>> localTypes) {
+        if ( descr instanceof PredicateDescr ) {
+            Appendable builder = new StringBuilderAppendable();
+            PredicateDescr pdescr = (PredicateDescr) descr;
+            if ( pdescr.getContent() instanceof LispForm ) {
+                FunctionHandlers.dump( (LispForm) pdescr.getContent(),
+                                       builder,
+                                       true);
+
+                content = builder.toString();
+                pdescr.setContent( content );
+            }
+        } else if ( descr instanceof ReturnValueRestrictionDescr ) {
+            Appendable builder = new StringBuilderAppendable();
+            ReturnValueRestrictionDescr rdescr = (ReturnValueRestrictionDescr) descr;
+            if ( rdescr.getContent() instanceof LispForm ) {
+                FunctionHandlers.dump( (LispForm) rdescr.getContent(),
+                                       builder,
+                                       true);
+                content = builder.toString();
+                rdescr.setContent( content );
+            }
+        }
+        return super.analyzeExpression( context,
+                                        descr,
+                                        content,
+                                        availableIdentifiers,
+                                        localTypes );
+    }
+
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/rule/builder/dialect/clips/ClipsDialectConfiguration.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/rule/builder/dialect/clips/ClipsDialectConfiguration.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/rule/builder/dialect/clips/ClipsDialectConfiguration.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,37 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.rule.builder.dialect.clips;
+
+import org.drools.compiler.Dialect;
+import org.drools.compiler.PackageBuilder;
+import org.drools.compiler.PackageRegistry;
+import org.drools.rule.Package;
+import org.drools.rule.builder.dialect.mvel.MVELDialectConfiguration;
+
+/**
+ * The Clips dialect.
+ * 
+ *
+ */
+public class ClipsDialectConfiguration
+    extends MVELDialectConfiguration {
+    
+    public Dialect newDialect(PackageBuilder packageBuilder, PackageRegistry pkgRegistry, Package pkg) {
+        return new ClipsDialect(packageBuilder, pkgRegistry, pkg);
+    }    
+
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/rule/builder/dialect/clips/ClipsEvalBuilder.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/rule/builder/dialect/clips/ClipsEvalBuilder.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/rule/builder/dialect/clips/ClipsEvalBuilder.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,68 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.rule.builder.dialect.clips;
+
+import org.drools.clips.Appendable;
+import org.drools.clips.FunctionHandlers;
+import org.drools.clips.LispForm;
+import org.drools.clips.StringBuilderAppendable;
+import org.drools.lang.descr.BaseDescr;
+import org.drools.lang.descr.EvalDescr;
+import org.drools.rule.Pattern;
+import org.drools.rule.RuleConditionElement;
+import org.drools.rule.builder.RuleBuildContext;
+import org.drools.rule.builder.RuleConditionBuilder;
+import org.drools.rule.builder.dialect.mvel.MVELEvalBuilder;
+
+/**
+ * @author etirelli
+ *
+ */
+public class ClipsEvalBuilder extends MVELEvalBuilder
+    implements
+    RuleConditionBuilder {
+
+    public RuleConditionElement build(final RuleBuildContext context,
+                                      final BaseDescr descr) {
+        return build( context,
+                      descr,
+                      null );
+    }
+
+    /**
+     * Builds and returns an Eval Conditional Element
+     * 
+     * @param context The current build context
+     * @param utils The current build utils instance
+     * @param patternBuilder not used by EvalBuilder
+     * @param descr The Eval Descriptor to build the eval conditional element from
+     * 
+     * @return the Eval Conditional Element
+     */
+    public RuleConditionElement build(final RuleBuildContext context,
+                                      final BaseDescr descr,
+                                      final Pattern prefixPattern) {
+        Appendable builder = new StringBuilderAppendable();
+        EvalDescr edescr = (EvalDescr) descr;
+            FunctionHandlers.dump( (LispForm) edescr.getContent(),
+                                   builder,
+                                   true );
+            edescr.setContent( builder.toString() );
+        return super.build(context, descr, prefixPattern);
+    }
+
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/rule/builder/dialect/clips/ClipsPredicateBuilder.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/rule/builder/dialect/clips/ClipsPredicateBuilder.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/rule/builder/dialect/clips/ClipsPredicateBuilder.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,45 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.rule.builder.dialect.clips;
+
+import java.util.List;
+
+import org.drools.lang.descr.PredicateDescr;
+import org.drools.rule.Declaration;
+import org.drools.rule.PredicateConstraint;
+import org.drools.rule.builder.PredicateBuilder;
+import org.drools.rule.builder.RuleBuildContext;
+import org.drools.rule.builder.dialect.mvel.MVELPredicateBuilder;
+
+/**
+ * @author etirelli
+ *
+ */
+public class ClipsPredicateBuilder extends MVELPredicateBuilder
+    implements
+    PredicateBuilder {
+
+    public void build(final RuleBuildContext context,
+                      final List[] usedIdentifiers,
+                      final Declaration[] previousDeclarations,
+                      final Declaration[] localDeclarations,
+                      final PredicateConstraint predicate,
+                      final PredicateDescr predicateDescr) {        
+        super.build(context, usedIdentifiers, previousDeclarations, localDeclarations, predicate, predicateDescr);
+    }
+
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/rule/builder/dialect/clips/ClipsReturnValueBuilder.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/rule/builder/dialect/clips/ClipsReturnValueBuilder.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/java/org/drools/rule/builder/dialect/clips/ClipsReturnValueBuilder.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,36 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.rule.builder.dialect.clips;
+
+import java.util.List;
+
+import org.drools.lang.descr.ReturnValueRestrictionDescr;
+import org.drools.rule.Declaration;
+import org.drools.rule.ReturnValueRestriction;
+import org.drools.rule.builder.RuleBuildContext;
+import org.drools.rule.builder.dialect.mvel.MVELReturnValueBuilder;
+
+public class ClipsReturnValueBuilder extends MVELReturnValueBuilder {
+    public void build(final RuleBuildContext context,
+                      final List[] usedIdentifiers,
+                      final Declaration[] previousDeclarations,
+                      final Declaration[] localDeclarations,
+                      final ReturnValueRestriction returnValueRestriction,
+                      final ReturnValueRestrictionDescr returnValueRestrictionDescr) {        
+        super.build(context, usedIdentifiers, previousDeclarations, localDeclarations, returnValueRestriction, returnValueRestrictionDescr );
+    }
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/resources/META-INF/drools.default.packagebuilder.conf
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/resources/META-INF/drools.default.packagebuilder.conf	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/resources/META-INF/drools.default.packagebuilder.conf	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,2 @@
+drools.dialect.clips = org.drools.rule.builder.dialect.clips.ClipsDialectConfiguration
+drools.dialect.mvel.strict = false
\ No newline at end of file

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/resources/org/drools/clips/Clips.g
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/resources/org/drools/clips/Clips.g	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/resources/org/drools/clips/Clips.g	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,952 @@
+grammar Clips;
+
+ at parser::header {
+	package org.drools.clips;
+
+    import org.drools.clips.*;		
+    
+	import java.util.List;
+	import java.util.ArrayList;
+	import java.util.Iterator;
+	import java.util.HashMap;	
+	import java.util.Set;	
+	import java.util.HashSet;			
+	import java.util.StringTokenizer;
+	import org.drools.lang.descr.*;
+	import org.drools.lang.Location;	
+}
+
+ 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 Location location = new Location( Location.LOCATION_UNKNOWN );	
+	
+	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 ( state.errorRecovery ) {
+			//System.err.print("[SPURIOUS] ");
+			return;
+		}
+		state.syntaxErrors++; // don't count spurious
+		state.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+ FIXME
+                                                           "; 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) ) );
+        	}
+        }
+        
+    		void addTypeFieldDescr(LispForm lispForm, TypeDeclarationDescr typeDescr) {
+    	        if ( !(lispForm.getSExpressions()[0] instanceof SymbolLispAtom) ) {
+    	            throw new RuntimeException("should specify a slot");
+    	        }
+    	        
+    	        SymbolLispAtom slot = (SymbolLispAtom) lispForm.getSExpressions()[0];
+    	        if ( !"slot".equals( slot.getValue().trim() )) {
+    	            throw new RuntimeException("should specify a slot");
+    	        }
+    	        
+    	        if ( !(lispForm.getSExpressions()[1] instanceof SymbolLispAtom) ) {
+    	            throw new RuntimeException("should specify a slot name");
+    	        }
+    	        SymbolLispAtom slotName = (SymbolLispAtom) lispForm.getSExpressions()[1];
+    	        
+    	        if ( !(lispForm.getSExpressions()[2] instanceof LispForm) ) {
+    	            throw new RuntimeException("should specify a type");
+    	        }
+    	        
+    	        LispForm typeForm = (LispForm) lispForm.getSExpressions()[2];
+    	        if ( !(typeForm.getSExpressions()[0] instanceof SymbolLispAtom) ) {
+    	            throw new RuntimeException("should specify a type");
+    	        }
+    	        SymbolLispAtom type = (SymbolLispAtom) typeForm.getSExpressions()[0];
+    	        if ( !"type".equals( type.getValue().trim() )) {
+    	            throw new RuntimeException("should specify a type");
+    	        }                
+    	        
+    	        if ( !(typeForm.getSExpressions()[1] instanceof SymbolLispAtom) ) {
+    	            throw new RuntimeException("should specify a slot name");
+    	        }
+    	        SymbolLispAtom typeName = (SymbolLispAtom) typeForm.getSExpressions()[1];        
+    	        
+    	        TypeFieldDescr fieldDescr = new TypeFieldDescr(removeQuotes(slotName.getValue()), new PatternDescr(removeQuotes(typeName.getValue())));        
+    	        typeDescr.addField( fieldDescr );
+            }
+    		
+    		String removeQuotes(String string) {
+    		    return string.substring( 1, string.length() -1 );
+    		}
+      
+}
+
+ at lexer::header {
+	package org.drools.clips;
+}
+
+/*
+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;
+		}
+	;	
+*/
+
+eval[ParserHandler handler]
+	:	
+	   (		  i=importDescr{ handler.importHandler( i ); }
+				| f=deffunction { handler.functionHandler( f ); }	
+				| t=deftemplate { handler.templateHandler( t ); }				
+				| r=defrule { handler.ruleHandler( r ); }
+				| form=lisp_form { handler.lispFormHandler( form ); }
+		)*
+	;
+	
+	/*
+eval_sExpressions[MVELClipsContext context] returns[List<SExpression> list]
+    @init {
+		list = new ArrayList<SExpression>();
+    }
+	:
+		(  	a=lisp_list { list.add( a ); }
+		   | a=deffunction { FunctionHandlers.dump(a, null, context); }
+		)*
+//		{ sExpressions = ( SExpression[] ) list.toArray( new SExpression[ list.size () ] ); }
+	;
+	*/	
+	
+importDescr returns[ImportDescr importDescr]
+	: LEFT_PAREN 'import' importName=NAME { importDescr = new ImportDescr( importName.getText() ); } RIGHT_PAREN
+	;	
+/*	
+
+
+execution_list returns[ExecutionEngine engine]
+	@init {
+	        engine = new BlockExecutionEngine();
+			BuildContext context = new ExecutionBuildContext( engine, functionRegistry );  	
+	}
+	
+	:
+		(fc=lisp_list[context, new LispForm(context) ] { context.addFunction( (FunctionCaller) fc ); })
+	;	
+*/	
+
+/*
+deffunction returns[Deffunction function]
+	@init {
+			BuildContext context = null;  	
+	}
+	:	loc=LEFT_PAREN	 
+	  	DEFFUNCTION 
+	  	ruleName=NAME {
+	    	function = new Deffunction( ruleName.getText() );
+			functionRegistry.addFunction( function );
+	      	context = new ExecutionBuildContext( function, functionRegistry );
+	  	}
+		loc=LEFT_PAREN	 
+		 (v=VAR {
+			context.addVariable( function.addParameter( v.getText() ) );
+		 })*	  
+	 	 RIGHT_PAREN
+	  	(fc=lisp_list[context, new LispForm(context) ] { context.addFunction( (FunctionCaller) fc ); })*
+	  	RIGHT_PAREN
+	;
+*/	
+	
+/*	
+deffunction_params[BuildContext context]
+	:	loc=LEFT_PAREN	 
+		 (v=VAR {
+		    // this creates a parameter on the underlying function
+		 	context.createLocalVariable( v.getText() );
+		 })*	  
+	 	 RIGHT_PAREN	
+	;	
+*/
+
+deffunction returns[FunctionDescr functionDescr]
+    @init {
+        List content = null;
+        functionDescr = null;
+    }
+	:	LEFT_PAREN	
+    	t=DEFFUNCTION //{ list.add( new SymbolLispAtom( t.getText() ) ); }    	//deffunction
+    	name=lisp_atom //name
+    	params=lisp_form  // params
+		(form=lisp_form { if ( content == null ) content = new ArrayList(); content.add( form ); } )+					    	
+	    RIGHT_PAREN
+	    { functionDescr = FunctionHandlers.createFunctionDescr( name, params, content ); }
+	    //{ sExpression = new LispForm( ( SExpression[] ) list.toArray( new SExpression[ list.size () ] ) ); }
+	;
+	
+defrule returns [RuleDescr rule]
+	@init { 
+	        rule = null; 
+	        AndDescr lhs = null;
+	        PatternDescr colum = null;  
+            Set declarations = null;  
+	      }
+	:	loc=LEFT_PAREN 
+		
+		DEFRULE ruleName=NAME
+	  	{ 	  			  		
+	  		debug( "start rule: " + ruleName.getText() );
+	  		String ruleStr = ruleName.getText();
+	  		AttributeDescr module = null;
+
+	        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.setNamespace( module.getValue() );
+		    	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() );	
+			
+			rule.addAttribute( new AttributeDescr( "dialect", "clips") );	
+			
+			declarations = new HashSet();  											
+		}
+		documentation=STRING {
+	    	// do nothing here for now
+		}
+		ruleAttribute[rule]
+		
+		ce[lhs, declarations]*
+		
+		'=>'
+		
+		list=rule_consequence{ rule.setConsequence( list ); }
+		
+		RIGHT_PAREN
+	;
+
+rule_consequence returns[List list]
+    @init {
+        list = null;
+    }
+    :	
+		(l=lisp_form	{ if ( list == null ) list = new ArrayList(); list.add( l ); })*								    	
+	;
+
+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, Set declarations]
+	:	(   and_ce[in_ce, declarations]	
+		  | or_ce[in_ce, declarations]
+		  | not_ce[in_ce, declarations]
+		  | exists_ce[in_ce, declarations]		  
+ 		  | eval_ce[in_ce, declarations] 		  
+		  | normal_pattern[in_ce, declarations]
+		  | bound_pattern[in_ce, declarations]
+		)
+	;
+	
+and_ce[ConditionalElementDescr in_ce, Set declarations]
+    @init {
+        AndDescr andDescr= null;        
+    }
+	:	LEFT_PAREN	
+		AND {
+	    	andDescr = new AndDescr();
+			in_ce.addDescr( andDescr );
+		}
+		ce[andDescr, declarations]+		 
+		RIGHT_PAREN					
+	;	
+	
+or_ce[ConditionalElementDescr in_ce, Set declarations]
+    @init {
+        OrDescr orDescr= null;         
+    }
+	:	LEFT_PAREN	
+		OR {
+	    	orDescr = new OrDescr();
+			in_ce.addDescr( orDescr );
+		}
+		ce[orDescr, declarations]+		 
+		RIGHT_PAREN					
+	;	
+	
+not_ce[ConditionalElementDescr in_ce, Set declarations]
+    @init {
+        NotDescr notDescr= null;         
+    }
+	:	LEFT_PAREN	
+		NOT {
+			notDescr = new NotDescr();
+		    in_ce.addDescr( notDescr );
+		}
+		ce[notDescr, declarations]		 
+		RIGHT_PAREN					
+	;		
+	
+exists_ce[ConditionalElementDescr in_ce, Set declarations]
+    @init {
+        ExistsDescr existsDescr= null;        
+    }
+	:	LEFT_PAREN	
+		EXISTS {
+		    existsDescr = new ExistsDescr();
+		    in_ce.addDescr( existsDescr );
+		}
+		ce[existsDescr, declarations]		 
+		RIGHT_PAREN					
+	;		
+
+eval_ce[ConditionalElementDescr in_ce, Set declarations]
+	:	LEFT_PAREN	
+		TEST 
+		t=lisp_form { EvalDescr evalDescr = new EvalDescr(); evalDescr.setContent( t ); in_ce.addDescr( evalDescr ); }			 
+		RIGHT_PAREN					
+	;		
+
+normal_pattern[ConditionalElementDescr in_ce, Set declarations]
+    @init {
+        PatternDescr pattern = null;
+        ConditionalElementDescr top = null;
+    }
+	:	LEFT_PAREN 
+		name=NAME {
+			pattern = new PatternDescr(name.getText());
+			in_ce.addDescr( pattern );
+			top = pattern.getConstraint();
+			
+		}
+		field_constriant[top, declarations]* 	  
+		RIGHT_PAREN
+	;		
+	
+
+
+bound_pattern[ConditionalElementDescr in_ce, Set declarations]
+    @init {
+        PatternDescr pattern = null;
+        String identifier = null;
+        ConditionalElementDescr top = null;        
+    }
+	:	var=VAR {
+			identifier = var.getText();
+		}
+		ASSIGN_OP LEFT_PAREN name=NAME 
+		{
+			pattern = new PatternDescr(name.getText());
+			pattern.setIdentifier( identifier.replace( '?', '$') );
+			in_ce.addDescr( pattern );
+			top = pattern.getConstraint();				    
+		}
+		field_constriant[top, declarations]* 
+		RIGHT_PAREN	
+	;			
+	
+field_constriant[ConditionalElementDescr base, Set declarations] 
+	@init {
+     	List list = new ArrayList();
+		FieldBindingDescr fbd = null;
+		FieldConstraintDescr fc = null;
+		RestrictionConnectiveDescr top = null;		
+		String op = "==";
+	}    
+	:	
+		LEFT_PAREN f=NAME 
+		{
+			fc = new FieldConstraintDescr(f.getText());
+			fc.setLocation( offset(f.getLine()), f.getCharPositionInLine() );
+			fc.setStartCharacter( ((CommonToken)f).getStartIndex() );
+			//base.addDescr( fc );    
+			top = fc.getRestriction();		
+		}	  
+		
+		or_restr_connective[top, base, fc, declarations] 
+		{ if ( top.getRestrictions().size() != 0 ) {
+		    base.insertBeforeLast( PredicateDescr.class, fc ); 
+		  }
+		}
+		RIGHT_PAREN		
+	;
+/*	
+connected_constraint[RestrictionConnectiveDescr rc, ConditionalElementDescr base]
+	:
+	restriction[rc, base]
+	( 
+	    AMPERSAND { rc.addRestriction(new RestrictionConnectiveDescr(RestrictionConnectiveDescr.AND)); }
+	    connected_constraint[rc, base]
+	| 
+	    PIPE {rc.addRestriction(new RestrictionConnectiveDescr(RestrictionConnectiveDescr.OR)); }
+	    connected_constraint[rc, base]
+	)?
+	;	
+*/
+
+
+or_restr_connective[ RestrictionConnectiveDescr rcBase, ConditionalElementDescr ceBase, FieldConstraintDescr fcBase, Set declarations ]
+	options { 
+		backtrack=true;
+	}
+	@init {
+		RestrictionConnectiveDescr or = new RestrictionConnectiveDescr(RestrictionConnectiveDescr.OR);
+	}
+	:
+		and_restr_connective[or, ceBase, fcBase, declarations] 
+		( 
+			options {backtrack=true;}
+			: PIPE
+			{
+				location.setType(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR);
+			}
+			and_restr_connective[or, ceBase, fcBase, declarations] 
+		)*
+	;
+	finally {
+	        if( or.getRestrictions().size() == 1 ) {
+	                $rcBase.addOrMerge( (RestrictionDescr) or.getRestrictions().get( 0 ) );
+	        } else if ( or.getRestrictions().size() > 1 ) {
+	        	$rcBase.addRestriction( or );
+	        }
+	}
+
+and_restr_connective[ RestrictionConnectiveDescr rcBase, ConditionalElementDescr ceBase, FieldConstraintDescr fcBase, Set declarations ]
+	@init {
+		RestrictionConnectiveDescr and = new RestrictionConnectiveDescr(RestrictionConnectiveDescr.AND);
+	}
+	:
+		restriction[and, ceBase, fcBase, declarations] 
+		( AMPERSAND restriction[and, ceBase, fcBase, declarations] )*
+		/*
+		(	options {backtrack=true;}
+		:	t=AMPERSAND 
+			{
+				location.setType(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR);
+			}
+			restriction[and, ceBase] 
+		)*
+		*/
+	;
+	finally {
+	        if( and.getRestrictions().size() == 1) {
+	                $rcBase.addOrMerge( (RestrictionDescr) and.getRestrictions().get( 0 ) );
+	        } else if ( and.getRestrictions().size() > 1 ) {
+	        	$rcBase.addRestriction( and );
+	        }
+	}
+	
+restriction[RestrictionConnectiveDescr rc, ConditionalElementDescr base, FieldConstraintDescr fcBase, Set declarations ]
+	@init {
+			String op = "==";
+	}
+	:	(TILDE{op = "!=";})?	 	  	 
+		(	predicate_constraint[rc, op, base]	  	  	
+	  	|	return_value_restriction[op, rc]
+	  	|	variable_restriction[op, rc, base, fcBase, declarations]
+	  	| 	lc=literal_restriction {
+     	    			rc.addRestriction( new LiteralRestrictionDescr(op, lc) );
+		      		op = "==";
+		        } 	  	  	  
+		)		
+	;		
+
+predicate_constraint[RestrictionConnectiveDescr rc, String op, ConditionalElementDescr base]	
+	:	COLON
+		t=lisp_form { $base.addDescr( new PredicateDescr( t ) ); }	
+		
+	;
+
+
+return_value_restriction[String op, RestrictionConnectiveDescr rc]
+	:	EQUALS 
+		t=lisp_form {rc.addRestriction( new ReturnValueRestrictionDescr (op, t ) ); }		
+	;
+		
+//will add a declaration field binding, if this is the first time the name  is used		
+variable_restriction[String op, RestrictionConnectiveDescr rc, ConditionalElementDescr ceBase, FieldConstraintDescr fcBase, Set declarations ]
+    @init { String identifier = null;}
+	:	VAR {
+	        identifier =  $VAR.text.replace( '?', '$');
+	        if ( declarations.contains( identifier) ) {
+				rc.addRestriction( new VariableRestrictionDescr(op, identifier ) );
+		 	} else {
+		 		FieldBindingDescr fbd = new FieldBindingDescr();
+		 		fbd.setIdentifier( identifier );		
+		 		fbd.setFieldName( fcBase.getFieldName() ); 		
+		 		ceBase.addDescr( fbd );
+		 		declarations.add( identifier );
+		 	}
+		}
+	;	
+
+	
+literal_restriction returns [String text]
+	@init {
+		text = null;
+	}
+	:
+	    t=literal {
+	    	text = t;
+	    }
+	;
+
+/* 
+eval_sExpressions[MVELClipsContext context] returns[List<SExpression> list]
+    @init {
+		list = new ArrayList<SExpression>();
+    }
+	:
+		(  	a=lisp_list { list.add( a ); }
+		   | a=deffunction { FunctionHandlers.dump(a, null, context); }
+		)*
+//		{ sExpressions = ( SExpression[] ) list.toArray( new SExpression[ list.size () ] ); }
+	;
+*/	
+lisp_form returns[LispForm lispForm]
+    @init {
+        List list = new ArrayList();
+        lispForm = null;
+    }
+	:	LEFT_PAREN	
+	
+		(
+		    t=NAME { list.add( new SymbolLispAtom( t.getText() ) ); }
+		    |
+		    t=VAR { list.add( new VariableLispAtom( t.getText() ) ); }	    
+	    )
+		(		a=lisp_atom	{ list.add( a ); }
+			|	l=lisp_form	{ list.add( l ); }
+		)*								    	
+	    RIGHT_PAREN
+	    { lispForm = new LispForm( ( SExpression[] ) list.toArray( new SExpression[ list.size () ] ) ); }
+	;
+	
+lisp_atom returns[SExpression sExpression] 
+	@init {
+		sExpression  =  null;		
+	}
+	:		
+		(		
+			 	t=VAR		{ sExpression = new VariableLispAtom( t.getText() ); }
+			|	t=STRING	{ sExpression = new StringLispAtom( getString( t ) ); }											
+			|	t=FLOAT		{ sExpression = new FloatLispAtom( t.getText() ); }
+			|	t=INT		{ sExpression = new IntLispAtom( t.getText() ); }
+			| 	t=BOOL		{ sExpression = new BoolLispAtom( t.getText() ); }			
+			| 	t=NULL		{ sExpression = new NullLispAtom( null ); }						
+	        |   t=NAME		{ sExpression = new SymbolLispAtom( "\"" +t.getText() + "\""); }				
+
+		)		
+	;		
+	
+
+deftemplate returns[TypeDeclarationDescr typeDescr]
+    :
+    loc=LEFT_PAREN 
+    DEFTEMPLATE deftemplateName=NAME	{ 	  			  		
+	  		debug( "start rule: " + deftemplateName.getText() );
+	  		String templateStr = deftemplateName.getText();
+
+            String mod = null;
+	        if ( templateStr.indexOf("::") >= 0 ) {
+                mod = templateStr.substring(0, templateStr.indexOf("::"));
+	            templateStr = templateStr.substring(templateStr.indexOf("::")+2);
+			}		    
+		    
+		    typeDescr = new TypeDeclarationDescr( templateStr );
+		    if( mod != null ) {
+		        typeDescr.setNamespace( mod );
+		    }		    
+		        
+			typeDescr.setLocation( offset(loc.getLine()), loc.getCharPositionInLine() );
+			typeDescr.setStartCharacter( ((CommonToken)loc).getStartIndex() ); 
+		
+											
+		}    
+		
+	documentation=STRING {
+		// do nothing here for now
+	}   
+	
+	    /*
+	    // can't get this to work, so process manually as a lisp_form
+    (LEFT_PAREN     
+    'slot' slotName=NAME
+        LEFT_PAREN 
+             'type' slotType=NAME {
+            typeDescr.addField( new TypeFieldDescr(slotName.getText(), new PatternDescr( slotType.getText() ) ) );
+        }        
+        RIGHT_PAREN 
+    RIGHT_PAREN)*
+	*/
+	
+	(list=lisp_form { addTypeFieldDescr(list, typeDescr); })*
+
+    RIGHT_PAREN
+    ;   
+	
+	
+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; }
+        ;                      
+
+     
+DEFTEMPLATE :   'deftemplate';
+  
+//SLOT        :	'slot';       
+DEFRULE		:	'defrule';
+DEFFUNCTION :	'deffunction';
+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 	: '?' SYMBOL_CHAR+
+        ;            
+
+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 : FIRST_SYMBOL_CHAR SYMBOL_CHAR* ;	
+
+// allowed <
+// not allowed ?
+fragment
+FIRST_SYMBOL_CHAR : ('a'..'z'|'A'..'Z'|'0'..'9'|'!'|'$'|'%'|'^'|'*'|'_'|'-'|'+'|'='|'\\'|'/'|'@'|'#'|':'|'>'|'<'|','|'.'|'['|']'|'{'|'}');	
+
+// allowed ? 
+// not allowed <
+fragment
+SYMBOL_CHAR : ('a'..'z'|'A'..'Z'|'0'..'9'|'!'|'$'|'%'|'^'|'*'|'_'|'-'|'+'|'='|'\\'|'/'|'@'|'#'|':'|'>'|','|'.'|'['|']'|'{'|'}'|'?');		

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/resources/org/drools/clips/functions.conf
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/resources/org/drools/clips/functions.conf	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/main/resources/org/drools/clips/functions.conf	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,28 @@
+#working with vars
+org.drools.clp.functions.BindFunction
+org.drools.clp.functions.ModifyFunction
+org.drools.clp.functions.CreateListFunction
+
+#flow control
+org.drools.clp.functions.IfFunction
+org.drools.clp.functions.BreakFunction
+org.drools.clp.functions.SwitchFunction
+org.drools.clp.functions.SwitchCaseFunction
+org.drools.clp.functions.SwitchDefaultFunction
+org.drools.clp.functions.WhileFunction
+org.drools.clp.functions.ForeachFunction
+org.drools.clp.functions.PrognFunction
+
+#math comparators
+org.drools.clp.functions.LessThanFunction
+org.drools.clp.functions.GreaterThanOrEqualFunction
+org.drools.clp.functions.EqFunction
+
+#math operators
+org.drools.clp.functions.PlusFunction
+org.drools.clp.functions.MinusFunction
+org.drools.clp.functions.DivideFunction
+org.drools.clp.functions.MultiplyFunction
+
+#io
+org.drools.clp.functions.PrintoutFunction

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/Cheese.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/Cheese.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/Cheese.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,84 @@
+/**
+ * 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.
+ */
+
+package org.drools;
+
+import java.io.Serializable;
+
+public class Cheese
+    implements
+    Serializable {
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 510l;
+    private String            type;
+    private int               price;
+
+    public Cheese() {
+
+    }
+
+    public Cheese(final String type,
+                  final int price) {
+        super();
+        this.type = type;
+        this.price = price;
+    }
+
+    public int getPrice() {
+        return this.price;
+    }
+
+    public String getType() {
+        return this.type;
+    }
+
+    public void setType(final String type) {
+        this.type = type;
+    }
+
+    public void setPrice(final int price) {
+        this.price = price;
+    }
+
+    public String toString() {
+        return "Cheese( type='" + this.type + "', price=" + this.price + " )";
+    }
+
+    public int hashCode() {
+        final int PRIME = 31;
+        int result = 1;
+        result = PRIME * result + price;
+        result = PRIME * result + ((type == null) ? 0 : type.hashCode());
+        return result;
+    }
+
+    public boolean equals(Object obj) {
+        if ( this == obj ) return true;
+        if ( obj == null ) return false;
+        if ( getClass() != obj.getClass() ) return false;
+        final Cheese other = (Cheese) obj;
+        if ( price != other.price ) return false;
+        if ( type == null ) {
+            if ( other.type != null ) return false;
+        } else if ( !type.equals( other.type ) ) return false;
+        return true;
+    }
+    
+    
+
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/Person.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/Person.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/Person.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,250 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+public class Person
+    implements
+    Serializable,
+    PersonInterface {
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 510l;
+    private String            name;
+    private String            likes;
+    private int               age;
+    private BigDecimal        bigDecimal;
+    private BigInteger        bigInteger;
+    private String            hair;
+
+    private char              sex;
+
+    private boolean           alive;
+
+    private String            status;
+
+    private Cheese            cheese;
+
+    public Person() {
+
+    }
+
+    public Person(final String name) {
+        this( name,
+              "",
+              0 );
+    }
+
+    public Person(final String name,
+                  final String likes) {
+        this( name,
+              likes,
+              0 );
+    }
+
+    public Person(final String name,
+                  final String likes,
+                  final int age) {
+        this.name = name;
+        this.likes = likes;
+        this.age = age;
+    }
+    
+    public void setFields(String name, String likes, int age) {
+        this.name = name;
+        this.likes = likes;
+        this.age = age;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.PersonInterface#getStatus()
+     */
+    public String getStatus() {
+        return this.status;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.PersonInterface#setStatus(java.lang.String)
+     */
+    public void setStatus(final String status) {
+        this.status = status;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.PersonInterface#getLikes()
+     */
+    public String getLikes() {
+        return this.likes;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.PersonInterface#getName()
+     */
+    public String getName() {
+        return this.name;
+    }
+
+    public void setName(final String name) {
+        this.name = name;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.PersonInterface#getAge()
+     */
+    public int getAge() {
+        return this.age;
+    }
+
+    public void setAge(final int age) {
+        this.age = age;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.PersonInterface#isAlive()
+     */
+    public boolean isAlive() {
+        return this.alive;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.PersonInterface#setAlive(boolean)
+     */
+    public void setAlive(final boolean alive) {
+        this.alive = alive;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.PersonInterface#getSex()
+     */
+    public char getSex() {
+        return this.sex;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.PersonInterface#setSex(char)
+     */
+    public void setSex(final char sex) {
+        this.sex = sex;
+    }
+
+    public String getHair() {
+        return this.hair;
+    }
+
+    public void setHair(final String hair) {
+        this.hair = hair;
+    }
+
+    public String toLongString() {
+        return "[Person name='" + this.name + "' likes='" + this.likes + "' age='" + this.age + "']";
+    }
+    
+    public String toString() {
+        return "[Person name='" + this.name + "']";
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public int hashCode() {
+        final int PRIME = 31;
+        int result = 1;
+        result = PRIME * result + this.age;
+        result = PRIME * result + (this.alive ? 1231 : 1237);
+        result = PRIME * result + ((this.name == null) ? 0 : this.name.hashCode());
+        result = PRIME * result + this.sex;
+        return result;
+    }
+
+    /**
+     * @inheritDoc
+     */
+    public boolean equals(final Object obj) {
+        if ( this == obj ) {
+            return true;
+        }
+        if ( obj == null ) {
+            return false;
+        }
+        if ( getClass() != obj.getClass() ) {
+            return false;
+        }
+        final Person other = (Person) obj;
+        if ( this.age != other.age ) {
+            return false;
+        }
+        if ( this.alive != other.alive ) {
+            return false;
+        }
+        if ( this.name == null ) {
+            if ( other.name != null ) {
+                return false;
+            }
+        } else if ( !this.name.equals( other.name ) ) {
+            return false;
+        }
+        if ( this.sex != other.sex ) {
+            return false;
+        }
+        return true;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.PersonInterface#getBigDecimal()
+     */
+    public BigDecimal getBigDecimal() {
+        return this.bigDecimal;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.PersonInterface#setBigDecimal(java.math.BigDecimal)
+     */
+    public void setBigDecimal(final BigDecimal bigDecimal) {
+        this.bigDecimal = bigDecimal;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.PersonInterface#getBigInteger()
+     */
+    public BigInteger getBigInteger() {
+        return this.bigInteger;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.PersonInterface#setBigInteger(java.math.BigInteger)
+     */
+    public void setBigInteger(final BigInteger bigInteger) {
+        this.bigInteger = bigInteger;
+    }
+
+    public void setLikes(final String likes) {
+        this.likes = likes;
+    }
+
+    public Cheese getCheese() {
+        return this.cheese;
+    }
+
+    public void setCheese(final Cheese cheese) {
+        this.cheese = cheese;
+    }
+
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/PersonInterface.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/PersonInterface.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/PersonInterface.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,50 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+public interface PersonInterface {
+
+    public abstract String getStatus();
+
+    public abstract void setStatus(String status);
+
+    public abstract String getLikes();
+
+    public abstract String getName();
+
+    public abstract int getAge();
+
+    public abstract boolean isAlive();
+
+    public abstract void setAlive(boolean alive);
+
+    public abstract char getSex();
+
+    public abstract void setSex(char sex);
+
+    public abstract BigDecimal getBigDecimal();
+
+    public abstract void setBigDecimal(BigDecimal bigDecimal);
+
+    public abstract BigInteger getBigInteger();
+
+    public abstract void setBigInteger(BigInteger bigInteger);
+
+}
\ No newline at end of file

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/clips/ClipsShellTest.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/clips/ClipsShellTest.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/clips/ClipsShellTest.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,480 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.lang.reflect.Method;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+import org.drools.Person;
+import org.drools.WorkingMemory;
+import org.drools.clips.functions.AssertFunction;
+import org.drools.clips.functions.BindFunction;
+import org.drools.clips.functions.CallFunction;
+import org.drools.clips.functions.CreateListFunction;
+import org.drools.clips.functions.EqFunction;
+import org.drools.clips.functions.GetFunction;
+import org.drools.clips.functions.IfFunction;
+import org.drools.clips.functions.LessThanFunction;
+import org.drools.clips.functions.LessThanOrEqFunction;
+import org.drools.clips.functions.MinusFunction;
+import org.drools.clips.functions.ModifyFunction;
+import org.drools.clips.functions.MoreThanFunction;
+import org.drools.clips.functions.MoreThanOrEqFunction;
+import org.drools.clips.functions.MultiplyFunction;
+import org.drools.clips.functions.NewFunction;
+import org.drools.clips.functions.PlusFunction;
+import org.drools.clips.functions.PrintoutFunction;
+import org.drools.clips.functions.PrognFunction;
+import org.drools.clips.functions.ReturnFunction;
+import org.drools.clips.functions.RunFunction;
+import org.drools.clips.functions.SetFunction;
+import org.drools.clips.functions.SwitchFunction;
+import org.drools.common.InternalRuleBase;
+import org.drools.rule.Package;
+import org.drools.rule.Rule;
+
+public class ClipsShellTest {
+    private ByteArrayOutputStream baos;
+
+    ClipsShell                    shell;
+
+    @Before
+    public void setUp() {
+        FunctionHandlers handlers = FunctionHandlers.getInstance();
+        handlers.registerFunction( new PlusFunction() );
+        handlers.registerFunction( new MinusFunction() );
+        handlers.registerFunction( new MultiplyFunction() );
+        handlers.registerFunction( new ModifyFunction() );
+        handlers.registerFunction( new CreateListFunction() );
+        handlers.registerFunction( new PrintoutFunction() );
+        handlers.registerFunction( new PrognFunction() );
+        handlers.registerFunction( new IfFunction() );
+        handlers.registerFunction( new LessThanFunction() );
+        handlers.registerFunction( new LessThanOrEqFunction() );
+        handlers.registerFunction( new MoreThanFunction() );
+        handlers.registerFunction( new MoreThanOrEqFunction() );
+        handlers.registerFunction( new EqFunction() );
+        handlers.registerFunction( new SwitchFunction() );
+        //handlers.registerFunction( new DeffunctionFunction() );
+        handlers.registerFunction( new ReturnFunction() );
+        handlers.registerFunction( new RunFunction() );
+        handlers.registerFunction( new BindFunction() );
+        handlers.registerFunction( new NewFunction() );
+        handlers.registerFunction( new SetFunction() );
+        handlers.registerFunction( new GetFunction() );
+        handlers.registerFunction( new CallFunction() );
+        handlers.registerFunction( new AssertFunction() );
+
+        this.shell = new ClipsShell();
+
+        this.baos = new ByteArrayOutputStream();
+        shell.addRouter( "t",
+                         new PrintStream( baos ) );
+    }
+
+    //    public void test1() {
+    //        String expr = "(* (+ 4 4 ) 2) (create$ 10 20 (+ 10 10) a) (modify ?p (name mark) (location \"london\")(age (+ 16 16) ) ) (printout t a b c (+ 4 4) )";
+    //
+    //        SExpression[] lisplists = evalString( expr );
+    //
+    //        StringBuilderAppendable appendable = new StringBuilderAppendable();
+    //        MVELClipsContext context = new MVELClipsContext();
+    //        for ( SExpression sExpression : lisplists ) {
+    //            FunctionHandlers.dump( sExpression, appendable, context );
+    //        }
+    //
+    //        System.out.println( appendable );
+    //    }
+
+    @Test
+    public void testBind() {
+        String expr = "(bind ?x (create$ 10 20 30) ) (printout t ?x)";
+
+        this.shell.eval( expr );
+
+        assertEquals( "[10, 20, 30]",
+                      new String( baos.toByteArray() ) );
+    }
+
+    @Test
+    public void testProgn() {
+        String expr = "(progn (?x (create$ 10 20 30) ) (printout t ?x) )";
+
+        this.shell.eval( expr );
+
+        assertEquals( "102030",
+                      new String( baos.toByteArray() ) );
+    }
+
+    @Test
+    public void testIf() {
+        String expr = "(if (< 1 3) then (printout t hello) (printout t hello) )";
+
+        this.shell.eval( expr );
+
+        assertEquals( "hellohello",
+                      new String( baos.toByteArray() ) );
+
+        if ( 1 <= 10 ) {
+
+        }
+    }
+
+    @Test
+    public void testIfElse() {
+        String expr = "(if (eq 1 3) then (printout t hello)  (printout t 1) else (printout t hello)  (printout t 2))";
+
+        this.shell.eval( expr );
+
+        assertEquals( "hello2",
+                      new String( baos.toByteArray() ) );
+    }
+
+    @Test
+    public void testSwitch() throws IOException {
+        String expr = "(switch (?x) (case a then (printout t hello)(printout t 1)) (case b then (printout t hello)(printout t 2)) (default (printout t hello)(printout t 3)) )";
+
+        // check case a
+        this.shell.addVariable( "$x",
+                                "a" );
+        this.shell.eval( expr );
+        assertEquals( "hello1",
+                      new String( baos.toByteArray() ) );
+
+        // check default
+        this.shell.addVariable( "$x",
+                                "M" );
+        this.shell.eval( expr );
+        assertEquals( "hello1hello3",
+                      new String( baos.toByteArray() ) );
+
+        // check case b
+        this.shell.addVariable( "$x",
+                                "b" );
+        this.shell.eval( expr );
+        assertEquals( "hello1hello3hello2",
+                      new String( baos.toByteArray() ) );
+    }
+
+    // @FIXME - org.mvel.CompileException: unable to resolve property: unable to resolve method: org.drools.clips.Shell.max(java.lang.Integer, java.lang.Integer) [arglength=2]
+    @Test @Ignore
+    public void testDeffunction() {
+        String function = "(deffunction max (?a ?b) (if (> ?a ?b) then (return ?a) else (return ?b) ) )";
+        this.shell.eval( function );
+
+        String expr = "(if (eq (max 3 5) 5) then (printout t hello) )";
+        this.shell.eval( expr );
+        assertEquals( "hello",
+                      new String( baos.toByteArray() ) );
+
+        expr = "(if (eq (max ?a ?b) 5) then (printout t hello) )";
+        this.shell.addVariable( "$a",
+                                "3" );
+        this.shell.addVariable( "$b",
+                                "5" );
+        this.shell.eval( expr );
+        assertEquals( "hellohello",
+                      new String( baos.toByteArray() ) );
+    }
+
+    @Test
+    public void testDirectImportAndNew() {
+        String t = "(import org.drools.Person) (bind ?p (new Person mark cheddar) ) (printout t ?p)";
+        this.shell.eval( t );
+        assertEquals( "[Person name='mark']",
+                      new String( this.baos.toByteArray() ) );
+    }
+
+    @Test
+    public void testDynamicImportAndNew() {
+        String t = "(import org.drools.*) (bind ?p (new Person mark cheddar) ) (printout t ?p)";
+        this.shell.eval( t );
+        assertEquals( "[Person name='mark']",
+                      new String( this.baos.toByteArray() ) );
+    }
+
+    @Test
+    public void testSet() {
+        String t = "(import org.drools.*) (bind ?p (new Person mark cheddar) ) (set ?p name bob) (printout t ?p)";
+        this.shell.eval( t );
+        assertEquals( "[Person name='bob']",
+                      new String( this.baos.toByteArray() ) );
+    }
+
+    @Test
+    public void testGet() {
+        String t = "(import org.drools.*) (bind ?p (new Person mark cheddar) )(printout t (get ?p name))";
+        this.shell.eval( t );
+        assertEquals( "mark",
+                      new String( this.baos.toByteArray() ) );
+    }
+
+    @Test
+    public void testExplicitCall() {
+        String t = "(import org.drools.*) (bind ?p (new Person mark cheddar) ) (call ?p setFields bob stilton 35)  (printout t (call ?p toLongString))";
+        this.shell.eval( t );
+        assertEquals( "[Person name='bob' likes='stilton' age='35']",
+                      new String( this.baos.toByteArray() ) );
+    }
+
+    @Test
+    public void testImplicitCall() {
+        String t = "(import org.drools.*) (bind ?p (new Person mark cheddar) ) (?p setFields bob stilton 35)  (printout t (call ?p toLongString))";
+        this.shell.eval( t );
+        assertEquals( "[Person name='bob' likes='stilton' age='35']",
+                      new String( this.baos.toByteArray() ) );
+    }
+
+    @Test @Ignore
+    public void testRuleCreation() {
+        this.shell.eval( "(import org.drools.Person)" );
+
+        this.shell.eval( "(defrule yyy  => (printout t yy \" \" (eq 1 1) ) ) )" );
+        Package pkg = shell.getStatefulSession().getRuleBase().getPackage( "MAIN" );
+
+        Rule rule = pkg.getRule( "yyy" );
+        assertEquals( "yyy",
+                      rule.getName() );
+
+        this.shell.eval( "(defrule xxx (Person (name ?name&bob) (age 30) ) (Person  (name ?name) (age 35)) => (printout t xx \" \" (eq 1 1) ) )" );
+
+        rule = pkg.getRule( "xxx" );
+        assertEquals( "xxx",
+                      rule.getName() );
+
+        assertEquals( 2,
+                      pkg.getRules().length );
+
+        assertTrue( pkg.getImports().containsKey( "org.drools.Person" ) );
+
+        WorkingMemory wm = shell.getStatefulSession();
+        wm.insert( new Person( "bob",
+                               "cheddar",
+                               30 ) );
+        wm.insert( new Person( "bob",
+                               "stilton",
+                               35 ) );
+        wm.fireAllRules();
+        assertEquals( "yy truexx true",
+                      new String( this.baos.toByteArray() ) );
+    }
+
+    @Test @Ignore
+    public void testTemplateCreation2() throws Exception {
+        this.shell.eval( "(deftemplate PersonTemplate (slot name (type String) ) (slot age (type int) ) )" );
+        this.shell.eval( "(defrule xxx (PersonTemplate (name ?name&bob) (age 30) ) (PersonTemplate  (name ?name) (age 35)) => (printout t xx \" \" (eq 1 1) ) )" );
+        this.shell.eval( "(assert (PersonTemplate (name 'mike') (age 34)))" );
+
+        Class personClass = ((InternalRuleBase)this.shell.getStatefulSession().getRuleBase()).getRootClassLoader().loadClass( "MAIN.PersonTemplate" );
+        assertNotNull( personClass );
+    }
+
+    @Test @Ignore
+    public void testTemplateCreation() throws Exception {
+        this.shell.eval( "(deftemplate Person (slot name (type String) ) (slot age (type int) ) )" );
+
+        this.shell.eval( "(defrule xxx (Person (name ?name&bob) (age 30) ) => (printout t hello bob ) )" );
+
+        this.shell.eval( "(assert (Person (name bob) (age 30) ) )" );
+        this.shell.eval( "(run)" );
+
+        assertEquals( "hellobob",
+                      new String( this.baos.toByteArray() ) );
+    }
+
+    @Test @Ignore
+    public void testTemplateCreationWithJava() throws Exception {
+        this.shell.eval( "(deftemplate Person (slot name (type String) ) (slot age (type int) ) )" );
+
+        this.shell.eval( "(defrule yyy  => (printout t yy \" \" (eq 1 1) ) ) )" );
+        Package pkg = shell.getStatefulSession().getRuleBase().getPackage( "MAIN" );
+
+        Rule rule = pkg.getRule( "yyy" );
+        assertEquals( "yyy",
+                      rule.getName() );
+
+        this.shell.eval( "(defrule xxx (Person (name ?name&bob) (age 30) ) (Person  (name ?name) (age 35)) => (printout t xx \" \" (eq 1 1) ) )" );
+
+        rule = pkg.getRule( "xxx" );
+        assertEquals( "xxx",
+                      rule.getName() );
+
+        assertEquals( 2,
+                      pkg.getRules().length );
+
+        WorkingMemory wm = shell.getStatefulSession();
+        Class personClass = ((InternalRuleBase)this.shell.getStatefulSession().getRuleBase()).getRootClassLoader().loadClass( "MAIN.Person" );
+
+        Method nameMethod = personClass.getMethod( "setName",
+                                                   new Class[]{String.class} );
+        Method ageMethod = personClass.getMethod( "setAge",
+                                                  new Class[]{int.class} );
+
+        Object bob1 = personClass.newInstance();
+        nameMethod.invoke( bob1,
+                           "bob" );
+        ageMethod.invoke( bob1,
+                          30 );
+
+        Object bob2 = personClass.newInstance();
+        nameMethod.invoke( bob2,
+                           "bob" );
+        ageMethod.invoke( bob2,
+                          35 );
+        //Constructor constructor = personClass.getConstructor( new Class[] { String.class,String.class, int.class} );
+        wm.insert( bob1 );
+        wm.insert( bob2 );
+
+        wm.fireAllRules();
+        assertEquals( "yy truexx true",
+                      new String( this.baos.toByteArray() ) );
+    }
+
+    @Test @Ignore
+    public void testEmptyLHSRule() {
+        String rule1 = "(defrule testRule => (printout t hello) (printout t goodbye))";
+        this.shell.eval( rule1 );
+        assertEquals( "hellogoodbye",
+                      new String( this.baos.toByteArray() ) );
+    }
+
+    @Test @Ignore
+    public void testSimpleLHSRule() {
+        this.shell.eval( "(import org.drools.*)" );
+        this.shell.eval( "(defrule testRule (Person (name ?name&mark) ) => (printout t hello) (printout t \" \" ?name))" );
+        this.shell.eval( "(assert (Person (name mark) ) )" );
+        this.shell.eval( "(run)" );
+        assertEquals( "hello mark",
+                      new String( this.baos.toByteArray() ) );
+    }
+
+    @Test @Ignore
+    public void testRuleCallDeftemplate() {
+        String function = "(deffunction max (?a ?b) (if (> ?a ?b) then (return ?a) else (return ?b) ) )";
+        this.shell.eval( function );
+
+        this.shell.eval( "(import org.drools.*)" );
+        this.shell.eval( "(defrule testRule (Person (age ?age) ) => (printout t hello) (printout t \" \" (max 3 ?age) ) )" );
+        this.shell.eval( "(assert (Person (name mark) (age 32) ) )" );
+        this.shell.eval( "(run)" );
+        assertEquals( "hello 32",
+                      new String( this.baos.toByteArray() ) );
+    }
+
+    @Test @Ignore
+    public void testTwoSimpleRulesWithModify() {
+        this.shell.eval( "(import org.drools.*)" );
+        this.shell.eval( "(defrule testRule1 ?p <- (Person (name ?name&mark) ) => (printout t hello) (printout t \" \" ?name) (modify ?p (name bob) ) )" );
+        this.shell.eval( "(defrule testRule2 (Person (name ?name&bob) ) => (printout t hello) (printout t \" \" ?name))" );
+        this.shell.eval( "(assert (Person (name mark) ) )" );
+        this.shell.eval( "(run)" );
+        assertEquals( "hello markhello bob",
+                      new String( this.baos.toByteArray() ) );
+    }
+
+    @Test @Ignore
+    public void testBlockEval() {
+        String text = "(import org.drools.*)";
+        text += "(defrule testRule1 ?p <- (Person (name ?name&mark) ) => (printout t hello) (printout t \" \" ?name) (modify ?p (name bob) ) )";
+        text += "(defrule testRule2 (Person (name ?name&bob) ) => (printout t hello) (printout t \" \" ?name))";
+        text += "(assert (Person (name mark) ) )";
+        text += "(run)";
+        this.shell.eval( text );
+        assertEquals( "hello markhello bob",
+                      new String( this.baos.toByteArray() ) );
+    }
+
+    @Test @Ignore
+    public void testPredicate() {
+        this.shell.eval( "(import org.drools.Person)" );
+        this.shell.eval( "(defrule testRule1 (Person (name ?name) (age ?age&:(> ?age 30)) ) => (printout t hello) (printout t \" \" ?name) )" );
+        this.shell.eval( "(assert (Person (name mark) (age 27) ) )" );
+        this.shell.eval( "(assert (Person (name bob) (age 35) ) )" );
+        this.shell.eval( "(run)" );
+        assertEquals( "hello bob",
+                      new String( this.baos.toByteArray() ) );
+    }
+
+    @Test @Ignore
+    public void testReturnValue() {
+        this.shell.eval( "(import org.drools.Person)" );
+        this.shell.eval( "(defrule testRule1 (Person (age ?age) ) (Person (name ?name) (age =(- ?age 3)) ) => (printout t hello) (printout t \" \" ?name) )" );
+        this.shell.eval( "(assert (Person (name mark) (age 32) ) )" );
+        this.shell.eval( "(assert (Person (name bob) (age 35) ) )" );
+        this.shell.eval( "(run)" );
+        assertEquals( "hello mark",
+                      new String( this.baos.toByteArray() ) );
+    }
+
+    @Test @Ignore
+    public void testTest() {
+        this.shell.eval( "(import org.drools.Person)" );
+        this.shell.eval( "(defrule testRule1 (Person (age ?age1) ) (Person (name ?name) (age ?age2) ) (test(eq ?age1 (+ ?age2 3) )) => (printout t hello) )" );
+        this.shell.eval( "(assert (Person (name mark) (age 32) ) )" );
+        this.shell.eval( "(assert (Person (name bob) (age 35) ) )" );
+        this.shell.eval( "(run)" );
+        assertEquals( "hello",
+                      new String( this.baos.toByteArray() ) );
+    }
+
+    @Test
+    public void testRun() {
+        this.shell.eval( "(run)" );
+    }
+
+    @Test @Ignore
+    public void testMixed() {
+        this.shell.eval( "(import org.drools.Cheese)" );
+        String str ="";
+        str += "(deftemplate Person ";
+        str += "  (slot name ";
+        str += "    (type String) ) ";
+        str += "  (slot age";
+        str += "    (type String) ) ";
+        str += "  (slot location";
+        str += "    (type String) ) ";        
+        str += "  (slot cheese";
+        str += "    (type String) ) ";
+        str += ")";
+        this.shell.eval( str );
+        this.shell.eval( "(deffunction max (?a ?b) (if (> ?a ?b) then (return ?a) else (return ?b) ) )" );
+
+        str = "";
+        str += "(defrule sendsomecheese ";
+        str += "  (Person (name ?name) (age ?personAge) (cheese ?cheeseType) (location \"london\") ) ";
+        str += "  (Cheese (type ?cheeseType) (price ?cheesePrice&:(eq (max ?personAge ?cheesePrice) ?cheesePrice)  ) )";
+        str += "\n=>\n";
+        str += "  (printout t \"send some \" ?cheeseType \" \" to \" \" ?name) ";
+        str += ")";
+        this.shell.eval( str );
+        
+        this.shell.eval( "(assert (Person (name mark) (location \"london\") (cheese \"cheddar\") (age 25) ) )" );
+        this.shell.eval( "(assert (Cheese (type \"cheddar\") (price  30) ) ) " );
+        this.shell.eval( "(run)" );
+        
+        assertEquals( "send some cheddar to mark",
+                      new String( this.baos.toByteArray() ) );        
+    }
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/clips/CompiledFunctionsTest.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/clips/CompiledFunctionsTest.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/clips/CompiledFunctionsTest.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,342 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips;
+
+import org.junit.Ignore;
+
+
+ at Ignore
+public class CompiledFunctionsTest { //extends TestCase {
+//    private CLPParser parser;
+//
+//    public void testPrintout() throws Exception {        
+//        BlockExecutionEngine engine = (BlockExecutionEngine) parse( "(printout d xx (eq 1 1) ?c (create$ (+ 1 1) x y) zzz)" ).execution_block();
+//        ExecutionContext context = new ExecutionContextImpl( null,
+//                                                         null,
+//                                                         1 );
+//
+//        Map vars = new HashMap();
+//        vars.put( "?c",
+//                  new ObjectValueHandler( "brie" ) );
+//        engine.replaceTempTokens( vars );
+//
+//        ByteArrayOutputStream bais = new ByteArrayOutputStream();                
+//        context.addPrintoutRouter( "d", new PrintStream(bais) );
+//        
+//        engine.execute( context );
+//        
+//        assertEquals( "xxtruebrie2xyzzz", new String( bais.toByteArray() ) );
+//    }
+//    
+//    public void testBindAndModify() throws Exception {
+//        BlockExecutionEngine engine = (BlockExecutionEngine) parse( "(bind ?x (+ 20 11) ) (modify ?p (age ?x) )" ).execution_block();
+//        ExecutionContext context = new ExecutionContextImpl( 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) )" ).execution_block();
+//        ExecutionContext context = new ExecutionContextImpl( 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) )" ).execution_block();
+//        ExecutionContext context = new ExecutionContextImpl( 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) ) (printout d 15) else (modify ?p (age 5)) (printout d 5) )" ).execution_block();
+//        ExecutionContext context = new ExecutionContextImpl( null,
+//                                                         null,
+//                                                         2 );
+//
+//        Person p = new Person( "mark" );
+//        Map vars = new HashMap();
+//
+//        vars.put( "?x",
+//                  new LongValueHandler( 10 ) );
+//        vars.put( "?y",
+//                  new IndexedLocalVariableValue( "?y",
+//                                          0 ) );
+//        vars.put( "?p",
+//                  new ObjectValueHandler( p ) );
+//        engine.replaceTempTokens( vars );
+//
+//        context.setLocalVariable( 0,
+//                                  new LongValueHandler( 20 ) );        
+//        ByteArrayOutputStream bais = new ByteArrayOutputStream();                
+//        context.addPrintoutRouter( "d", new PrintStream(bais) );        
+//        engine.execute( context );
+//        assertEquals( 15,
+//                      p.getAge() );
+//        assertEquals( "15", new String( bais.toByteArray() ) );
+//        
+//        
+//        context.setLocalVariable( 0,
+//                                  new LongValueHandler( 7 ) );
+//        bais = new ByteArrayOutputStream();                
+//        context.addPrintoutRouter( "d", new PrintStream(bais) );          
+//        engine.execute( context );
+//        assertEquals( 5,
+//                      p.getAge() );
+//        assertEquals( "5", new String( bais.toByteArray() ) );
+//    }
+//
+//    public void testWhile() throws Exception {               
+//        BlockExecutionEngine engine = (BlockExecutionEngine) parse( "(while (< ?x ?y) do (bind ?x (+ ?x 1)) (printout d ?x \" \") )" ).execution_block();
+//        ExecutionContext context = new ExecutionContextImpl( null,
+//                                                         null,
+//                                                         2 );
+//
+//        Map vars = new HashMap();
+//
+//        vars.put( "?x",
+//                  new IndexedLocalVariableValue( "?x",
+//                                          0 ) );
+//        vars.put( "?y",
+//                  new IndexedLocalVariableValue( "?y",
+//                                          1 ) );
+//        engine.replaceTempTokens( vars );
+//
+//        context.setLocalVariable( 0,
+//                                  new LongValueHandler( 0 ) );
+//        context.setLocalVariable( 1,
+//                                  new LongValueHandler( 10 ) );
+//        
+//        ByteArrayOutputStream bais = new ByteArrayOutputStream();              
+//        context.addPrintoutRouter( "d", new PrintStream(bais) );                                
+//
+//        engine.execute( context );
+//        assertEquals( new BigDecimal( 10 ),
+//                      context.getLocalVariable( 0 ).getBigDecimalValue( context ) );
+//        
+//        assertEquals( "1 2 3 4 5 6 7 8 9 10 ", new String( bais.toByteArray() ) );        
+//    }
+//
+//    public void testForeach() throws Exception {
+//        BlockExecutionEngine engine = (BlockExecutionEngine) parse( "(bind ?x 0) (foreach ?e (create$ 1 2 3) (bind ?x (+ ?x ?e) ) (printout d ?x \" \") )" ).execution_block();
+//        ExecutionContext context = new ExecutionContextImpl( null,
+//                                                         null,
+//                                                         2 );
+//        
+//        ByteArrayOutputStream bais = new ByteArrayOutputStream();              
+//        context.addPrintoutRouter( "d", new PrintStream(bais) );         
+//        
+//        engine.execute( context );
+//        assertEquals( new BigDecimal( 6 ),
+//                      context.getLocalVariable( 0 ).getBigDecimalValue( context ) );
+//        
+//        assertEquals( "1 3 6 ", new String( bais.toByteArray() ) );          
+//    }
+//    
+//    public void testSwitch() throws Exception {
+//        BlockExecutionEngine engine = (BlockExecutionEngine) parse( "(bind ?cheese ?var) (switch ?cheese (case stilton then (bind ?x ?cheese ) (break) ) (case cheddar then (bind ?x ?cheese ) (break) ) (default (bind ?x \"default\" ) ) )" ).execution_block();
+//        ExecutionContext context = new ExecutionContextImpl( null,
+//                                                         null,
+//                                                         3 );
+//
+//        Map vars = new HashMap();
+//
+//        vars.put( "?var",
+//                  new IndexedLocalVariableValue( "?var",
+//                                          2 ) );        
+//        engine.replaceTempTokens( vars );
+//
+//        // try it with stilton
+//        context.setLocalVariable( 2,
+//                                  new ObjectValueHandler( "stilton" ) );
+//        engine.execute( context );        
+//        assertEquals( "stilton" ,
+//                      context.getLocalVariable( 1 ).getObject( context ) );
+//
+//        // try it with cheddar        
+//        context.setLocalVariable( 2,
+//                                  new ObjectValueHandler( "cheddar" ) );
+//        engine.execute( context );        
+//        assertEquals( "cheddar" ,
+//                      context.getLocalVariable( 1 ).getObject( context ) );        
+//        
+//        // try it with a brie, which has no matching case        
+//        context.setLocalVariable( 2,
+//                                  new ObjectValueHandler( "brie" ) );
+//        engine.execute( context );        
+//        assertEquals( "default" ,
+//                      context.getLocalVariable( 1 ).getObject( context ) );                          
+//    }    
+//    
+//    public void testProgn() throws Exception {
+//        BlockExecutionEngine engine = (BlockExecutionEngine) parse( "(bind ?n 2) (while (progn (bind ?n (* ?n ?n)) (< ?n 1000)) do (printout d ?n) )" ).execution_block();
+//        ExecutionContext context = new ExecutionContextImpl( null,
+//                                                         null,
+//                                                         2 );
+//        
+//        ByteArrayOutputStream bais = new ByteArrayOutputStream();              
+//        context.addPrintoutRouter( "d", new PrintStream(bais) );                                
+//
+//        engine.execute( context );
+//        
+//        assertEquals( "416256", new String( bais.toByteArray() ) );          
+//    }
+//    
+//    public void testDefTemplate() throws Exception {
+//        Deffunction engine = (Deffunction) parse( "(deffunction factorial (?n) (if (>= ?n 1) then (* ?n (factorial (- ?n 1))) else 1)) " ).deffunction();
+//        
+//        ExecutionContext context = new ExecutionContextImpl( null,
+//                                                         null,
+//                                                         1 );
+//
+//        ByteArrayOutputStream bais = new ByteArrayOutputStream();              
+//        context.addPrintoutRouter( "d", new PrintStream(bais) );                                              
+//        
+//        assertEquals( 720,engine.execute( new ValueHandler[] { new LongValueHandler( 6 ) }, context ).getBigDecimalValue( context ).longValue() );    
+//    }    
+//
+//    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 CommonTokenStream( lexer );
+//    }
+//
+//    private CLPParser newParser(final TokenStream tokenStream) {
+//        final CLPParser p = new CLPParser( tokenStream );
+//        p.setFunctionRegistry( new XFunctionRegistry( 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 );
+//    }
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/clips/FunctionFactoryTest.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/clips/FunctionFactoryTest.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/clips/FunctionFactoryTest.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,34 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class FunctionFactoryTest {
+    @Test
+    public void testInit() {
+//        XFunctionRegistry factory = new XFunctionRegistry( 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() );
+    }
+}

Added: labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/clips/LhsClpParserTest.java
===================================================================
--- labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/clips/LhsClpParserTest.java	                        (rev 0)
+++ labs/jbossrules/tags/5.2.0.M1/drools-clips/src/test/java/org/drools/clips/LhsClpParserTest.java	2011-02-24 15:26:37 UTC (rev 36697)
@@ -0,0 +1,428 @@
+/**
+ * Copyright 2010 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.
+ */
+
+package org.drools.clips;
+
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+import org.antlr.runtime.ANTLRStringStream;
+import org.antlr.runtime.CharStream;
+import org.antlr.runtime.CommonTokenStream;
+import org.drools.lang.descr.AndDescr;
+import org.drools.lang.descr.AttributeDescr;
+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.PatternDescr;
+import org.drools.lang.descr.PredicateDescr;
+import org.drools.lang.descr.RestrictionConnectiveDescr;
+import org.drools.lang.descr.ReturnValueRestrictionDescr;
+import org.drools.lang.descr.RuleDescr;
+
+public class LhsClpParserTest {
+
+    private ClipsParser parser;
+    
+    //XFunctionRegistry registry;
+    
+    @Before
+    public void setUp() {
+        //this.registry = new XFunctionRegistry( BuiltinFunctions.getInstance() );
+    }
+    
+    @After
+    public void tearDown() throws Exception {
+        //this.parser = null;
+    }
+
+    @Test
+    public void testParseFunction() throws Exception {
+//        BuildContext context = new ExecutionBuildContext( new CLPPredicate(), this.registry );
+//        FunctionCaller fc = ( FunctionCaller ) parse( "(< 1 2)" ).lisp_list( context, new LispForm2(context) );
+//        
+//        assertEquals( "<", fc.getName() );        
+//        assertEquals( new LongValueHandler( 1 ), fc.getParameters()[0] );
+//        assertEquals( new LongValueHandler( 2 ), fc.getParameters()[1] );
+    }
+    
+    @Test
+    public void testPatternsRule() throws Exception {
+        // the first pattern bellowshould generate a descriptor tree like that:
+        //            Pattern[person]
+        //                 |
+        //                AND
+        //               /   \
+        //              FB    FC[person name]
+        //                     |
+        //                     OR
+        //          +----------|------------+
+        //         LR         LR          AND
+        //                                /   \
+        //                              RVR   PC
+        
+        // MARK: is it valid to add a predicate restriction as part of a field constraint? I mean, shouldn't
+        // the predicate be out of the (name ...) scope? 
+        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 pattern
+        PatternDescr personPattern = (PatternDescr) lhsList.get( 0 );
+        assertEquals( "$b",
+                      personPattern.getIdentifier() );
+        assertEquals( "person",
+                      personPattern.getObjectType() );
+
+        List colList = personPattern.getDescrs();
+        assertEquals( 3,
+                      colList.size() );
+        
+        // first, we have a field binding
+        FieldBindingDescr fbd = (FieldBindingDescr) colList.get( 0 );
+        assertEquals( "$bf",
+                      fbd.getIdentifier() );
+        assertEquals( "name",
+                      fbd.getFieldName() );
+        
+        // then, we have a field constraint
+        FieldConstraintDescr fieldConstraintDescr = (FieldConstraintDescr) colList.get( 1 );
+        assertEquals( "name",
+                      fieldConstraintDescr.getFieldName() );                        
+        RestrictionConnectiveDescr root = (RestrictionConnectiveDescr) fieldConstraintDescr.getRestriction();
+        assertEquals( 1,
+                      root.getRestrictions().size() );
+        RestrictionConnectiveDescr or = (RestrictionConnectiveDescr) root.getRestrictions().get( 0 );
+        assertEquals( RestrictionConnectiveDescr.OR, 
+                      or.getConnective() );
+        
+        List restrictionList = or.getRestrictions();
+
+        assertEquals( 3,
+                      restrictionList.size() );
+
+        // first we have a literal restriction
+        LiteralRestrictionDescr litDescr = (LiteralRestrictionDescr) restrictionList.get( 0 );
+        assertEquals( "==",
+                      litDescr.getEvaluator() );
+        assertEquals( "yyy",
+                      litDescr.getText() );
+
+        // second, we have another literal restriction
+        litDescr = (LiteralRestrictionDescr) restrictionList.get( 1 );
+        assertEquals( "!=",
+                      litDescr.getEvaluator() );
+        assertEquals( "zzz",
+                      litDescr.getText() );
+        
+        ReturnValueRestrictionDescr retDescr = (ReturnValueRestrictionDescr) restrictionList.get( 2 );
+        assertEquals( "!=",
+                      retDescr.getEvaluator() );
+        
+        LispForm lispForm = ( LispForm ) retDescr.getContent();
+        assertEquals("(+ 2 3)", lispForm.toString() );                         
+
+        // ----------------
+        // this is how it would be compatible to our core engine 
+        PredicateDescr predicateDescr = (PredicateDescr) colList.get( 2 );
+        
+        lispForm = ( LispForm ) predicateDescr.getContent();
+        assertEquals("(< 1 2)", lispForm.toString() );                
+
+        // -----------------
+        // Parse the second column
+        PatternDescr hobbyPattern = (PatternDescr) lhsList.get( 1 );
+        assertEquals( "$c",
+                      hobbyPattern.getIdentifier() );
+        assertEquals( "hobby",
+                      hobbyPattern.getObjectType() );
+
+        colList = hobbyPattern.getDescrs();
+        assertEquals( 3,
+                      colList.size() );
+
+        fbd = (FieldBindingDescr) colList.get( 0 );
+        assertEquals( "$bf2",
+                      fbd.getIdentifier() );
+        assertEquals( "type",
+                      fbd.getFieldName() );
+        
+        fieldConstraintDescr = (FieldConstraintDescr) colList.get( 1 );
+        restrictionList = fieldConstraintDescr.getRestrictions();
+
+        assertEquals( "type",
+                      fieldConstraintDescr.getFieldName() );
+
+        assertEquals( RestrictionConnectiveDescr.AND,
+                      fieldConstraintDescr.getRestriction().getConnective() );
+
+        litDescr = (LiteralRestrictionDescr) restrictionList.get( 0 );
+        assertEquals( "!=",
+                      litDescr.getEvaluator() );
+        assertEquals( "iii",
+                      litDescr.getText() );
+
+        fieldConstraintDescr = (FieldConstraintDescr) colList.get( 2 );
+        restrictionList = fieldConstraintDescr.getRestrictions();
+
+        assertEquals( "rating",
+                      fieldConstraintDescr.getFieldName() );
+
+        litDescr = (LiteralRestrictionDescr) restrictionList.get( 0 );
+        assertEquals( "==",
+                      litDescr.getEvaluator() );
+        assertEquals( "fivestar",
+                      litDescr.getText() );
+    }
+
+    @Test
+    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
+        PatternDescr col = (PatternDescr) 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 = (PatternDescr) 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 = (PatternDescr) 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 = (PatternDescr) 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() );
+    }
+
+    @Test
+    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() );
+
+        PatternDescr col = (PatternDescr) 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 = (PatternDescr) 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 = (PatternDescr) 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() );  
+    }
+    
+    @Test
+    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 );
+        LispForm lispForm = ( LispForm ) evalDescr.getContent();
+        assertEquals("(< 9.0 1.3)", lispForm.toString() );                          
+    }
+
+    @Test
+    public void testRuleHeader() throws Exception {
+        RuleDescr rule = parse( "(defrule MAIN::name \"docs\"(declare (salience -100) ) => )" ).defrule();
+        
+        Map<String, AttributeDescr> attributes = rule.getAttributes();
+        AttributeDescr module = ( AttributeDescr ) attributes.get( "agenda-group" );
+        assertEquals( "agenda-group", module.getName() );
+        assertEquals( "MAIN", module.getValue() );
+        
+        assertEquals("name", rule.getName() );
+        
+        AttributeDescr dialect = ( AttributeDescr ) attributes.get( "dialect" );
+        assertEquals( "dialect", dialect.getName() );
+        assertEquals( "clips", dialect.getValue() );        
+        
+        AttributeDescr salience = ( AttributeDescr ) attributes.get( "salience" );
+        assertEquals( "salience", salience.getName() );
+        assertEquals( "-100", salience.getValue() );
+        
+        
+    }
+    
+    private ClipsParser parse(final String text) throws Exception {
+        return new ClipsParser( new CommonTokenStream( new ClipsLexer( new ANTLRStringStream( text ) ) ) );
+    }
+
+    private ClipsParser parse(final String source,
+                            final String text) throws Exception {
+        this.parser =  new ClipsParser( new CommonTokenStream( new ClipsLexer( new ANTLRStringStream( 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 ClipsParser 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 void assertEqualsIgnoreWhitespace(final String expected,
+                                              final String actual) {
+        final String cleanExpected = expected.replaceAll( "\\s+",
+                                                          "" );
+        final String cleanActual = actual.replaceAll( "\\s+",
+                                                      "" );
+
+        assertEquals( cleanExpected,
+                      cleanActual );
+    }
+
+}



More information about the jboss-svn-commits mailing list