From 1da31eb45f1ca7fb62cb4293ee8f3d2ac1eb0d82 Mon Sep 17 00:00:00 2001 From: Anders Nilsson <anders.nilsson@cs.lth.se> Date: Sun, 10 Dec 2006 22:14:15 +0100 Subject: [PATCH] Synching. Doesn't compile --- CompilerGeneration.jrag | 25 +++++++++++++++++++++++++ siaras/build.xml | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/CompilerGeneration.jrag b/CompilerGeneration.jrag index 39fb59c..88efcb8 100644 --- a/CompilerGeneration.jrag +++ b/CompilerGeneration.jrag @@ -27,6 +27,7 @@ aspect AbsGrammarGeneration { pStream.println("StringElement : SimpleElement ::= <IDENTIFIER>;"); pStream.println("IntElement : SimpleElement ::= <INTEGER_LITERAL>;"); pStream.println("FloatElement : SimpleElement ::= <FLOAT_LITERAL>;"); + pStream.println("abstract ClassUse : ComplexElement ::= /decl:Thing/;"); pStream.println("Attribute ::= Value;"); pStream.println("RdfDatatype : Attribute ::= ;"); pStream.println("RdfId : Attribute ::= ;"); @@ -58,6 +59,9 @@ aspect AbsGrammarGeneration { pStream.print(" ::="); getOwnRestrictions().genAbsGrammar(pStream); pStream.println(";"); + pStream.print(getId()+"Use"); + pStream.print(" : ClassUse"); + pStream.println(";"); } void Restrictions.genAbsGrammar(PrintStream pStream) { @@ -251,8 +255,16 @@ aspect GenRewrites { pStream.println(ind(3)+"return node;"); pStream.println(ind(2)+"}"); pStream.println(ind(1)+"}"); + pStream.println(); // Rearrange device nodes on the AST to get away from the // current diagonal style from Protege + pStream.println(ind(1)+"rewrite "+name()+" {"); + pStream.println(ind(2)+"when (!isTopElement())"); + pStream.println(ind(2)+"to "+name()+"Use {"); + pStream.println(ind(3)+"getStart().addElement(this);"); + pStream.println(ind(3)+"return new "+name()+"Use();"); + pStream.println(ind(2)+"}"); + pStream.println(ind(1)+"}"); } } @@ -282,6 +294,19 @@ aspect GenMisc { pStream.println(ind(1)+"eq StringElement.value() = getIDENTIFIER();"); pStream.println(ind(1)+"eq IntElement.value() = getINTEGER_LITERAL();"); pStream.println(ind(1)+"eq FloatElement.value() = getFLOAT_LITERAL();"); + + pStream.println(ind(1)+"boolean Thing.isTopElement() {"); + pStream.println(ind(2)+"return getParent().getParent() instanceof Start;"); + pStream.println(ind(1)+"}"); + + pStream.println(ind(1)+"Start ASTNode.getStart() {"); + pStream.println(ind(2)+"return getParent().getStart();"); + pStream.println(ind(1)+"}"); + pStream.println(ind(1)+"Start Start.getStart() {"); + pStream.println(ind(2)+"return this;"); + pStream.println(ind(1)+"}"); + + super.genMisc(pStream); pStream.println("}"); } diff --git a/siaras/build.xml b/siaras/build.xml index dffb26c..98cdf20 100644 --- a/siaras/build.xml +++ b/siaras/build.xml @@ -6,7 +6,7 @@ gen - generates java files genClean - removes all generated files and their class files --> -<project name="Java1.4Frontend" default="build" basedir="."> +<project name="OntologyCompiler" default="build" basedir="."> <!-- "package" is the directory where generated files will be stored --> <property name="package" value="AST"/> -- GitLab