Commit cd5ee26b authored by Anders Nilsson's avatar Anders Nilsson

Updated grammars to handle newer version of protege, more tags

parent 8598e4c4
......@@ -17,3 +17,6 @@ siaras/javadoc
siaras/OntologyCompiler.jar
*.repository
siaras/ontology.pprj
RoSta/GeneratedAspects.jrag
RoSta/Parser.java
RoSta/RoSta.ast
// package programs;
/*
* Copyright (C) 2006 Anders Nilsson <anders.nilsson@cs.lth.se>
* Copyright (C) 2006-2008 Anders Nilsson <anders.nilsson@cs.lth.se>
*
* This file is part of OntologyCompiler.
*/
......@@ -12,9 +12,22 @@ import java.io.PrintStream;
public class GenCompiler extends Parser {
public static void main(String args[]) {
Start ast = parse(args);
File siarasDir = new File("siaras");
String name = "default";
String owlFile = "";
int i = 0;
while (i<args.length) {
if (args[i].equals("-d")) {
name = args[++i];
i++;
} else {
owlFile = args[i++];
}
}
Start ast = parse(owlFile);
File siarasDir = new File(name);
if (!siarasDir.isDirectory()) {
siarasDir.mkdir();
}
......@@ -22,17 +35,17 @@ public class GenCompiler extends Parser {
String fileName = null;
try {
// Generate JastAdd abstract grammar
fileName = "siaras/Siaras.ast";
fileName = name+"/"+name+".ast";
PrintStream pStream = new PrintStream(new File(fileName));
ast.genAbsGrammar(pStream);
// Generate Parser.java
fileName = "siaras/Parser.java";
fileName = name+"/Parser.java";
pStream = new PrintStream(new File(fileName));
ast.genParser(pStream);
// Generate aspects
fileName = "siaras/GeneratedAspects.jrag";
fileName = name+"/GeneratedAspects.jrag";
pStream = new PrintStream(new File(fileName));
ast.genAspects(pStream);
......
......@@ -16,8 +16,8 @@ import AST.Start;
public class Parser {
protected static Start parse(String args[]) {
Reader r = getReader(args);
protected static Start parse(String arg) {
Reader r = getReader(arg);
Start ast = null;
try {
OwlParser parser = new OwlParser(r);
......@@ -29,17 +29,22 @@ public class Parser {
return ast;
}
private static Reader getReader(String[] args) {
private static Reader getReader(String arg) {
Reader r = null;
if (args.length != 1) {
r = new InputStreamReader(System.in);
} else {
// if (args.length != 1) {
// r = new InputStreamReader(System.in);
// } else {
// try {
// r = new FileReader(args[0]);
// } catch (FileNotFoundException e1) {
// System.err.println("Dumper: file " + args[0] + " not found");
// }
try {
r = new FileReader(args[0]);
r = new FileReader(arg);
} catch (FileNotFoundException e1) {
System.err.println("Dumper: file " + args[0] + " not found");
System.err.println("Dumper: file " + arg + " not found");
}
}
// }
return r;
}
......
/* -*-Java-*- */
/*
* Copyright (C) 2006 Anders Nilsson <anders.nilsson@cs.lth.se>
* Copyright (C) 2006-2008 Anders Nilsson <anders.nilsson@cs.lth.se>
*
* This file is part of OntologyCompiler.
*/
......
......@@ -27,7 +27,7 @@
<!-- compile sources -->
<target name="build" depends="gen">
<javac compiler="jikes" debug="true" nowarn="true" srcdir="." includes="**/*.java" excludes="tools/** siaras/**" classpath=".:${tools}/beaver-rt.jar:${tools}/junit.jar"/>
<javac compiler="jikes" debug="true" nowarn="true" srcdir="." includes="AST/*.java *.java" excludes="tools/** " classpath=".:${tools}/beaver-rt.jar:${tools}/junit.jar"/>
</target>
<!-- generate compiler source files -->
......
......@@ -64,12 +64,15 @@ XmlBase : Attribute;
Xmlns : Attribute;
XmlnsDaml : Attribute;
XmlnsDc : Attribute;
XmlnsOwl : Attribute;
XmlnsP1 : Attribute;
XmlnsProtege : Attribute;
XmlnsRdf : Attribute;
XmlnsXsd : Attribute;
XmlnsRdfs : Attribute;
XmlnsOwl : Attribute;
XmlnsSwrl : Attribute;
XmlnsSwrlb : Attribute;
XmlnsXsd : Attribute;
XmlnsXsp : Attribute;
DiscardedElement : Element ::= Identifier Attribute* Element*;
......
......@@ -111,11 +111,14 @@ SPECIAL_TOKEN : /* COMMENTS */
| < XMLNS_DAML : "xmlns:daml" >
| < XMLNS_DC : "xmlns:dc" >
| < XMLNS_P1 : "xmlns:p1" >
| < XMLNS_OWL : "xmlns:owl" >
| < XMLNS_PROTEGE : "xmlns:protege" >
| < XMLNS_RDF : "xmlns:rdf" >
| < XMLNS_XSD : "xmlns:xsd" >
| < XMLNS_RDFS : "xmlns:rdfs" >
| < XMLNS_OWL : "xmlns:owl" >
| < XMLNS_SWRL : "xmlns:swrl" >
| < XMLNS_SWRLB : "xmlns:swrlb" >
| < XMLNS_XSD : "xmlns:xsd" >
| < XMLNS_XSP : "xmlns:xsp" >
}// RESERVED WORDS AND LITERALS
<DEFAULT, BOUNDS> TOKEN : /* LITERALS */
......@@ -708,7 +711,10 @@ void XmlnsAttribute() : {}
| XmlnsProtege()
| XmlnsRdf()
| XmlnsRdfs()
| XmlnsSwrl()
| XmlnsSwrlb()
| XmlnsXsd()
| XmlnsXsp()
}
void Xmlns() #Xmlns : {}
......@@ -741,11 +747,26 @@ void XmlnsRdf() #XmlnsRdf : {}
<XMLNS_RDF> <ASSIGN> Value()
}
void XmlnsSwrl() #XmlnsSwrl : {}
{
<XMLNS_SWRL> <ASSIGN> Value()
}
void XmlnsSwrlb() #XmlnsSwrlb : {}
{
<XMLNS_SWRLB> <ASSIGN> Value()
}
void XmlnsXsd() #XmlnsXsd : {}
{
<XMLNS_XSD> <ASSIGN> Value()
}
void XmlnsXsp() #XmlnsXsp : {}
{
<XMLNS_XSP> <ASSIGN> Value()
}
void XmlnsRdfs() #XmlnsRdfs : {}
{
<XMLNS_RDFS> <ASSIGN> Value()
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment