From cc3a86129e1a33ea2d500b4b568c9fd2f72946c5 Mon Sep 17 00:00:00 2001 From: Anders Nilsson <anders.nilsson@cs.lth.se> Date: Fri, 10 Feb 2006 16:57:44 +0100 Subject: [PATCH] Just started writing code for generating a new compiler --- CompilerGeneration.jrag | 23 +++++++++++++++++++++++ GenCompiler.java | 16 ++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 CompilerGeneration.jrag create mode 100644 GenCompiler.java diff --git a/CompilerGeneration.jrag b/CompilerGeneration.jrag new file mode 100644 index 0000000..aacdcba --- /dev/null +++ b/CompilerGeneration.jrag @@ -0,0 +1,23 @@ +/* -*-Java-*- */ + +import java.io.*; + +aspect CompilerGeneration { + void ASTNode.genAbsGrammar(PrintStream pStream) { + for (int i=0; i<getNumChild(); i++) { + getChild(i).genAbsGrammar(pStream); + } + } + + public void Start.genAbsGrammar(PrintStream p) { + super.genAbsGrammar(p); + } + + void OwlClass.genAbsGrammar(PrintStream pStream) { + pStream.println(getAttribute(0).getValue().getSTRING_LITERAL()); + } +} + +aspect Name { + syn String Element +} \ No newline at end of file diff --git a/GenCompiler.java b/GenCompiler.java new file mode 100644 index 0000000..6ab52a8 --- /dev/null +++ b/GenCompiler.java @@ -0,0 +1,16 @@ +// package programs; + +import AST.Start; + +public class GenCompiler extends Parser { + public static void main(String args[]) { + Start ast = parse(args); + + // Dump the AST +// ast.dumpTree(" ", System.out); + + // Should be generated to a file when sufficiently + // implemented. AndersN 060210 + ast.genAbsGrammar(System.out); + } +} \ No newline at end of file -- GitLab