From: "Mike Miller" To: alexey@ccs.neu.edu cc: lieber@ccs.neu.edu Subject: HW3 part 5 question In hw3, part 5 what does the "*l" represent in the class dictionary. For example: ClassMethods = "{" *l + [ SList(Method) ] - "}" Also, what does the "+" and "-" represent. I understand that the ClassMethods type has an optional parameterized list of Methods, and the field name is methods. But the + and - are not inside quotes so they are not syntactic sugar, so what are they for??? ================================== // For the Demeter/Java User's Guide: PrintingVisitor section. // Also refer to this in cd section. Often you would like to control the printing of your objects. For example, you would like to use newline and space characters to make your object sentences look nicer. For example, if you write a compiler, you would like to represent your assembly code as objects which you print at the end of the compilation. You want each assembly code instruction start on a new line. The PrintVisitor is capable of handling this situation based on information in the class dictionary. Wherever you can put a lexical token in your class dictionary, you can put a pretty printing command. There are four printing commands that can be used: *l Add new line. *s Add space. + Indent. Starts a new indentation level. Indentation is by three spaces by default. - Unindent. Ends the current indentation level. Examples: ClassParents = [*s "*extends*" *s Superclasses] [*s "*implements*" *s Interfaces]. // we want a space before and after *extends* and *implements*. TGVertex = ClassName *l "incoming:" *l + List(TGEdge) - *l ... // we want a newline after the class name and "incoming" // and print the edges indented. After the incoming // edges are printed, we want another newline. From dougo@ccs.neu.edu Tue Oct 28 19:06:04 1997 Received: from mizar.ccs.neu.edu (mizar.ccs.neu.edu [129.10.113.98]) by amber.ccs.neu.edu (8.8.6/8.7.3) with ESMTP id TAA27201; Tue, 28 Oct 1997 19:05:56 -0500 (EST) Received: (dougo@localhost) by mizar.ccs.neu.edu (8.8.6/8.6.4) id TAA04579; Tue, 28 Oct 1997 19:05:55 -0500 (EST) Date: Tue, 28 Oct 1997 19:05:55 -0500 (EST) Message-Id: <199710290005.TAA04579@mizar.ccs.neu.edu> From: Doug Orleans To: Karl Lieberherr Cc: com3360@ccs.neu.edu Subject: Re: pretty printing commands In-Reply-To: <199710281606.LAA22487@stockberg.ccs.neu.edu> References: <199710281606.LAA22487@stockberg.ccs.neu.edu> X-Mailer: VM 6.22 under 19.15p7 XEmacs Lucid X-Face: (4D-osoq?}7M3\EgvbWKo *s Add space. The PrintVisitor tries to be smart about spaces; it automatically prints them between adjacent tokens that end/start with alphanumeric characters. For example, Foo = "foo" int Ident. will be printed as "foo 3 bar", not "foo3bar". However, in this example: > ClassParents = [*s "*extends*" *s Superclasses] > [*s "*implements*" *s Interfaces]. the *s directives explicitly print spaces before and after the keywords because they don't start or end with alphanumerics. The idea is (without any *s directives) to print the minimum number of spaces necessary so that the object can be parsed back from the printed string preserving the object structure. (This is why the PrintVisitor may be renamed to UnparseVisitor at some point in the future...) --Doug