Hi Mira: time has come to propose a grammar for APPCs. Below is a pretty complete proposal which reuses much of Demeter/Java. As an interim solution I plan to have *.appc files in Demeter/Java that produce Java packages working together with the rest of Demeter/Java. I will polish it further. Any suggestions? -- Karl import java.util.*; import java.io.*; // need to add: // to strategies: // introduce variable names for object transportation // to class graphs: // parameters on edges (methods with arguments) // implement Persephone semantics // to behavior: // allow keyword: main-entry // should we allow strategy {visitor methods} anywhere? APPC_with_Mapping = APPC Mapping. APPC = // independent of class graph "APPC" APPC_Name "ICG" ClassGraph [ NList(StrategyDefinition) ] Behavior . Behavior = "behavior" ClassBehavior. // taken from Demeter/Java and modified // modifications needed to Demeter/Java syntax // add at method // allow return values from wrappers Mapping = // dependent on class graph "mapping" MappingKind. MappingKind : DefaultMapping. DefaultMapping = "default". StrategyDefinition = "strategy" StrategyName "=" StrategyExpression ".". StrategyExpression : SGEdge| StrategyGraph | StrategyName *common* [ NegativeConstraint ]. StrategyGraph = "{" *l + SList(StrategyExpression) - *l "}". SGEdge = "->" ClassGlobSpec *s ClassGlobSpec. Constraint : NegativeConstraint *common* GlobSpec. NegativeConstraint : Bypassing. Bypassing = "bypassing". GlobSpec : OneGlob | GlobSet. OneGlob = Glob. GlobSet = "{" *s [ Commalist(Glob) *s ] "}". Glob : ClassGlob | EdgeGlob. EdgeGlob : PartGlob . ClassGlob = ClassNameGlob. PartGlob = "->" *s SourceGlob "," *s PartNameGlob "," *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 "}". Main = . // Terminal buffer classes. ClassName = Name. APPC_Name = Name. PartName = Name. StrategyName = Name. Name ~ Ident { // kludge!! *lookahead* (@ "." _Ident(), { "=:~(".indexOf(getToken(3).image) == -1 } @) "." Ident }. // Parameterized class definitions. List(S) ~ {*s S}. NList(S) ~ S {*s S}. SList(S) ~ S { *l S } . Commalist(S) ~ S {"," *s S}. // demjava.cd -- class dictionary for Demeter/Java // /proj/adaptive/www/sources/DemeterJava/examples/j-check-TBR3 Program = [ Package ] [ JavaCode ] ClassGraph. Package ~ "package" DirName { "." DirName } ";". ClassGraph = DList(ClassDef). ClassDef = ParamClassName ClassParts "." . ParamClassName = ClassName ["(" Commalist(ClassName) ")"]. ClassParts : ConstOrAltClass | RepetitionClass. ConstOrAltClass : ConstructionClass | AlternationClass *common* + + + List(PartOrSyntax) ClassParents - - -. PartOrSyntax : Part | OptionalPart | Syntax. Part = [ "<" PartName ">" ] ClassSpec. OptionalPart = "[" Sandwich(Part) "]". ClassParents = [ "*extends*" ClassSpec ] [ "*implements*" Commalist(ClassSpec) ] . ConstructionClass = "=". AlternationClass = ":" + + + Barlist(Subclass) - - - [ Common ]. Subclass = ClassSpec. Common = *l + + + "*" "common" "*" - - -. RepetitionClass = "~" Sandwich(RepeatedPart). RepeatedPart = [ ClassSpec ] "{" Sandwich(ClassSpec) "}". Sandwich(S) = List(Syntax) S List(Syntax) . ClassSpec = ClassName ["(" Commalist(ClassSpec) ")" ] . Syntax : PlainSyntax | PrintCommand. PlainSyntax = String. PrintCommand : PrintIndent | PrintUnindent | PrintSkip | PrintSpace. PrintIndent = "+" . PrintUnindent = "-" . PrintSkip = "*l" . PrintSpace = "*s" . // Terminal buffer classes. DirName = Ident. // ClassName = Ident. // PartName = Ident. JavaCode = Text. // JavaCode = "(@" String "@)". // Parameterized class definitions. // List(S) ~ {S}. // SList(S) ~ S { *l S } *l . DList(S) ~ S { *l *l S } *l . // Commalist(S) ~ S {"," S}. Barlist(S) ~ S { *l "|" S}. // Extra utility parameterized classes. Parameterized = Commalist(Part). SyntaxTable = List(PlainSyntax). // Visitors IsDemeterClassVisitor = // vector of cd defined class names ClassNames. CheckingVisitor = // vector of cd defined class names ClassNames ClassName // current class

Integer // number of parts per class Integer // number of terminal parts per class Boolean . ClassNames = *extends* Vector. // Vector(String) // from cd of Demeter/Java 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 ParmName List(ArraySpec). Throws = [ *s "throws" Commalist(ClassName) ]. MethodBody : VerbatimMethodBody | AdaptiveMethodBody | NoMethodBody. VerbatimMethodBody = JavaCode. AdaptiveMethodBody = TraversalExpression VisitorExpression. NoMethodBody = ";". // TraversalExpression : TraversalRef | TraversalSpec. TraversalExpression : 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 = JavaType // changed from Demeter/Java: added WrapperKind HostSpec JavaCode. WrapperKind : Before | Around | After | At. Before = "before". Around = "around". After = "after". At = "at". 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. TraversalName = Name. VisitorName = Name. MethodName = Ident. ParmName = Ident. JavaType = Name List(ArraySpec). ArraySpec = "[" "]".