Modified: 
incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/UnionAtom.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/UnionAtom.java?rev=1306390&r1=1306389&r2=1306390&view=diff
==============================================================================
--- 
incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/UnionAtom.java
 (original)
+++ 
incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/UnionAtom.java
 Wed Mar 28 15:00:06 2012
@@ -1,124 +1,98 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.stanbol.rules.manager.atoms;
 
-import org.apache.stanbol.rules.base.api.JenaClauseEntry;
-import org.apache.stanbol.rules.base.api.JenaVariableMap;
 import org.apache.stanbol.rules.base.api.RuleAtom;
-import org.apache.stanbol.rules.base.api.SPARQLObject;
 import org.apache.stanbol.rules.base.api.util.AtomList;
-import org.apache.stanbol.rules.manager.SPARQLFunction;
-import org.semanticweb.owlapi.model.OWLDataFactory;
-import org.semanticweb.owlapi.model.SWRLAtom;
-
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.Resource;
-import com.hp.hpl.jena.reasoner.rulesys.ClauseEntry;
-
 
 public class UnionAtom implements RuleAtom {
 
-       private AtomList atomList1;
-       private AtomList atomList2;
-       
-       public UnionAtom(AtomList atomList1, AtomList atomList2) {
-               this.atomList1 = atomList1;
-               this.atomList2 = atomList2;
-       }
-       
-       @Override
-       public Resource toSWRL(Model model) {
-               // TODO Auto-generated method stub
-               return null;
-       }
-
-       @Override
-       public SPARQLObject toSPARQL() {
-               String scope1 = "";
-               
-               for(RuleAtom kReSRuleAtom : atomList1){
-                       if(!scope1.isEmpty()){
-                               scope1 += " . ";
-                       }
-                       scope1 += kReSRuleAtom.toSPARQL().getObject();
-               }
-               
-               String scope2 = "";
-               
-               for(RuleAtom kReSRuleAtom : atomList2){
-                       if(!scope2.isEmpty()){
-                               scope2 += " . ";
-                       }
-                       scope2 += kReSRuleAtom.toSPARQL().getObject();
-               }
-               
-               String sparqlUnion = " { " + scope1 + " } UNION { " +scope2 + " 
} ";
-               
-               return new SPARQLFunction(sparqlUnion);
-       }
-
-       @Override
-       public SWRLAtom toSWRL(OWLDataFactory factory) {
-               // TODO Auto-generated method stub
-               return null;
-       }
-
-       @Override
-       public String toKReSSyntax() {
-               String scope1 = "";
-               
-               for(RuleAtom kReSRuleAtom : atomList1){
-                       if(!scope1.isEmpty()){
-                               scope1 += " . ";
-                       }
-                       scope1 += kReSRuleAtom.toKReSSyntax();
-               }
-               
-               String scope2 = "";
-               
-               for(RuleAtom kReSRuleAtom : atomList2){
-                       if(!scope2.isEmpty()){
-                               scope2 += " . ";
-                       }
-                       scope2 += kReSRuleAtom.toKReSSyntax();
-               }
-               
-               return "union(" + scope1 + ", " +scope2 + ")";
-       }
-       
-       @Override
-       public boolean isSPARQLConstruct() {
-               return false;
-       }
-       
-       @Override
-       public boolean isSPARQLDelete() {
-               return false;
-       }
-       
-       @Override
-       public boolean isSPARQLDeleteData() {
-               return false;
-       }
-
-       @Override
-       public JenaClauseEntry toJenaClauseEntry(JenaVariableMap 
jenaVariableMap) {
-               // TODO Auto-generated method stub
-               return null;
-       }
+    private AtomList atomList1;
+    private AtomList atomList2;
+
+    public UnionAtom(AtomList atomList1, AtomList atomList2) {
+        this.atomList1 = atomList1;
+        this.atomList2 = atomList2;
+    }
+
+    public AtomList getAtomList1() {
+        return atomList1;
+    }
+
+    public AtomList getAtomList2() {
+        return atomList2;
+    }
+
+    @Override
+    public String toString() {
+        String scope1 = "";
+
+        for (RuleAtom ruleAtom : atomList1) {
+            if (!scope1.isEmpty()) {
+                scope1 += " . ";
+            }
+            scope1 += ruleAtom.toString();
+        }
+
+        String scope2 = "";
+
+        for (RuleAtom ruleAtom : atomList2) {
+            if (!scope2.isEmpty()) {
+                scope2 += " . ";
+            }
+            scope2 += ruleAtom.toString();
+        }
+
+        return "union(" + scope1 + ", " + scope2 + ")";
+    }
+
+    @Override
+    public String prettyPrint() {
+        StringBuilder stringBuilder = new StringBuilder();
+
+        stringBuilder.append("the union of the set of conjunctive atoms {");
+
+        boolean first = true;
+        for (RuleAtom ruleAtom : atomList1) {
+            if (!first) {
+                stringBuilder.append(" AND ");
+            } else {
+                first = false;
+            }
+
+            stringBuilder.append(ruleAtom.toString());
+        }
+
+        stringBuilder.append("} with the set of conjunctive atoms {");
+
+        first = true;
+        for (RuleAtom ruleAtom : atomList2) {
+            if (!first) {
+                stringBuilder.append(" AND ");
+            } else {
+                first = false;
+            }
+
+            stringBuilder.append(ruleAtom.toString());
+        }
+
+        stringBuilder.append("}");
+
+        return stringBuilder.toString();
+    }
 
 }

Modified: 
incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/UpperCaseAtom.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/UpperCaseAtom.java?rev=1306390&r1=1306389&r2=1306390&view=diff
==============================================================================
--- 
incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/UpperCaseAtom.java
 (original)
+++ 
incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/UpperCaseAtom.java
 Wed Mar 28 15:00:06 2012
@@ -1,86 +1,41 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.stanbol.rules.manager.atoms;
 
-import org.apache.stanbol.rules.base.api.JenaClauseEntry;
-import org.apache.stanbol.rules.base.api.JenaVariableMap;
-import org.apache.stanbol.rules.base.api.SPARQLObject;
-import org.apache.stanbol.rules.manager.SPARQLFunction;
-import org.semanticweb.owlapi.model.OWLDataFactory;
-import org.semanticweb.owlapi.model.SWRLAtom;
-
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.Resource;
-import com.hp.hpl.jena.reasoner.rulesys.ClauseEntry;
+public class UpperCaseAtom extends StringFunctionAtom {
 
+    private StringFunctionAtom stringFunctionAtom;
 
-public class UpperCaseAtom extends StringFunctionAtom {
+    public UpperCaseAtom(StringFunctionAtom stringFunctionAtom) {
+        this.stringFunctionAtom = stringFunctionAtom;
+    }
+
+    public StringFunctionAtom getStringFunctionAtom() {
+        return stringFunctionAtom;
+    }
+
+    @Override
+    public String toString() {
+        return "upperCase(" + stringFunctionAtom.toString() + ")";
+    }
+
+    @Override
+    public String prettyPrint() {
+        return "the upper-case representation of " + 
stringFunctionAtom.prettyPrint();
+    }
 
-       private StringFunctionAtom stringFunctionAtom;
-       
-       public UpperCaseAtom(StringFunctionAtom stringFunctionAtom) {
-               this.stringFunctionAtom = stringFunctionAtom;
-       }
-
-       @Override
-       public Resource toSWRL(Model model) {
-               // TODO Auto-generated method stub
-               return null;
-       }
-
-       @Override
-       public SPARQLObject toSPARQL() {
-               
-               String uriResourceString = 
stringFunctionAtom.toSPARQL().getObject();
-               
-               
if(uriResourceString.startsWith("http://kres.iks-project.eu/ontology/meta/variables#";)){
-                       uriResourceString = 
"?"+uriResourceString.replace("http://kres.iks-project.eu/ontology/meta/variables#";,
 "");
-                       
-               }
-               
-               String sparql = 
"<http://www.w3.org/2005/xpath-functions#upper-case> (" + uriResourceString + 
")"; 
-                       
-               return new SPARQLFunction(sparql);
-       }
-
-       @Override
-       public SWRLAtom toSWRL(OWLDataFactory factory) {
-               // TODO Auto-generated method stub
-               return null;
-       }
-
-       @Override
-       public String toKReSSyntax() {
-               String uriResourceString = stringFunctionAtom.toKReSSyntax();
-               
-               
if(uriResourceString.startsWith("http://kres.iks-project.eu/ontology/meta/variables#";)){
-                       uriResourceString = 
"?"+uriResourceString.replace("http://kres.iks-project.eu/ontology/meta/variables#";,
 "");
-                       
-               }
-               
-               return "upperCase(" + uriResourceString + ")";
-       }
-
-       @Override
-       public JenaClauseEntry toJenaClauseEntry(JenaVariableMap 
jenaVariableMap) {
-               // TODO Auto-generated method stub
-               return null;
-       }
-       
-       
-       
 }

Modified: 
incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/VariableAtom.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/VariableAtom.java?rev=1306390&r1=1306389&r2=1306390&view=diff
==============================================================================
--- 
incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/VariableAtom.java
 (original)
+++ 
incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/atoms/VariableAtom.java
 Wed Mar 28 15:00:06 2012
@@ -1,59 +1,59 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.stanbol.rules.manager.atoms;
 
 import java.net.URI;
 
-import org.apache.stanbol.rules.base.api.URIResource;
+import org.apache.stanbol.rules.base.api.Symbols;
 
-import com.hp.hpl.jena.rdf.model.Model;
-import com.hp.hpl.jena.rdf.model.Resource;
+public class VariableAtom extends IObjectAtom {
 
-import org.apache.stanbol.rules.base.SWRL;
+    private URI uri;
+    private boolean negative;
 
-public class VariableAtom implements URIResource {
+    public VariableAtom(URI uri, boolean negative) {
+        this.uri = uri;
+        this.negative = negative;
+    }
 
-       private URI uri;
-       private boolean negative;
-       
-       public VariableAtom(URI uri, boolean negative) {
-               this.uri = uri;
-               this.negative = negative;
-       }
-
-       @Override
-       public URI getURI() {
-               return uri;
-       }
-
-               @Override
-       public Resource createJenaResource(Model model) {
-               return model.createResource(uri.toString(), SWRL.Variable);
-       }
-               
-       @Override
-       public String toString() {
-               
-               return uri.toString();
-               
-       }
-       
-       public boolean isNegative() {
-               return negative;
-       }
-       
+    @Override
+    public URI getURI() {
+        return uri;
+    }
+
+    public boolean isNegative() {
+        return negative;
+    }
+
+    @Override
+    public String toString() {
+        return "?" + getVariableName();
+    }
+
+    @Override
+    public String prettyPrint() {
+        return "variable " + uri.toString();
+    }
+
+    public String getVariableName() {
+        String uriString = uri.toString();
+
+        uriString = uriString.replace(Symbols.variablesPrefix, "");
+
+        return uriString;
+    }
 }

Modified: 
incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/parse/ParseException.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/parse/ParseException.java?rev=1306390&r1=1306389&r2=1306390&view=diff
==============================================================================
--- 
incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/parse/ParseException.java
 (original)
+++ 
incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/parse/ParseException.java
 Wed Mar 28 15:00:06 2012
@@ -1,203 +1,182 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 /* Generated By:JavaCC: Do not edit this line. ParseException.java Version 5.0 
*/
 /* JavaCCOptions:KEEP_LINE_COL=null */
 package org.apache.stanbol.rules.manager.parse;
 
 /**
- * This exception is thrown when parse errors are encountered.
- * You can explicitly create objects of this exception type by
- * calling the method generateParseException in the generated
- * parser.
- *
- * You can modify this class to customize your error reporting
- * mechanisms so long as you retain the public fields.
+ * This exception is thrown when parse errors are encountered. You can 
explicitly create objects of this
+ * exception type by calling the method generateParseException in the 
generated parser.
+ * 
+ * You can modify this class to customize your error reporting mechanisms so 
long as you retain the public
+ * fields.
  */
 public class ParseException extends Exception {
 
-  /**
-   * The version identifier for this Serializable class.
-   * Increment only if the <i>serialized</i> form of the
-   * class changes.
-   */
-  private static final long serialVersionUID = 1L;
-
-  /**
-   * This constructor is used by the method "generateParseException"
-   * in the generated parser.  Calling this constructor generates
-   * a new object of this type with the fields "currentToken",
-   * "expectedTokenSequences", and "tokenImage" set.
-   */
-  public ParseException(Token currentTokenVal,
-                        int[][] expectedTokenSequencesVal,
-                        String[] tokenImageVal
-                       )
-  {
-    super(initialise(currentTokenVal, expectedTokenSequencesVal, 
tokenImageVal));
-    currentToken = currentTokenVal;
-    expectedTokenSequences = expectedTokenSequencesVal;
-    tokenImage = tokenImageVal;
-  }
-
-  /**
-   * The following constructors are for use by you for whatever
-   * purpose you can think of.  Constructing the exception in this
-   * manner makes the exception behave in the normal way - i.e., as
-   * documented in the class "Throwable".  The fields "errorToken",
-   * "expectedTokenSequences", and "tokenImage" do not contain
-   * relevant information.  The JavaCC generated code does not use
-   * these constructors.
-   */
-
-  public ParseException() {
-    super();
-  }
-
-  /** Constructor with message. */
-  public ParseException(String message) {
-    super(message);
-  }
-
-
-  /**
-   * This is the last token that has been consumed successfully.  If
-   * this object has been created due to a parse error, the token
-   * followng this token will (therefore) be the first error token.
-   */
-  public Token currentToken;
-
-  /**
-   * Each entry in this array is an array of integers.  Each array
-   * of integers represents a sequence of tokens (by their ordinal
-   * values) that is expected at this point of the parse.
-   */
-  public int[][] expectedTokenSequences;
-
-  /**
-   * This is a reference to the "tokenImage" array of the generated
-   * parser within which the parse error occurred.  This array is
-   * defined in the generated ...Constants interface.
-   */
-  public String[] tokenImage;
-
-  /**
-   * It uses "currentToken" and "expectedTokenSequences" to generate a parse
-   * error message and returns it.  If this object has been created
-   * due to a parse error, and you do not catch it (it gets thrown
-   * from the parser) the correct error message
-   * gets displayed.
-   */
-  private static String initialise(Token currentToken,
-                           int[][] expectedTokenSequences,
-                           String[] tokenImage) {
-    String eol = System.getProperty("line.separator", "\n");
-    StringBuffer expected = new StringBuffer();
-    int maxSize = 0;
-    for (int i = 0; i < expectedTokenSequences.length; i++) {
-      if (maxSize < expectedTokenSequences[i].length) {
-        maxSize = expectedTokenSequences[i].length;
-      }
-      for (int j = 0; j < expectedTokenSequences[i].length; j++) {
-        expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' ');
-      }
-      if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 
0) {
-        expected.append("...");
-      }
-      expected.append(eol).append("    ");
+    /**
+     * The version identifier for this Serializable class. Increment only if 
the <i>serialized</i> form of the
+     * class changes.
+     */
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * This constructor is used by the method "generateParseException" in the 
generated parser. Calling this
+     * constructor generates a new object of this type with the fields 
"currentToken",
+     * "expectedTokenSequences", and "tokenImage" set.
+     */
+    public ParseException(Token currentTokenVal, int[][] 
expectedTokenSequencesVal, String[] tokenImageVal) {
+        super(initialise(currentTokenVal, expectedTokenSequencesVal, 
tokenImageVal));
+        currentToken = currentTokenVal;
+        expectedTokenSequences = expectedTokenSequencesVal;
+        tokenImage = tokenImageVal;
+    }
+
+    /**
+     * The following constructors are for use by you for whatever purpose you 
can think of. Constructing the
+     * exception in this manner makes the exception behave in the normal way - 
i.e., as documented in the
+     * class "Throwable". The fields "errorToken", "expectedTokenSequences", 
and "tokenImage" do not contain
+     * relevant information. The JavaCC generated code does not use these 
constructors.
+     */
+
+    public ParseException() {
+        super();
     }
-    String retval = "Encountered \"";
-    Token tok = currentToken.next;
-    for (int i = 0; i < maxSize; i++) {
-      if (i != 0) retval += " ";
-      if (tok.kind == 0) {
-        retval += tokenImage[0];
-        break;
-      }
-      retval += " " + tokenImage[tok.kind];
-      retval += " \"";
-      retval += add_escapes(tok.image);
-      retval += " \"";
-      tok = tok.next;
+
+    /** Constructor with message. */
+    public ParseException(String message) {
+        super(message);
     }
-    retval += "\" at line " + currentToken.next.beginLine + ", column " + 
currentToken.next.beginColumn;
-    retval += "." + eol;
-    if (expectedTokenSequences.length == 1) {
-      retval += "Was expecting:" + eol + "    ";
-    } else {
-      retval += "Was expecting one of:" + eol + "    ";
+
+    /**
+     * This is the last token that has been consumed successfully. If this 
object has been created due to a
+     * parse error, the token followng this token will (therefore) be the 
first error token.
+     */
+    public Token currentToken;
+
+    /**
+     * Each entry in this array is an array of integers. Each array of 
integers represents a sequence of
+     * tokens (by their ordinal values) that is expected at this point of the 
parse.
+     */
+    public int[][] expectedTokenSequences;
+
+    /**
+     * This is a reference to the "tokenImage" array of the generated parser 
within which the parse error
+     * occurred. This array is defined in the generated ...Constants interface.
+     */
+    public String[] tokenImage;
+
+    /**
+     * It uses "currentToken" and "expectedTokenSequences" to generate a parse 
error message and returns it.
+     * If this object has been created due to a parse error, and you do not 
catch it (it gets thrown from the
+     * parser) the correct error message gets displayed.
+     */
+    private static String initialise(Token currentToken, int[][] 
expectedTokenSequences, String[] tokenImage) {
+        String eol = System.getProperty("line.separator", "\n");
+        StringBuffer expected = new StringBuffer();
+        int maxSize = 0;
+        for (int i = 0; i < expectedTokenSequences.length; i++) {
+            if (maxSize < expectedTokenSequences[i].length) {
+                maxSize = expectedTokenSequences[i].length;
+            }
+            for (int j = 0; j < expectedTokenSequences[i].length; j++) {
+                
expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' ');
+            }
+            if (expectedTokenSequences[i][expectedTokenSequences[i].length - 
1] != 0) {
+                expected.append("...");
+            }
+            expected.append(eol).append("    ");
+        }
+        String retval = "Encountered \"";
+        Token tok = currentToken.next;
+        for (int i = 0; i < maxSize; i++) {
+            if (i != 0) retval += " ";
+            if (tok.kind == 0) {
+                retval += tokenImage[0];
+                break;
+            }
+            retval += " " + tokenImage[tok.kind];
+            retval += " \"";
+            retval += add_escapes(tok.image);
+            retval += " \"";
+            tok = tok.next;
+        }
+        retval += "\" at line " + currentToken.next.beginLine + ", column " + 
currentToken.next.beginColumn;
+        retval += "." + eol;
+        if (expectedTokenSequences.length == 1) {
+            retval += "Was expecting:" + eol + "    ";
+        } else {
+            retval += "Was expecting one of:" + eol + "    ";
+        }
+        retval += expected.toString();
+        return retval;
     }
-    retval += expected.toString();
-    return retval;
-  }
-
-  /**
-   * The end of line string for this machine.
-   */
-  protected String eol = System.getProperty("line.separator", "\n");
-
-  /**
-   * Used to convert raw characters to their escaped version
-   * when these raw version cannot be used as part of an ASCII
-   * string literal.
-   */
-  static String add_escapes(String str) {
-      StringBuffer retval = new StringBuffer();
-      char ch;
-      for (int i = 0; i < str.length(); i++) {
-        switch (str.charAt(i))
-        {
-           case 0 :
-              continue;
-           case '\b':
-              retval.append("\\b");
-              continue;
-           case '\t':
-              retval.append("\\t");
-              continue;
-           case '\n':
-              retval.append("\\n");
-              continue;
-           case '\f':
-              retval.append("\\f");
-              continue;
-           case '\r':
-              retval.append("\\r");
-              continue;
-           case '\"':
-              retval.append("\\\"");
-              continue;
-           case '\'':
-              retval.append("\\\'");
-              continue;
-           case '\\':
-              retval.append("\\\\");
-              continue;
-           default:
-              if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
-                 String s = "0000" + Integer.toString(ch, 16);
-                 retval.append("\\u" + s.substring(s.length() - 4, 
s.length()));
-              } else {
-                 retval.append(ch);
-              }
-              continue;
+
+    /**
+     * The end of line string for this machine.
+     */
+    protected String eol = System.getProperty("line.separator", "\n");
+
+    /**
+     * Used to convert raw characters to their escaped version when these raw 
version cannot be used as part
+     * of an ASCII string literal.
+     */
+    static String add_escapes(String str) {
+        StringBuffer retval = new StringBuffer();
+        char ch;
+        for (int i = 0; i < str.length(); i++) {
+            switch (str.charAt(i)) {
+                case 0:
+                    continue;
+                case '\b':
+                    retval.append("\\b");
+                    continue;
+                case '\t':
+                    retval.append("\\t");
+                    continue;
+                case '\n':
+                    retval.append("\\n");
+                    continue;
+                case '\f':
+                    retval.append("\\f");
+                    continue;
+                case '\r':
+                    retval.append("\\r");
+                    continue;
+                case '\"':
+                    retval.append("\\\"");
+                    continue;
+                case '\'':
+                    retval.append("\\\'");
+                    continue;
+                case '\\':
+                    retval.append("\\\\");
+                    continue;
+                default:
+                    if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
+                        String s = "0000" + Integer.toString(ch, 16);
+                        retval.append("\\u" + s.substring(s.length() - 4, 
s.length()));
+                    } else {
+                        retval.append(ch);
+                    }
+                    continue;
+            }
         }
-      }
-      return retval.toString();
-   }
+        return retval.toString();
+    }
 
 }
 /* JavaCC - OriginalChecksum=6917a930637533b189885678ddc74852 (do not edit 
this line) */

Modified: 
incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/parse/RuleGrammar.jj
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/parse/RuleGrammar.jj?rev=1306390&r1=1306389&r2=1306390&view=diff
==============================================================================
--- 
incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/parse/RuleGrammar.jj
 (original)
+++ 
incubator/stanbol/trunk/rules/manager/src/main/java/org/apache/stanbol/rules/manager/parse/RuleGrammar.jj
 Wed Mar 28 15:00:06 2012
@@ -14,84 +14,94 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-/**
- * JavaCC template file created by SF JavaCC plugin 1.5.17+ wizard for JavaCC 
1.5.0+
- */
 options
 {
   JDK_VERSION = "1.6";
   static = false;
 }
 
-PARSER_BEGIN(RuleParser)
+PARSER_BEGIN(RuleParserImpl)
 package org.apache.stanbol.rules.manager.parse;
 
+import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.io.Reader;
 import java.io.StringReader;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.util.Iterator;
-
-import com.hp.hpl.jena.rdf.model.ModelFactory;
-import com.hp.hpl.jena.rdf.model.Resource;
-
 
+import org.apache.clerezza.rdf.core.UriRef;
 import org.apache.stanbol.rules.base.api.Rule;
 import org.apache.stanbol.rules.base.api.RuleAtom;
-import org.apache.stanbol.rules.base.api.URIResource;
 import org.apache.stanbol.rules.base.api.util.AtomList;
 import org.apache.stanbol.rules.manager.KB;
 import org.apache.stanbol.rules.manager.RuleImpl;
 import org.apache.stanbol.rules.manager.atoms.ClassAtom;
 import org.apache.stanbol.rules.manager.atoms.ComparisonAtom;
+import org.apache.stanbol.rules.manager.atoms.ConcatAtom;
+import org.apache.stanbol.rules.manager.atoms.CreateLabelAtom;
 import org.apache.stanbol.rules.manager.atoms.DatavaluedPropertyAtom;
+import org.apache.stanbol.rules.manager.atoms.DifferentAtom;
+import org.apache.stanbol.rules.manager.atoms.DivisionAtom;
 import org.apache.stanbol.rules.manager.atoms.EndsWithAtom;
+import org.apache.stanbol.rules.manager.atoms.ExpressionAtom;
+import org.apache.stanbol.rules.manager.atoms.GreaterEqualThanAtom;
+import org.apache.stanbol.rules.manager.atoms.GreaterThanAtom;
+import org.apache.stanbol.rules.manager.atoms.IObjectAtom;
 import org.apache.stanbol.rules.manager.atoms.IndividualPropertyAtom;
-import org.apache.stanbol.rules.manager.atoms.DifferentAtom;
-import org.apache.stanbol.rules.manager.atoms.TypedLiteralAtom;
+import org.apache.stanbol.rules.manager.atoms.IsBlankAtom;
 import org.apache.stanbol.rules.manager.atoms.LengthAtom;
+import org.apache.stanbol.rules.manager.atoms.LessEqualThanAtom;
+import org.apache.stanbol.rules.manager.atoms.LessThanAtom;
+import org.apache.stanbol.rules.manager.atoms.LetAtom;
+import org.apache.stanbol.rules.manager.atoms.LocalNameAtom;
+import org.apache.stanbol.rules.manager.atoms.LowerCaseAtom;
+import org.apache.stanbol.rules.manager.atoms.MultiplicationAtom;
+import org.apache.stanbol.rules.manager.atoms.NamespaceAtom;
+import org.apache.stanbol.rules.manager.atoms.NewIRIAtom;
+import org.apache.stanbol.rules.manager.atoms.NewLiteralAtom;
 import org.apache.stanbol.rules.manager.atoms.NotAtom;
 import org.apache.stanbol.rules.manager.atoms.NumberAtom;
 import org.apache.stanbol.rules.manager.atoms.NumericFunctionAtom;
-import org.apache.stanbol.rules.manager.atoms.SPARQLddAtom;
-import org.apache.stanbol.rules.manager.atoms.SameAtom;
-import org.apache.stanbol.rules.manager.atoms.LessThanAtom;
-import org.apache.stanbol.rules.manager.atoms.GreaterThanAtom;
+import org.apache.stanbol.rules.manager.atoms.NumericVariableAtom;
+import org.apache.stanbol.rules.manager.atoms.PropStringAtom;
 import org.apache.stanbol.rules.manager.atoms.ResourceAtom;
-import org.apache.stanbol.rules.manager.atoms.VariableAtom;
-import org.apache.stanbol.rules.manager.atoms.LetAtom;
-import org.apache.stanbol.rules.manager.atoms.ConcatAtom;
+import org.apache.stanbol.rules.manager.atoms.RuleBlankNode;
+import org.apache.stanbol.rules.manager.atoms.SameAtom;
+import org.apache.stanbol.rules.manager.atoms.StartsWithAtom;
+import org.apache.stanbol.rules.manager.atoms.StrAtom;
 import org.apache.stanbol.rules.manager.atoms.StringAtom;
 import org.apache.stanbol.rules.manager.atoms.StringFunctionAtom;
+import org.apache.stanbol.rules.manager.atoms.StringVariableAtom;
 import org.apache.stanbol.rules.manager.atoms.SubstringAtom;
 import org.apache.stanbol.rules.manager.atoms.SubtractionAtom;
 import org.apache.stanbol.rules.manager.atoms.SumAtom;
-import org.apache.stanbol.rules.manager.atoms.NewNodeAtom;
-import org.apache.stanbol.rules.manager.atoms.BlankNodeAtom;
-import org.apache.stanbol.rules.manager.atoms.UpperCaseAtom;
-import org.apache.stanbol.rules.manager.atoms.LowerCaseAtom;
-import org.apache.stanbol.rules.manager.atoms.NamespaceAtom;
-import org.apache.stanbol.rules.manager.atoms.LocalNameAtom;
-import org.apache.stanbol.rules.manager.atoms.StrAtom;
+import org.apache.stanbol.rules.manager.atoms.TypedLiteralAtom;
 import org.apache.stanbol.rules.manager.atoms.UnionAtom;
-import org.apache.stanbol.rules.manager.atoms.CreateLabelAtom;
-import org.apache.stanbol.rules.manager.atoms.PropStringAtom;
-import org.apache.stanbol.rules.manager.atoms.IsBlankAtom;
-import org.apache.stanbol.rules.manager.atoms.SPARQLcAtom;
-import org.apache.stanbol.rules.manager.atoms.SPARQLdAtom;
-import org.apache.stanbol.rules.manager.atoms.StartsWithAtom;
-import org.apache.stanbol.rules.base.api.RuleExpressiveness;
+import org.apache.stanbol.rules.manager.atoms.UpperCaseAtom;
+import org.apache.stanbol.rules.manager.atoms.VariableAtom;
 
-public class RuleParser
+import com.hp.hpl.jena.rdf.model.ModelFactory;
+import com.hp.hpl.jena.rdf.model.Resource;
+
+/**
+*
+* @author anuzzolese 
+* 
+*/
+
+@SuppressWarnings("unused")
+
+public class RuleParserImpl
 {
 
   static KB kb;
   
-  public static KB parse( String inString ) {
+  public static KB parse( String namespace, String inString ) {
   {
-       kb = new KB();
+       kb = new KB(namespace);
        Reader reader = new StringReader( inString ) ;
-    RuleParser parser = new RuleParser(reader);
+    RuleParserImpl parser = new RuleParserImpl(reader);
     StringBuffer buffer = new StringBuffer() ;
        try {
                parser.start( ) ; 
@@ -102,6 +112,21 @@ public class RuleParser
        } 
        return kb ; }
   }
+  
+  public static KB parse( String namespace, InputStream inStream ) {
+
+               kb = new KB(namespace);
+               Reader reader = new InputStreamReader(inStream);
+               RuleParserImpl parser = new RuleParserImpl(reader);
+               try {
+                       parser.start();
+               } catch (TokenMgrError e) {
+                       throw new IllegalStateException(e);
+               } catch (ParseException e) {
+                       throw new IllegalStateException(e);
+               }
+               return kb;
+       }
 
 
        private static URI getSWRLArgument(String argument){
@@ -144,10 +169,25 @@ public class RuleParser
         }
 }
 
-PARSER_END(RuleParser)
+PARSER_END(RuleParserImpl)
 
 SKIP : {" "}
 SKIP : {"\r" | "\t" | "\n"}
+SKIP :
+{
+  "/*" : WithinComment
+}
+
+<WithinComment> SKIP :
+{
+  "*/" : DEFAULT
+}
+
+<WithinComment> MORE :
+{
+  <~[]>
+}
+
 
 TOKEN : /* OPERATORS */
 {
@@ -156,13 +196,15 @@ TOKEN : /* OPERATORS */
 | < EQUAL : "=" >
 | < AND : "." >
 | < COMMA : "," >
-| < REFLEXIVE : "+" >
 | < SAME : "same" >
 | < DIFFERENT : "different" >
 | < LESSTHAN : "lt" >
 | < GREATERTHAN : "gt" >
+| < LESSEQUALTHAN : "leq" >
+| < GREATEREQUALTHAN : "geq" >
 | < IS : "is" >
-| < NEW_NODE : "newNode" >
+| < NEW_IRI : "newIRI" >
+| < NEW_LITERAL: "newLiteral" >
 | < LENGTH : "length" >
 | < SUBSTRING : "substring" >
 | < UPPERCASE : "upperCase" >
@@ -176,6 +218,8 @@ TOKEN : /* OPERATORS */
 | < NOTEX : "notex" >
 | < PLUS : "sum" >
 | < MINUS : "sub" >
+| < MULTIPLIED : "mult" >
+| < DIVIDED : "div" >
 | < NOT : "not" >
 | < NAMESPACE : "namespace" >
 | < LOCALNAME : "localname" >
@@ -183,12 +227,8 @@ TOKEN : /* OPERATORS */
 | < APOX : "^" >
 | < UNION : "union" >
 | < CREATE_LABEL : "createLabel" >
-| < SPARQL_C : "sparql-c" >
-| < SPARQL_D : "sparql-d" >
-| < SPARQL_DD : "sparql-dd" >
 | < PROP : "prop" >
 | < IS_BLANK : "isBlank" >
-| < FORWARD_CHAIN : "!" >
 }
 
 TOKEN : /* BLOCKS */
@@ -207,7 +247,6 @@ TOKEN :
 | < VARIABLE : "?" ([ "0"-"9","a"-"z","A"-"Z","-", "_"])+ >
 | < URI : "<" ([ "0"-"9","a"-"z","A"-"Z","-", "_", ".", "#", ":", "/", "(", 
")" ])+ ">" >
 | < STRING : "\"" ([ "0"-"9","a"-"z","A"-"Z","-", "_", ".", ":", "/", "#", 
"\\", "?", " ", "!", "$", "%" ])+ "\"" >
-| < SPARQL_STRING : "%" ([ "0"-"9","a"-"z","A"-"Z","-", "_", ".", ":", "/", 
"#", "\\", "?", " ", "!", "$", "%", "{", "}", "(", ")", "\"", "<", ">", "=", 
"+", "\n", "\t", "&", "|", "," ])+ "%" >
 | < BNODE : "_:" ([ "0"-"9","a"-"z","A"-"Z","-", "_", "."])+ >
 }
 
@@ -238,49 +277,22 @@ void prefix() :
                                                                                
   kb.addPrefix(nsPrefix, prefixURI);                                           
                                    
                                                                                
 } 
                                                        |   obj=rule() { 
AtomList[] atoms = (AtomList[]) obj;
-                                                                               
         String varPrefix = kb.getPrefixURI("var");
-                                                                               
         varPrefix = varPrefix.substring(0, varPrefix.length());
+                                                                               
         String ruleStorePrefix = kb.getPrefixURI("rmi2");
+                                                                               
         ruleStorePrefix = ruleStorePrefix.substring(0, 
ruleStorePrefix.length());
                                                                                
         
                                                                                
         if(atoms.length == 1){
                                                             AtomList body = 
atoms[0];
                                                             if(body.size() == 
1){
-                                                                    
Iterator<RuleAtom> it = body.iterator();
-                                                                    RuleAtom 
atom = it.next();
-                                                                    
if(atom.isSPARQLConstruct()){
-                                                                            
rule = new RuleImpl(varPrefix+nsPrefix, atoms[0], null, 
RuleExpressiveness.SPARQLConstruct);
-                                                                            
kb.addRule(rule);
-                                                                    }
-                                                                    else 
if(atom.isSPARQLDelete()){
-                                                                            
rule = new RuleImpl(varPrefix+nsPrefix, atoms[0], null, 
RuleExpressiveness.SPARQLDelete);
-                                                                            
kb.addRule(rule);
-                                                                    }
-                                                                    else 
if(atom.isSPARQLDeleteData()){
-                                                                            
rule = new RuleImpl(varPrefix+nsPrefix, atoms[0], null, 
RuleExpressiveness.SPARQLDeleteData);
-                                                                            
kb.addRule(rule);
-                                                                    }
+                                                                    // FIXME 
it previously managed SPARQL code injection.
                                                             }
 
                                                      }
                                                  else{
-                                                         rule = new 
RuleImpl(varPrefix+nsPrefix, atoms[0], atoms[1], RuleExpressiveness.KReSCore);
+                                                         rule = new 
RuleImpl(new UriRef(ruleStorePrefix+nsPrefix), nsPrefix, atoms[0], atoms[1]);
                                                          kb.addRule(rule);
                                                 }
                                                                                
}
                                                )
