[Mulgara-svn] r382 - in branches/nw-interface/src/jar/itql/java/org/mulgara: . lang
pag at mulgara.org
pag at mulgara.org
Mon Aug 27 21:19:45 UTC 2007
Author: pag
Date: 2007-08-27 16:19:45 -0500 (Mon, 27 Aug 2007)
New Revision: 382
Added:
branches/nw-interface/src/jar/itql/java/org/mulgara/lang/
branches/nw-interface/src/jar/itql/java/org/mulgara/lang/Interpreter.java
branches/nw-interface/src/jar/itql/java/org/mulgara/lang/MulgaraLexerException.java
branches/nw-interface/src/jar/itql/java/org/mulgara/lang/MulgaraParserException.java
Log:
Refactored Interpreting operations into this package, to act as a base for both SableCC and Beaver interpreters.
Copied: branches/nw-interface/src/jar/itql/java/org/mulgara/lang/Interpreter.java (from rev 374, branches/nw-interface/src/jar/itql/java/org/mulgara/itql/Interpreter.java)
===================================================================
--- branches/nw-interface/src/jar/itql/java/org/mulgara/itql/Interpreter.java 2007-08-23 17:23:56 UTC (rev 374)
+++ branches/nw-interface/src/jar/itql/java/org/mulgara/lang/Interpreter.java 2007-08-27 21:19:45 UTC (rev 382)
@@ -0,0 +1,90 @@
+package org.mulgara.parser;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.mulgara.query.Query;
+import org.mulgara.query.ast.Command;
+
+
+/**
+ * This interface defines the namespaces used while interpreting RDF code.
+ * @author pag
+ *
+ */
+public interface Interpreter {
+
+ //
+ // Constants
+ //
+ /** The rdf namespace prefix. */
+ public static final String RDF = "rdf";
+
+ /** The rdfs namespace prefix. */
+ public static final String RDFS = "rdfs";
+
+ /** The owl namespace prefix. */
+ public static final String OWL = "owl";
+
+ /** The mulgara namespace prefix. */
+ public static final String MULGARA = "mulgara";
+
+ /** The krule namespace prefix. */
+ public static final String KRULE = "krule";
+
+ /** The Dublin Core namespace prefix. */
+ public static final String DC = "dc";
+
+ /** The URI of the rdf namespace. */
+ public static final String RDF_NS = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+
+ /** The URI of the rdfs namespace. */
+ public static final String RDFS_NS = "http://www.w3.org/2000/01/rdf-schema#";
+
+ /** The URI of the owl namespace. */
+ public static final String OWL_NS = "http://www.w3.org/2002/07/owl#";
+
+ /** The URI of the mulgara namespace. */
+ public static final String MULGARA_NS = "http://mulgara.org/mulgara#";
+
+ /** The URI of the krule namespace. */
+ public static final String KRULE_NS = "http://mulgara.org/owl/krule/#";
+
+ /** The URI of the dc namespace. */
+ public static final String DC_NS = "http://purl.org/dc/elements/1.1/";
+
+ /**
+ * Parses the given TQL command.
+ *
+ * @param command the command to parse in TQL syntax
+ * @return An AST for the command
+ * @throws MulgaraParserException if the syntax of the command is incorrect
+ * @throws MulgaraLexerException if the syntax of the command is incorrect
+ * @throws IOException if the <var>command</var> cannot be paersed
+ * @throws IllegalArgumentException if the <var>command</var> is <code>null</code>
+ */
+ public Command parseCommand(String command) throws MulgaraParserException, MulgaraLexerException, Exception;
+
+ /**
+ * Parses the given TQL command.
+ *
+ * @param command the command to parse in TQL syntax
+ * @return A {@link List} of ASTs, one for each command
+ * @throws MulgaraParserException if the syntax of the command is incorrect
+ * @throws MulgaraLexerException if the syntax of the command is incorrect
+ * @throws IOException if the <var>command</var> cannot be paersed
+ * @throws IllegalArgumentException if the <var>command</var> is <code>null</code>
+ */
+ public List<Command> parseCommands(String command) throws MulgaraParserException, MulgaraLexerException, Exception;
+
+ /**
+ * Parse a string into a {@link Query}. Convenience method over parseCommand.
+ *
+ * @param queryString a string containing an ITQL query
+ * @return the corresponding {@link Query} instance
+ * @throws IOException if <var>queryString</var> can't be buffered.
+ * @throws MulgaraLexerException if <var>queryString</var> can't be tokenized.
+ * @throws MulgaraParserException if <var>queryString</var> is not syntactic.
+ */
+ public Query parseQuery(String queryString) throws IOException, MulgaraLexerException, MulgaraParserException;
+}
\ No newline at end of file
Added: branches/nw-interface/src/jar/itql/java/org/mulgara/lang/MulgaraLexerException.java
===================================================================
--- branches/nw-interface/src/jar/itql/java/org/mulgara/lang/MulgaraLexerException.java 2007-08-27 21:13:48 UTC (rev 381)
+++ branches/nw-interface/src/jar/itql/java/org/mulgara/lang/MulgaraLexerException.java 2007-08-27 21:19:45 UTC (rev 382)
@@ -0,0 +1,19 @@
+package org.mulgara.parser;
+
+public class MulgaraLexerException extends Exception {
+
+ private static final long serialVersionUID = -5853073510057952109L;
+
+ public MulgaraLexerException(String message) {
+ super(message);
+ }
+
+ public MulgaraLexerException(Throwable cause) {
+ super(cause);
+ }
+
+ public MulgaraLexerException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
Added: branches/nw-interface/src/jar/itql/java/org/mulgara/lang/MulgaraParserException.java
===================================================================
--- branches/nw-interface/src/jar/itql/java/org/mulgara/lang/MulgaraParserException.java 2007-08-27 21:13:48 UTC (rev 381)
+++ branches/nw-interface/src/jar/itql/java/org/mulgara/lang/MulgaraParserException.java 2007-08-27 21:19:45 UTC (rev 382)
@@ -0,0 +1,19 @@
+package org.mulgara.parser;
+
+public class MulgaraParserException extends Exception {
+
+ private static final long serialVersionUID = -7724312286750583118L;
+
+ public MulgaraParserException(String message) {
+ super(message);
+ }
+
+ public MulgaraParserException(Throwable cause) {
+ super(cause);
+ }
+
+ public MulgaraParserException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
More information about the Mulgara-svn
mailing list