// demdraw.cd -- CD for Apstudio // Authors - Kedar & Binoy // modified: Binoy : 1998/03/12 //***************************************************************************** // package EDU.neu.ccs.demeter.tools.apstudio.graphedit; import java.awt.*; import java.io.*; import java.util.*; import EDU.neu.ccs.demeter.*; import EDU.neu.ccs.demeter.common.tg.*; // Topmost class in class structure is Graph UGraph = "#Class" "#Dictionary" "#Graph" *l [ Package *l] [ SList(Import) *l ] [ JavaCode *l] //deprecated [< vertices >UVertex_List] Hashtable //vert list <-> hash [< edges > UEdge_List] Hashtable //edge list <-> hash Hashtable [UID] *EOF*. /** TODO: 1. Rethink Package handling. Since new demjava 0.5.6 can have more than one package statement! 2. Same for global & local imports. 3. Remove support for preamble */ // Following is description of class Vertex_List and its parts UVertex_List ~ "#Vertex" "#List" *l + UVertex {*l UVertex } *l- . UVertex : UConstOrAltVertex | UTerm | UInterface *common* < vid > UID < vertexname > UVertexName < position > Coordinates [< incoming > IEdge_List] //incoming uids [< outgoing > OEdge_List] //outgoing uids Vector Vector [Decorator] //subgraph tag TGVertex < persp > Perspective *extends* NetPrimitive . UConstOrAltVertex : UConstVertex | UAltVertex *common* ParseOrNot Vector [ ScopeIdentifier_List]. ParseOrNot : YaParse | NopParse. YaParse = "#parse". NopParse = "#noparse". UTerm : UTermConstVertex | UTermInterface. IEdge_List ~ "#Incoming" UID { "," UID }. //commalist uid {","uid} OEdge_List ~ "#Outgoing" UID { "," UID }. //commalist uid {","uid} UConstVertex = "#ConstVertex" [< beFore > UBefore][< afTer > UAfter]. UBefore = "#Before" String. UAfter = "#After" String. UAltVertex = "#AltVertex" . UInterface = "#Interface" [ InterfaceModifier_List] JavaCode. InterfaceModifier_List ~ InterfaceModifier { InterfaceModifier }. InterfaceModifier : PublicModifier. PublicModifier = "#public". UTermConstVertex = "#TermConstVertex" . UTermInterface = "#TermInterface" . ScopeIdentifier_List ~ ScopeIdentifier { ScopeIdentifier }. ScopeIdentifier : PublicIdentifier | FinalIdentifier . PublicIdentifier = "#public". FinalIdentifier = "#final". // Following is description of class Edge_List and its parts UEdge_List ~ "#Edge" "#List" *l + UEdge {*l UEdge } *l -. UEdge : USuperEdge | UConstEdge *common* < eid >UID < fromVertex > UID < toVertex > UID [Decorator] //subgraph tag [ BendPoint]//_List ] ArcPerspective *extends* NetPrimitive. //BendPoint_List ~ BendPoint{BendPoint}. USuperEdge : UAltEdge | UExtendEdge | UImplEdge . BendPoint = Coordinates. UAltEdge = "#AltEdge" TGAEdge. UExtendEdge = "#ExtendEdge" TGAEdge. UImplEdge = "#ImplEdge" TGIEdge. UConstEdge = "#ConstEdge" [< edgename > UEdgeName] Cardinality [UBefore][UAfter] [ PartModifier_List] TGCEdge. PartModifier_List ~ PartModifier { PartModifier }. PartModifier : FinalMod | StaticMod | ReadOnlyMod | PrivateMod . FinalMod = "#final". StaticMod = "#static". ReadOnlyMod = "#read-only". PrivateMod = "#private". Cardinality = "#Cardinality" < lower > Lower [ < upper > Upper]. Lower = Integer. Upper = "." "." String. // Classes common to Vertex and Edge UID = < id > Integer. UEdgeName = Ident *implements* PartNameI. UVertexName = Ident *implements* ClassNameI. // Classes common to Vertex , VertexName , Edge and EdgeName Coordinates = "{" X Y "}". X = Integer . Y = Integer . //Decorator to store the attribute(color?) of vertices and edges Decorator = "travstat"Integer Vector.//PList(Attributes) //Attributes = Integer. //IndependantTraversal= "from" List(SUID) Vector // TOCLASS // List(DUID) Vector // ["bypassing" List(UID) ] // Vector. //SUID = UID. //DUID = UID. //TOCLASS : ToV | ToStopV. ///ToV = "to". //ToStopV = "tostop". UniqueIDGenerator= . // demjava.cd -- class dictionary for Demeter/Java // $Id: demjava.cd,v 1.54 1998/03/01 12:05:35 dougo Exp $ Program = GlobalImports ClassGraph *EOF* . GlobalImports = [ SList(Import) *l ] . Import = "import" PackageName [ ImportAllClasses ] ";". ImportAllClasses = ".*". ClassGraph = Hashtable DList(ClassGraphEntry) [ "tg:" TraversalGraph ] . ClassGraphEntry : Directive | Definition. Directive : ParseDirective | VisitorDirective | PackageDirective. ParseDirective = ParseKeyword. VisitorDirective = VisitorKeyword. PackageDirective = Package *l LocalImports. Package = "package" PackageName ";". LocalImports = [ SList(Import) *l ] . Definition : ClassDef. ClassDef = List(ClassKeyword) ParamClassName [ *s ParseDirective ] *s ClassParts [ ClassMethods ] [ *s EOFtoken ] "." . ParamClassName = ClassName ["(" Commalist(ClassName) ")"]. ClassParts : ConstOrAltClass | RepetitionClass. ConstOrAltClass : ConstructionClass | AlternationClass *common* + + + List(PartOrSyntax) ClassParents - - -. PartOrSyntax : Part | OptionalPart | Syntax. Part = [ "<" PartName ">" *s ] List(PartKeyword) ClassSpec [ PartInit ]. PartInit = PartInitKeyword *s JavaCode. OptionalPart = "[" [LocalLookahead] Sandwich(Part) "]". ClassParents = [ Superclasses ] [ Interfaces ]. Superclasses = ExtendsKeyword Commalist(Superclass). Superclass = ClassSpec. Interfaces = ImplementsKeyword Commalist(Interface). Interface = ClassSpec. ConstructionClass = "=". AlternationClass = ":" + + + [ *lookahead* (@ _Subclass() @) Barlist(Subclass) ] - - - [ CommonKeyword ]. Subclass = [LocalLookahead] ClassSpec. LocalLookahead = LookaheadKeyword JavaCode. RepetitionClass = "~" Sandwich(RepeatedPart). RepeatedPart = [ ClassSpec ] "{" [LocalLookahead] Sandwich(ClassSpec) *s "}". Sandwich(S) = List(Syntax) *s S List(Syntax) . ClassSpec = ClassName ["(" Commalist(ClassSpec) ")" ] . Syntax : PlainSyntax | PrintCommand. PlainSyntax = String. PrintCommand : PrintIndent | PrintUnindent | PrintSkip | PrintSpace. PrintIndent = "+" . PrintUnindent = "-" . PrintSkip = "*l" . PrintSpace = "*s" . EOFtoken = "*EOF*". ////////////////////// // Behavior (methods). ////////////////////// ProgramBehavior = [ DList(Behavior) ] *EOF* . Behavior : StrategyDefinition | ClassBehavior. StrategyDefinition = "strategy" StrategyName "=" StrategyExpression ".". StrategyExpression : StrategyGraph | PathDirective | StrategyVariable | CompoundStrategy. StrategyGraph = "{" *l + [ "vec:" *s Vector ] SList(SGEdge) - *l "}" *s [ "source:" ClassGlobSpec ] [ "source-edge:" NList(Integer) ] [ "target:" ClassGlobSpec ] *implements* StrategyGraphI . SGEdge = ClassGlobSpec *s "->" *s ClassGlobSpec [ NegativeConstraint ]. PathDirective = [ NegativeConstraint ] List(PathSegment) TargetDirective. PathSegment = PositiveConstraint [ NegativeConstraint ]. Constraint : PositiveConstraint | NegativeConstraint *common* GlobSpec. PositiveConstraint : Through | Via. // synonyms Through = "through". Via = "via". NegativeConstraint : Bypassing | OnlyThrough. Bypassing = "bypassing". OnlyThrough = "only-through". TargetDirective : To | ToStop *common* ClassGlobSpec. To = "to". ToStop = "to-stop". StrategyVariable = "do" StrategyName. CompoundStrategy : Join | Merge | Intersect *common* "(" Commalist(StrategyExpression) ")". Join = "join". Merge = "merge". Intersect = "intersect". GlobSpec : OneGlob | GlobSet. OneGlob = Glob. GlobSet = "{" *s [ Commalist(Glob) *s ] "}". Glob : ClassGlob | EdgeGlob. EdgeGlob : PartGlob | SubclassGlob | SuperclassGlob. ClassGlob = ClassNameGlob. PartGlob = "->" *s SourceGlob "," *s PartNameGlob "," *s DestGlob. SubclassGlob = "=>" *s SourceGlob "," *s DestGlob. SuperclassGlob = ":>" *s SourceGlob "," *s DestGlob. SourceGlob = ClassNameGlob. DestGlob = ClassNameGlob. ClassNameGlob : ClassNameExact | AnyClass. ClassNameExact = ClassName. AnyClass = "*". PartNameGlob : PartNameExact | AnyPart. PartNameExact = PartName. AnyPart = "*". ClassGlobSpec : OneClassGlob | ClassGlobSet. OneClassGlob = ClassGlob. ClassGlobSet = "{" *s Commalist(ClassGlob) *s "}". ClassBehavior = ClassGlobSpec ClassMethods. ClassMethods = "{" *l + [ SList(Method) ] - *l "}" [ "wrappers:" Hashtable // maps Wrapper-kind -> HostSet ] . HostSet = [ "exact:" Hashtable ] // globs with no stars [ "partnames:" Hashtable ] // -> *,name,* globs [ "globs:" GlobSet] . // other globs Method : TraversalDef | MethodDef | Wrapper | Accessor | Constructor | Start | Finish | ReturnValue | Verbatim. // Class graph traversal definitions. TraversalDef = "traversal" TraversalName TraversalParms *s "{" *l + StrategyExpression ";" - *l "}". TraversalParms = "(" [ Commalist(Visitor) ] ")" . Visitor = ClassName [ VisitorName ]. // Adaptive methods. MethodDef = MethodSignature MethodBody. MethodSignature = List(MethodKeyword) JavaType MethodName "(" [ Commalist(MethodParm) ] ")" Throws. MethodKeyword : PublicMethod | ProtectedMethod | PrivateMethod | StaticMethod | FinalMethod | AbstractMethod. PublicMethod = "public". ProtectedMethod = "protected". PrivateMethod = "private". StaticMethod = "static". FinalMethod = "final". AbstractMethod = "abstract". MethodParm = JavaType List(ArraySpec) ParmName List(ArraySpec). ArraySpec = "[" "]". Throws = [ *s "throws" Commalist(ClassName) ]. MethodBody : VerbatimMethodBody | AdaptiveMethodBody | NoMethodBody. VerbatimMethodBody = JavaCode. AdaptiveMethodBody = TraversalExpression VisitorExpression. NoMethodBody = ";". TraversalExpression : TraversalRef | TraversalSpec. TraversalRef = [Equals] TraversalName. Equals = "=". // optional syntax TraversalSpec = StrategyExpression. VisitorExpression : VisitorRef | VisitorSpec. VisitorRef : WithVisitorRef | ParenVisitorRef. WithVisitorRef = "with" Commalist(ClassName) ";". ParenVisitorRef = "(" Commalist(ClassName) ")" ";". VisitorSpec = ClassMethods. // Visit methods. Wrapper = WrapperKind HostSpec JavaCode. WrapperKind : Before | Around | After. Before = "before". Around = "around". After = "after". HostSpec : GlobSpec. // Derived part accessors. Accessor : Getter | Setter *common* PartName JavaCode . Getter = "get" . Setter = "set" . // Constructor method. // Only no-arg constructors supported for now. Constructor = "init" JavaCode. // Methods called at the beginning and ending of a traversal. Start = "start" JavaCode. Finish = "finish" JavaCode. // Code for computing the return value of a visitor when used in an // adaptive method. ReturnValue = "return" [ JavaType ] JavaCode. // Verbatim java code. Verbatim = JavaCode. // Terminal buffer classes. PackageName ~ IdentOrKeyword { *lookahead* (@ 2 @) "." IdentOrKeyword }. ClassName = Name *implements* ClassNameI. PartName = IdentOrKeyword *implements* PartNameI. TraversalName = Name. VisitorName = Name. MethodName = Ident. ParmName = Ident. StrategyName = Ident. JavaType = Name. JavaCode = Text. Name ~ Ident { // kludge!! *lookahead* (@ "." _Ident(),{ "=:~(".indexOf(getToken(3).image) == -1 } @) "." Ident }. // All the keywords that look like identifiers in the class dictionary // grammar that aren't keywords in Java. IdentOrKeyword : ParseIdent | NoParseIdent | VisitorsIdent | EndVisitorsIdent | VisitorIdent | NotParsedIdent | DerivedIdent | InitIdent | CommonIdent | LookaheadIdent | OtherIdent. ParseIdent = "parse". NoParseIdent = "noparse". VisitorsIdent = "visitors". EndVisitorsIdent = "endvisitors". VisitorIdent = "visitor". NotParsedIdent = "notparsed". DerivedIdent = "derived". InitIdent = "init". CommonIdent = "common". LookaheadIdent = "lookahead". OtherIdent = Ident. // Keywords with optional star forms. ParseKeyword : DoParse | DontParse. DoParse : DoParseWithoutStars | DoParseWithStars. DoParseWithoutStars = "parse". DoParseWithStars = "*parse*". DontParse : DontParseWithoutStars | DontParseWithStars. DontParseWithoutStars = "noparse". DontParseWithStars = "*noparse*". VisitorKeyword : BeginVisitors | EndVisitors. BeginVisitors : BeginVisitorsWithoutStars | BeginVisitorsWithStars. BeginVisitorsWithoutStars = "visitors". BeginVisitorsWithStars = "*visitors*". EndVisitors : EndVisitorsWithoutStars | EndVisitorsWithStars. EndVisitorsWithoutStars = "endvisitors". EndVisitorsWithStars = "*endvisitors*". ClassKeyword : PublicClass | FinalClass | InterfaceClass | VisitorClass | NotParsedClass. PublicClass : PublicClassWithoutStars | PublicClassWithStars. PublicClassWithoutStars = "public". PublicClassWithStars = "*public*". FinalClass : FinalClassWithoutStars | FinalClassWithStars. FinalClassWithoutStars = "final". FinalClassWithStars = "*final*". InterfaceClass : InterfaceClassWithoutStars | InterfaceClassWithStars. InterfaceClassWithoutStars = "interface". InterfaceClassWithStars = "*interface*". VisitorClass : VisitorClassWithoutStars | VisitorClassWithStars. VisitorClassWithoutStars = "visitor". VisitorClassWithStars = "*visitor*". NotParsedClass : NotParsedClassWithoutStars | NotParsedClassWithStars. NotParsedClassWithoutStars = "notparsed". NotParsedClassWithStars = "*notparsed*". PartKeyword : FinalPart | StaticPart | ReadOnlyPart | PrivatePart | DerivedPart. FinalPart : FinalPartWithoutStars | FinalPartWithStars. FinalPartWithoutStars = "final". FinalPartWithStars = "*final*". StaticPart : StaticPartWithoutStars | StaticPartWithStars. StaticPartWithoutStars = "static". StaticPartWithStars = "*static*". ReadOnlyPart : ReadOnlyPartWithoutStars | ReadOnlyPartWithStars. ReadOnlyPartWithoutStars = "read-only". ReadOnlyPartWithStars = "*read-only*". PrivatePart : PrivatePartWithoutStars | PrivatePartWithStars. PrivatePartWithoutStars = "private". PrivatePartWithStars = "*private*". DerivedPart : DerivedPartWithoutStars | DerivedPartWithStars. DerivedPartWithoutStars = "derived". DerivedPartWithStars = "*derived*". PartInitKeyword : PartInitKeywordWithoutStars | PartInitKeywordWithStars. PartInitKeywordWithoutStars = "init". PartInitKeywordWithStars = "*init*". ExtendsKeyword : ExtendsKeywordWithoutStars | ExtendsKeywordWithStars. ExtendsKeywordWithoutStars = "extends". ExtendsKeywordWithStars = *s "*extends*" *s. ImplementsKeyword : ImplementsKeywordWithoutStars | ImplementsKeywordWithStars. ImplementsKeywordWithoutStars = "implements". ImplementsKeywordWithStars = *s "*implements*" *s. CommonKeyword : CommonWithoutStars | CommonWithStars. CommonWithoutStars = *l + + + "common" - - -. CommonWithStars = *l + + + "*common*" - - -. LookaheadKeyword : LookaheadKeywordWithoutStars | LookaheadKeywordWithStars. LookaheadKeywordWithoutStars = "lookahead". LookaheadKeywordWithStars = "*lookahead*". // Parameterized class definitions. List(S) ~ {*s S}. NList(S) ~ S {*s S}. SList(S) ~ S { *l S } . DList(S) ~ S { *l *l S } *l . Commalist(S) ~ S {"," *s S}. Barlist(S) ~ S { *l "|" *s S}. *noparse* // Utility classes. TraversalMethodName = MethodName. ClassType = boolean boolean boolean boolean boolean boolean boolean boolean. PartType = boolean boolean boolean boolean boolean . Parts ~ { Part }. ///********** //visitors (text-uml ones) //turn off parsing for the visitors *noparse* *visitors* PlacementVisitor = UGraph . EdgeDistinctionVisitor = String. ClassNameRetVisitor = ClassName. ClassNameTranspVisitor = ParamClassName. EdgeVisitor = EdgeDistinctionVisitor ClassNameTranspVisitor UGraph. //************ // Visitors for UML - to - TEXT traversals VertexReadingVisitor = UGraph String Integer Integer . EdgeReadingVisitor = UGraph String String Integer String Integer Integer . // Visitors and Main class (the GUI ones) ReadVertexVisitor= VertexContainer . VertexContainer = < construction > Vector < alternation > Vector < termination > Vector. ReadEdgeVisitor = < elements > EdgeContainer . EdgeContainer = < construction > Vector < alternation > Vector . Main = . CountingVisitor = Integer . //TraversalVisitor = UGraph IndependantTraversal . superInitVisitor : InitVisitor | HashCreateVisitor | TGUpdateVisitor. InitVisitor = . HashCreateVisitor =. ListVectorVisitor = VectorVectorVector. DecoCollectVisitor =UID Vector. tostopVisitor = . RepClassSpecVisitor = Name Name. PlaceVertexVisitor = Coordinates Hashtable Hashtable. SomeClassSpecVisitor = UConstEdge. //Visitors for cd2gcd : for Modifiers IntModVisitor = InterfaceModifier_List . ClassModVisitor = ScopeIdentifier_List . PartModVisitor = PartModifier_List . //visitors for cdstring.beh cdStringVisitor : ConstVisitor | AltVisitor | IntVisitor *common* String. ConstVisitor = Hashtable Hashtable . AltVisitor = Hashtable Hashtable . IntVisitor = Hashtable Hashtable . //visitors for CTGstrategy.beh ClassGlobVisitor : SourceEdgeCollector . SourceEdgeCollector = StrategyGraph NList(Integer). ClassNameAccessor : . GlobVisitor : GlobMatcher | GlobCollector | ClassGlobCollector | EdgeGlobCollector | OutgoingEdgeSpecConvertor | SGEdgeMatcher . GlobMatcher = Glob boolean. GlobCollector = GlobSet. ClassGlobCollector = ClassGlobSet. EdgeGlobCollector = GlobSet. OutgoingEdgeSpecConvertor = GlobSet. SGEdgeMatcher = ClassNameI int Vector. TGVertexCollector = TraversalGraph. TGEdgeGlobMaker = ClassName ClassName ClassName PartName Glob *extends* TGEdgeVisitor. //visitors for CTGsubgraph.beh TGCreateVisitor = TraversalGraph Hashtable. TGUpdateVisitor = . //visitor for gcdsave.beh & extracting propagation graph SaveGraphVisitor = < graphString > String . SelectMarkedVisitor = boolean boolean boolean String String. // Visitors for strategy graph extraction SGraphCollector = Vector Vector. VecVisitor = Vector. StringVisitor = String. DummyVisitor=.