-                                               
-|
-
-       < FORWARD_CHAIN > nsPrefix=getVariable() obj=rule() { AtomList[] atoms 
= (AtomList[]) obj;
-                                                                               
         String varPrefix = kb.getPrefixURI("var");
-                                                                               
         varPrefix = varPrefix.substring(0, varPrefix.length());
-                                                                               
         rule = new RuleImpl(varPrefix+nsPrefix, atoms[0], atoms[1], 
RuleExpressiveness.ForwardChaining);
-                                                                               
         kb.addRule(rule); }
-                                                                               
         
-|      < REFLEXIVE > nsPrefix=getVariable() obj=rule() {       AtomList[] 
kReSAtoms = (AtomList[]) obj;
-                                                                               
                                 String pref = kb.getPrefixURI("var");
-                                                         pref = 
pref.substring(0, pref.length());
-                                                         rule = new 
RuleImpl(pref+nsPrefix, kReSAtoms[0], kReSAtoms[1], 
RuleExpressiveness.Reflexive);
-                                                         kb.addRule(rule); }
 }
 
 
@@ -306,33 +318,7 @@ AtomList[] ruleDefinition():
 {
        body=atomList() <LARROW> head=atomList()
        { return new AtomList[]{body, head};}
-       
-|      
-       < SPARQL_C > < LPAR > t = < SPARQL_STRING > < RPAR >
-       { 
-               RuleAtom sparqlAtom = new SPARQLcAtom(t.image);
-               AtomList atomList = new AtomList();
-               atomList.addToHead(sparqlAtom);
-               return new AtomList[]{atomList};
-       }
-       
-|      
-       < SPARQL_D > < LPAR > t = < SPARQL_STRING > < RPAR >
-       { 
-               RuleAtom sparqlDAtom = new SPARQLdAtom(t.image);
-        AtomList atomDList = new AtomList();
-        atomDList.addToHead(sparqlDAtom);
-        return new AtomList[]{atomDList};
-       }
-
-|      
-       < SPARQL_DD > < LPAR > t = < SPARQL_STRING > < RPAR >
-       { 
-               RuleAtom sparqlDDAtom = new SPARQLddAtom(t.image);
-        AtomList atomDDList = new AtomList();
-        atomDDList.addToHead(sparqlDDAtom);
-        return new AtomList[]{atomDDList};
-       } 
+        
 }
 
 AtomList atomList() :
