////////////////// class dictionary import edu.neu.ccs.demeter.dj.*; import java.util.*; import java.io.*; public AC = List(Collaboration) *EOF*. public Collaboration = "collaboration" CollabName [IsACollab] ";" Structure AdapterDef. public IsACollab = "extends" CollabName. public Structure = Imports List(ParticipantDef) *l . public IsA = "extends" ParticipantName. public Impls = "implements" CommaList(ParticipantName). public HasA = JavaType VarName ";". public Imports = List(Import). public Import = "import" LongImportName ";" *l. public LongImportName = LongName. public ParticipantDef = ParticipantOrInterface ParticipantName [IsA] [Impls] *l. public ParticipantOrInterface : IsParticipant | IsInterface. public IsParticipant = "participant". public IsInterface = "interface". public AdapterDef = List(AdapterItem). // order is IMPORTANT public AdapterItem = "attach" [ CommaList(CollabRef)] AttachmentSpecList. public CollabRef : ResharedCollab | SharedCollab | NormalCollab common CollabName. public ResharedCollab = "reshared" . public SharedCollab = "shared" . public NormalCollab = "normal". public AttachmentSpecList = "{" List(Attachment) "}". public Attachment = "{" ShortName ":" + *l List(CompositeParticipantDef) - *l "}". public CompositeParticipantDef = PartSpec "+=" [ CommaList(PartSpec)] With *l. public With = "with" BracedList(Entry). Entry : Export | Around. Around = "around" ShortName ":" NameSpec "do" NameSpec . public Export = "export" NameSpec ["as" NameSpec] . List(S) ~ { S}. CommaList(S) ~ S {"," *s S}. BracedList(P) ~ "{" + *l { P } - *l "}". public PartSpec = LongName. public ShortName = Ident. public LongName ~ ShortName { "." ShortName}. public VarName = ShortName. public JavaType = LongName List(ArraySpec). public ArraySpec = "[" "]". public NameSpec = ShortName. public CollabName = LongName. public ParticipantName = ShortName. Main = . ///////////////////// behavior file Main { {{ public static void main(String[] args) throws Exception { AC ac = AC.parse(System.in); ac.print(); System.out.println(); System.out.println("done 1"); ac.display(); System.out.println(); System.out.println("done 2"); ac.display_all(); System.out.println(); System.out.println("done 3"); // DJ ClassGraph cg = new ClassGraph(true, false); ClassGraph cgCommandsWithoutTail = new ClassGraph(cg, "from AC bypassing -> *,tail,* to *"); ac.process(new TraversalGraph("from AC to ParticipantDef", cg)); System.out.println("done"); } }} } ParticipantName { void print() to Ident (PrintVisitor); } AC { void display_all() bypassing -> *,tail,* to * (DisplayVisitor); } AC { void display() bypassing -> *,tail,* to Attachment (DisplayVisitor); } AC { void print() to * (PrintVisitor); } AC { {{ void process(TraversalGraph where) { Visitor cV = new Visitor() { void before(ParticipantDef host){ System.out.println("participant name "); host.get_name().print(); System.out.println(); }; public void start() {System.out.println("start the traversal");} }; where.traverse(this, cV); } }} } ///////////// output collaboration counts;participant Counted extends X collaboration gettersNsetters;participant Foo implements Y collaboration result;participant Food attach normal gettersNsetters{{gns: Food+=Foo, X, edu.neu.ccs.demeter.S with{ around gns:get_str do counted export main as y } }}attach shared counts{{q: Food+=Counted, R, S.T with{ export gns as counted export gnsset_i as reset } }} done 1 : AC ( : Collaboration_List { : Nonempty_Collaboration_List ( : Collaboration ( : AdapterDef ( : AdapterItem_List { } ) ) : Nonempty_Collaboration_List ( : Collaboration ( : AdapterDef ( : AdapterItem_List { } ) ) : Nonempty_Collaboration_List ( : Collaboration ( : AdapterDef ( : AdapterItem_List { : Nonempty_AdapterItem_List ( : AdapterItem ( : AttachmentSpecList ( : Attachment_List { : Nonempty_Attachment_List ( : Attachment ( ) ) } ) ) : Nonempty_AdapterItem_List ( : AdapterItem ( : AttachmentSpecList ( : Attachment_List { : Nonempty_Attachment_List ( : Attachment ( ) ) } ) ) ) ) } ) ) ) ) ) } ) done 2 : AC ( : Collaboration_List { : Nonempty_Collaboration_List ( : Collaboration ( : CollabName ( : LongName { : Nonempty_LongName ( : ShortName ( : Ident "counts" ) ) } ) : Structure ( : Imports ( : Import_List { } ) : ParticipantDef_List { : Nonempty_ParticipantDef_List ( : ParticipantDef ( : IsParticipant ( ) : ParticipantName ( : ShortName ( : Ident "Counted" ) ) : IsA ( : ParticipantName ( : ShortName ( : Ident "X" ) ) ) ) ) } ) : AdapterDef ( : AdapterItem_List { } ) ) : Nonempty_Collaboration_List ( : Collaboration ( : CollabName ( : LongName { : Nonempty_LongName ( : ShortName ( : Ident "gettersNsetters" ) ) } ) : Structure ( : Imports ( : Import_List { } ) : ParticipantDef_List { : Nonempty_ParticipantDef_List ( : ParticipantDef ( : IsParticipant ( ) : ParticipantName ( : ShortName ( : Ident "Foo" ) ) : Impls ( : ParticipantName_CommaList { : Nonempty_ParticipantName_CommaList ( : ParticipantName ( : ShortName ( : Ident "Y" ) ) ) } ) ) ) } ) : AdapterDef ( : AdapterItem_List { } ) ) : Nonempty_Collaboration_List ( : Collaboration ( : CollabName ( : LongName { : Nonempty_LongName ( : ShortName ( : Ident "result" ) ) } ) : Structure ( : Imports ( : Import_List { } ) : ParticipantDef_List { : Nonempty_ParticipantDef_List ( : ParticipantDef ( : IsParticipant ( ) : ParticipantName ( : ShortName ( : Ident "Food" ) ) ) ) } ) : AdapterDef ( : AdapterItem_List { : Nonempty_AdapterItem_List ( : AdapterItem ( : CollabRef_CommaList { : Nonempty_CollabRef_CommaList ( : NormalCollab ( : CollabName ( : LongName { : Nonempty_LongName ( : ShortName ( : Ident "gettersNsetters" ) ) } ) ) ) } : AttachmentSpecList ( : Attachment_List { : Nonempty_Attachment_List ( : Attachment ( : ShortName ( : Ident "gns" ) : CompositeParticipantDef_List { : Nonempty_CompositeParticipantDef_List ( : CompositeParticipantDef ( : PartSpec ( : LongName { : Nonempty_LongName ( : ShortName ( : Ident "Food" ) ) } ) : PartSpec_CommaList { : Nonempty_PartSpec_CommaList ( : PartSpec ( : LongName { : Nonempty_LongName ( : ShortName ( : Ident "Foo" ) ) } ) : Nonempty_PartSpec_CommaList ( : PartSpec ( : LongName { : Nonempty_LongName ( : ShortName ( : Ident "X" ) ) } ) : Nonempty_PartSpec_CommaList ( : PartSpec ( : LongName { : Nonempty_LongName ( : ShortName ( : Ident "edu" ) : Nonempty_LongName ( : ShortName ( : Ident "neu" ) : Nonempty_LongName ( : ShortName ( : Ident "ccs" ) : Nonempty_LongName ( : ShortName ( : Ident "demeter" ) : Nonempty_LongName ( : ShortName ( : Ident "S" ) ) ) ) ) ) } ) ) ) ) } : With ( : Entry_BracedList { : Nonempty_Entry_BracedList ( : Around ( : ShortName ( : Ident "gns" ) : NameSpec ( : ShortName ( : Ident "get_str" ) ) : NameSpec ( : ShortName ( : Ident "counted" ) ) ) : Nonempty_Entry_BracedList ( : Export ( : NameSpec ( : ShortName ( : Ident "main" ) ) : NameSpec ( : ShortName ( : Ident "y" ) ) ) ) ) } ) ) ) } ) ) } ) ) : Nonempty_AdapterItem_List ( : AdapterItem ( : CollabRef_CommaList { : Nonempty_CollabRef_CommaList ( : SharedCollab ( : CollabName ( : LongName { : Nonempty_LongName ( : ShortName ( : Ident "counts" ) ) } ) ) ) } : AttachmentSpecList ( : Attachment_List { : Nonempty_Attachment_List ( : Attachment ( : ShortName ( : Ident "q" ) : CompositeParticipantDef_List { : Nonempty_CompositeParticipantDef_List ( : CompositeParticipantDef ( : PartSpec ( : LongName { : Nonempty_LongName ( : ShortName ( : Ident "Food" ) ) } ) : PartSpec_CommaList { : Nonempty_PartSpec_CommaList ( : PartSpec ( : LongName { : Nonempty_LongName ( : ShortName ( : Ident "Counted" ) ) } ) : Nonempty_PartSpec_CommaList ( : PartSpec ( : LongName { : Nonempty_LongName ( : ShortName ( : Ident "R" ) ) } ) : Nonempty_PartSpec_CommaList ( : PartSpec ( : LongName { : Nonempty_LongName ( : ShortName ( : Ident "S" ) : Nonempty_LongName ( : ShortName ( : Ident "T" ) ) ) } ) ) ) ) } : With ( : Entry_BracedList { : Nonempty_Entry_BracedList ( : Export ( : NameSpec ( : ShortName ( : Ident "gns" ) ) : NameSpec ( : ShortName ( : Ident "counted" ) ) ) : Nonempty_Entry_BracedList ( : Export ( : NameSpec ( : ShortName ( : Ident "gnsset_i" ) ) : NameSpec ( : ShortName ( : Ident "reset" ) ) ) ) ) } ) ) ) } ) ) } ) ) ) ) } ) ) ) ) ) } ) done 3 start the traversal participant name Counted participant name Foo participant name Food done