From fd45da653fdd14d57f3078b00a9debbc30f14f34 Mon Sep 17 00:00:00 2001
From: Anders Nilsson <anders.nilsson@cs.lth.se>
Date: Sun, 5 Nov 2006 21:01:06 +0100
Subject: [PATCH] Started working on generating JavaCC from parsed ontology

---
 CompilerGeneration.jrag | 31 ++++++++++++++++++++++++++++++-
 GenCompiler.java        |  3 ++-
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/CompilerGeneration.jrag b/CompilerGeneration.jrag
index 2b6c253..8cc0055 100644
--- a/CompilerGeneration.jrag
+++ b/CompilerGeneration.jrag
@@ -26,7 +26,9 @@ aspect AbsGrammarGeneration {
     }
 
     void OwlRestriction.genAbsGrammar(PrintStream pStream) {
-		pStream.print(getRestrictionPropertyId());
+// 		pStream.print(getRestrictionPropertyId());
+		pStream.print(getRestrictionClassId().substring(0,1).toLowerCase()+
+					  getRestrictionClassId().substring(1));
 		pStream.print(":");
 		pStream.print(getRestrictionClassId());
 		if (allValuesFrom()) {
@@ -66,3 +68,30 @@ aspect AbsGrammarGeneration {
 
 }
 
+
+
+aspect JavaCCGen {
+
+	public void ASTNode.genJavaCC(PrintStream pStream) {
+		for (int i=0; i<getNumChild(); i++) {
+			getChild(i).genAbsGrammar(pStream);
+		}		
+	}
+
+	public void Start.genJavaCC(PrintStream pStream) {
+		pStream.println("options {");
+		pStream.println("    MULTI                       = true;");
+		pStream.println("    VISITOR                     = true;");
+		pStream.println("    NODE_DEFAULT_VOID           = true;");
+		pStream.println("    NODE_SCOPE_HOOK             = false;");
+		pStream.println("    NODE_PREFIX                 = \"\";");
+		pStream.println("    JAVA_UNICODE_ESCAPE         = true;");
+		pStream.println("    STATIC                      = false;");
+		pStream.println("} ");
+		pStream.println("PARSER_BEGIN(OwlParser)");
+		pStream.println("package AST;");
+		pStream.println("public class OwlParser {");
+		pStream.println("}");
+		pStream.println("PARSER_END(OwlParser)");
+	}
+}
diff --git a/GenCompiler.java b/GenCompiler.java
index 6ab52a8..cb769cb 100644
--- a/GenCompiler.java
+++ b/GenCompiler.java
@@ -12,5 +12,6 @@ public class GenCompiler extends Parser {
 		// Should be generated to a file when sufficiently
 		// implemented. AndersN 060210
 		ast.genAbsGrammar(System.out);
+		ast.genJavaCC(System.out);
 	}
-}
\ No newline at end of file
+}
-- 
GitLab