@@ -365,7 +351,8 @@ RuleAtom atom() :
 |  ruleAtom=individualPropertyAtom() {return ruleAtom;}
 |  ruleAtom=datavaluedPropertyAtom() {return ruleAtom;}
 |  ruleAtom=letAtom() {return ruleAtom;}
-|  ruleAtom=newNodeAtom() {return ruleAtom;}
+|  ruleAtom=newIRIAtom() {return ruleAtom;}
+|  ruleAtom=newLiteralAtom() {return ruleAtom;}
 |  ruleAtom=comparisonAtom() {return ruleAtom;}
 |  ruleAtom=unionAtom() {return ruleAtom;}
 
@@ -427,6 +414,7 @@ StringFunctionAtom stringFunctionAtom() 
        |   stringFunctionAtom=stringAtom()
        |       stringFunctionAtom=propStringAtom()
        |       stringFunctionAtom=createLabelAtom()
+       |       stringFunctionAtom=stringVariable()
        )
 
        {return stringFunctionAtom;}
@@ -434,30 +422,30 @@ StringFunctionAtom stringFunctionAtom() 
 
 
 StrAtom strAtom() : 
-{URIResource uri;}
+{IObjectAtom uri;}
 {
        < STR > < LPAR > uri = iObject() < RPAR >
        {return new StrAtom(uri);}
 }
 
 NamespaceAtom namespaceAtom() : 
