From af9b6e5521ea31d9388b36490020ccd9fadb7a08 Mon Sep 17 00:00:00 2001 From: Sven Gestegard Robertz <sven.robertz@cs.lth.se> Date: Wed, 20 May 2015 11:02:36 +0200 Subject: [PATCH] Preliminary refactoring: added annotations to *Decl --- compiler/2014/Annotations.jrag | 3 ++- compiler/2014/LabComm.ast | 2 +- compiler/2014/LabCommParser.parser | 4 ++-- compiler/2014/Refactoring.jrag | 8 ++++++++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/compiler/2014/Annotations.jrag b/compiler/2014/Annotations.jrag index 3533f8e..8616604 100644 --- a/compiler/2014/Annotations.jrag +++ b/compiler/2014/Annotations.jrag @@ -5,8 +5,9 @@ aspect Annotations { syn boolean Annotation.isIntention() = false; eq Intention.isIntention() = true; - inh TypeInstance Annotation.parentInstance(); + inh ASTNode Annotation.parentInstance(); eq TypeInstance.getAnnotation(int i).parentInstance() = this; + eq Decl.getAnnotation(int i).parentInstance() = this; coll Set<Intention> TypeInstance.intentionSet() [new HashSet<Intention>()] with add; diff --git a/compiler/2014/LabComm.ast b/compiler/2014/LabComm.ast index f2c73dd..311cac4 100644 --- a/compiler/2014/LabComm.ast +++ b/compiler/2014/LabComm.ast @@ -1,6 +1,6 @@ Specification ::= Decl*; -abstract Decl ::= TypeInstance /Signature/; +abstract Decl ::= TypeInstance Annotation* /Signature/; TypeInstance ::= DataType <Name:String> Annotation*; diff --git a/compiler/2014/LabCommParser.parser b/compiler/2014/LabCommParser.parser index 73f8080..6624635 100644 --- a/compiler/2014/LabCommParser.parser +++ b/compiler/2014/LabCommParser.parser @@ -82,10 +82,10 @@ Field var_decl = ; TypeDecl type_decl = - TYPEDEF type_instance.t SEMICOLON {: return new TypeDecl(t); :} ; + annotations.a TYPEDEF type_instance.t SEMICOLON {: return new TypeDecl(t, a); :} ; SampleDecl sample_decl = - SAMPLE type_instance.t SEMICOLON {: return new SampleDecl(t); :} ; + annotations.a SAMPLE type_instance.t SEMICOLON {: return new SampleDecl(t, a); :} ; DataType type = prim_type.p {: return p; :} diff --git a/compiler/2014/Refactoring.jrag b/compiler/2014/Refactoring.jrag index fbe083f..84f3484 100644 --- a/compiler/2014/Refactoring.jrag +++ b/compiler/2014/Refactoring.jrag @@ -11,4 +11,12 @@ aspect Refactoring { this(t, n, new List<Annotation>()); System.out.println("WARNING! TypeInstance(DataType, String) ignoring intention list"); } + public TypeDecl.TypeDecl(TypeInstance t) { + this(t, new List<Annotation>()); + System.out.println("WARNING! TypeDecl(TypeInstance) ignoring intention list"); + } + public SampleDecl.SampleDecl(TypeInstance t) { + this(t, new List<Annotation>()); + System.out.println("WARNING! SampleDecl(TypeInstance) ignoring intention list"); + } } -- GitLab