-{URIResource uri;}
+{IObjectAtom uri;}
 {
        < NAMESPACE > < LPAR > uri = iObject() < RPAR >
        {return new NamespaceAtom(uri);}
 }
 
 LocalNameAtom localnameAtom() : 
-{URIResource uri;}
+{IObjectAtom uri;}
 {
        < LOCALNAME > < LPAR > uri = iObject() < RPAR >
        {return new LocalNameAtom(uri);}
 }
 
 StringAtom stringAtom() :
-{Object obj; StringFunctionAtom stringFunctionAtom;}
+{String obj;}
 {
-       obj = uObject() { return new StringAtom(obj.toString()); }
+       obj = getStringValue() { return new StringAtom(obj.toString()); }
 }
 
 ConcatAtom concatAtom() : 
@@ -490,6 +478,16 @@ SubstringAtom substringAtom() : 
 }
 
 
+ExpressionAtom expressionAtom() :
+{ExpressionAtom expressionAtom;}
+{
+       LOOKAHEAD(2)
+               expressionAtom = stringFunctionAtom()
+       |       expressionAtom = numericFunctionAtom()
+       
+       {return expressionAtom;}
+}
+
 NumericFunctionAtom numericFunctionAtom() : 
 {NumericFunctionAtom numericFunctionAtom;}
 {
@@ -498,6 +496,7 @@ NumericFunctionAtom numericFunctionAtom(
        |   numericFunctionAtom = subtractionAtom()
        |   numericFunctionAtom = lengthAtom()
        |   numericFunctionAtom = numberAtom()
+       |   numericFunctionAtom = numericVariable()
        )
 
        {return numericFunctionAtom;}
@@ -529,12 +528,29 @@ SubtractionAtom subtractionAtom() : 
        {return new SubtractionAtom(numericFunctionAtom1, 
numericFunctionAtom2);}
 }
 
+MultiplicationAtom multiplicationAtom() : 
+{NumericFunctionAtom numericFunctionAtom1; NumericFunctionAtom 
numericFunctionAtom2;}
+{
+       
+       < MULTIPLIED > < LPAR > numericFunctionAtom1 = numericFunctionAtom() < 
COMMA > numericFunctionAtom2 = numericFunctionAtom() < RPAR >
+
+       {return new MultiplicationAtom(numericFunctionAtom1, 
numericFunctionAtom2);}
+}
+
+DivisionAtom divisionAtom() : 
+{NumericFunctionAtom numericFunctionAtom1; NumericFunctionAtom 
numericFunctionAtom2;}
+{
+       
+       < DIVIDED > < LPAR > numericFunctionAtom1 = numericFunctionAtom() < 
COMMA > numericFunctionAtom2 = numericFunctionAtom() < RPAR >
+
+       {return new DivisionAtom(numericFunctionAtom1, numericFunctionAtom2);}
+}
+
 NumericFunctionAtom numberAtom() :
 {Token t;}
 {
        (
                t = < NUM >     
-       |       t = < VARIABLE >
        )
        { return new NumberAtom(t.image); }
 
@@ -542,22 +558,30 @@ NumericFunctionAtom numberAtom() :
 
 
 ClassAtom classAtom() :
-{URIResource uri1; URIResource uri2;}
+{IObjectAtom uri1; IObjectAtom uri2;}
 {
        < IS > < LPAR > uri1=iObject()  < COMMA > uri2=iObject() < RPAR >
        { return new ClassAtom(uri1, uri2);}
 }
 
 
-NewNodeAtom newNodeAtom() : 
-{URIResource arg1; Object arg2;}
+NewIRIAtom newIRIAtom() : 
+{IObjectAtom arg1; StringFunctionAtom arg2;}
 {
-       < NEW_NODE > < LPAR > arg1=iObject()  < COMMA > arg2=dObject() < RPAR >
-       { return new NewNodeAtom(arg1, arg2);}
+       < NEW_IRI > < LPAR > arg1=iObject()  < COMMA > 
arg2=stringFunctionAtom() < RPAR >
+       { return new NewIRIAtom(arg1, arg2);}
+}
+
+
+NewLiteralAtom newLiteralAtom() : 
+{IObjectAtom arg1; StringFunctionAtom arg2;}
+{
+       < NEW_LITERAL > < LPAR > arg1=iObject()  < COMMA > 
arg2=stringFunctionAtom() < RPAR >
+       { return new NewLiteralAtom(arg1, arg2);}
 }
 
 LetAtom letAtom() : 
-{URIResource uri1; StringFunctionAtom fun;}
+{IObjectAtom uri1; StringFunctionAtom fun;}
 {
        < LET > < LPAR > uri1=iObject()  < COMMA > fun=stringFunctionAtom() < 
RPAR >
        { return new LetAtom(uri1, fun);}
@@ -565,7 +589,7 @@ LetAtom letAtom() : 
 
 
 IndividualPropertyAtom individualPropertyAtom() :
-{URIResource uri1; URIResource uri2; URIResource uri3;}
+{IObjectAtom uri1; IObjectAtom uri2; IObjectAtom uri3;}
 {
         < HAS > < LPAR > uri1=iObject() < COMMA > uri2=iObject() <COMMA> 
uri3=iObject() < RPAR >
         {return new IndividualPropertyAtom(uri1, uri2, uri3);}
@@ -573,7 +597,7 @@ IndividualPropertyAtom individualPropert
 
 
 DatavaluedPropertyAtom datavaluedPropertyAtom() :
-{URIResource uri1; URIResource uri2; Object obj;}
+{IObjectAtom uri1; IObjectAtom uri2; RuleAtom obj;}
 {
         < VALUES > < LPAR > uri1=iObject() < COMMA > uri2=iObject() <COMMA> 
obj=dObject() < RPAR >
         { return new DatavaluedPropertyAtom(uri1, uri2, obj); }
@@ -581,34 +605,48 @@ DatavaluedPropertyAtom datavaluedPropert
 
 
 SameAtom sameAsAtom() :
-{StringFunctionAtom stringFunctionAtom1; StringFunctionAtom 
stringFunctionAtom2;}
+{ExpressionAtom expressionAtom1; ExpressionAtom expressionAtom2;}
 {
-       < SAME > < LPAR > stringFunctionAtom1=stringFunctionAtom() < COMMA > 
stringFunctionAtom2=stringFunctionAtom() < RPAR >
-       { return new SameAtom(stringFunctionAtom1, stringFunctionAtom2); } 
+       < SAME > < LPAR > expressionAtom1=expressionAtom() < COMMA > 
expressionAtom2=expressionAtom() < RPAR >
+       { return new SameAtom(expressionAtom1, expressionAtom2); } 
 }
 
 LessThanAtom lessThanAtom() :
-{Object obj1; Object obj2;}
+{ExpressionAtom obj1; ExpressionAtom obj2;}
 {
-       < LESSTHAN > < LPAR > obj1=dObject() < COMMA > obj2=dObject() < RPAR >
+       < LESSTHAN > < LPAR > obj1=expressionAtom() < COMMA > 
obj2=expressionAtom() < RPAR >
        { return new LessThanAtom(obj1, obj2); } 
 }
 
+LessEqualThanAtom lessEqualThanAtom() :
+{ExpressionAtom obj1; ExpressionAtom obj2;}
+{
+       < LESSEQUALTHAN > < LPAR > obj1=expressionAtom() < COMMA > 
obj2=expressionAtom() < RPAR >
+       { return new LessEqualThanAtom(obj1, obj2); } 
+}
+
 GreaterThanAtom greaterThanAtom() :
-{Object obj1; Object obj2;}
+{ExpressionAtom obj1; ExpressionAtom obj2;}
 {
-       < GREATERTHAN > < LPAR > obj1=dObject() < COMMA > obj2=dObject() < RPAR 
>
+       < GREATERTHAN > < LPAR > obj1=expressionAtom() < COMMA > 
obj2=expressionAtom() < RPAR >
        { return new GreaterThanAtom(obj1, obj2); } 
 }
 
+GreaterEqualThanAtom greaterEqualThanAtom() :
+{ExpressionAtom obj1; ExpressionAtom obj2;}
+{
+       < GREATEREQUALTHAN > < LPAR > obj1=expressionAtom() < COMMA > 
obj2=expressionAtom() < RPAR >
+       { return new GreaterEqualThanAtom(obj1, obj2); } 
+}
+
 DifferentAtom differentFromAtom() :
-{StringFunctionAtom stringFunctionAtom1; StringFunctionAtom 
stringFunctionAtom2;}
+{ExpressionAtom expressionAtom1; ExpressionAtom expressionAtom2;}
 {
-       < DIFFERENT > < LPAR > stringFunctionAtom1=stringFunctionAtom() < COMMA 
> stringFunctionAtom2=stringFunctionAtom() < RPAR >
-       { return new DifferentAtom(stringFunctionAtom1, stringFunctionAtom2); } 
+       < DIFFERENT > < LPAR > expressionAtom1=expressionAtom() < COMMA > 
expressionAtom2=expressionAtom() < RPAR >
+       { return new DifferentAtom(expressionAtom1, expressionAtom2); } 
 }
 
-URIResource reference() :
+IObjectAtom reference() :
 { String uri1;
   Token colon;
   String uri3; }
@@ -624,7 +662,7 @@ URIResource reference() :
 
 
 
-URIResource varReference() :
+IObjectAtom varReference() :
 { String uri1;
   Token colon;
   String uri3; }
@@ -655,7 +693,7 @@ String getVariable() :
 }
 
 
-String getString() :
+String getStringValue() :
 {
        Token t;
 }
@@ -663,12 +701,20 @@ String getString() :
        t = < STRING > { return t.image; }
 }
 
-Integer getInt() :
+StringAtom getString() :
+{
+       Token t;
+}
+{
+       t = < STRING > { return new StringAtom(t.image); }
+}
+
+NumberAtom getInt() :
 {
        Token t;
 }
 {
-       t=< NUM > { return Integer.valueOf(t.image); }
+       t=< NUM > { return new NumberAtom(t.image); }
 }
 
 
@@ -686,14 +732,14 @@ Object uObject() :
 }
 
 
-URIResource iObject() :
-{ URIResource uri; }
+IObjectAtom iObject() :
+{ IObjectAtom uri; }
 {
        uri = variable() {return uri;} | uri = reference() {return uri;}
 }
 
-Object dObject() :
-{ Object variable; }
+RuleAtom dObject() :
+{ RuleAtom variable; }
 {
        
        (variable=literal() | variable=variable()) {return variable;}   
@@ -701,8 +747,8 @@ Object dObject() :
 
 
 
-Object literal() : 
-{ Object literal; URIResource typedLiteral;}
+ExpressionAtom literal() : 
+{ ExpressionAtom literal; IObjectAtom typedLiteral;}
 {
        (
        
@@ -722,8 +768,8 @@ Object literal() : 
        
 }
 
-URIResource typedLiteral() :
-{ URIResource type = null; }
+IObjectAtom typedLiteral() :
+{ IObjectAtom type = null; }
 {
        (
                        < APOX > < APOX > type = reference()
@@ -732,7 +778,7 @@ URIResource typedLiteral() :
        {return type;}
 } 
 
-URIResource variable() :
+IObjectAtom variable() :
 { Token t; String var;}
 {
        < NOTEX > < LPAR > t = < VARIABLE > < RPAR > {var=t.image; 
var=kb.getPrefixURI("var") + var.substring(1);
@@ -754,6 +800,8 @@ URIResource variable() :
        { var=t.image;  return new RuleBlankNode(var); }
 }
 
+
+
 ComparisonAtom notAtom() :
 { ComparisonAtom comparisonAtom; }
 {
@@ -762,7 +810,7 @@ ComparisonAtom notAtom() :
 }
 
 ComparisonAtom isBlankAtom() :
-{ URIResource uriRes; }
+{ IObjectAtom uriRes; }
 {
        < IS_BLANK > < LPAR > uriRes = iObject()  < RPAR >
        {return new IsBlankAtom(uriRes);}       
@@ -785,3 +833,30 @@ ComparisonAtom comparisonAtom() :
 }
 
 
+NumericVariableAtom numericVariable() :
+{ Token t; String var;}
+{
+       t = < VARIABLE >
+       { var=t.image; var=kb.getPrefixURI("var") + var.substring(1);
+                                                                               
                                try{ 
+                                                                               
                                        return new NumericVariableAtom(new 
URI(var), false);
+                                                                               
                                } catch (URISyntaxException e) {
+                                                                               
                                        e.printStackTrace();
+                                                                               
                                        return null;
+                                                                               
                                } }
+
+}
+
+StringVariableAtom stringVariable() :
+{ Token t; String var;}
+{
+       t = < VARIABLE >
+       { var=t.image; var=kb.getPrefixURI("var") + var.substring(1);
+                                                                               
                                try{ 
+                                                                               
                                        return new StringVariableAtom(new 
URI(var), false);
+                                                                               
                                } catch (URISyntaxException e) {
+                                                                               
                                        e.printStackTrace();
+                                                                               
                                        return null;
+                                                                               
                                } }
+
+}
\ No newline at end of file


Reply via email to