Has anybody done some work on parsing the class comments?
This uses a semi-formal notation, like: Subclasses should implement: accessing getPath Instance Variables: name <String> the name of the thing employers <Set of: Person> a collection maritalStatus <'married' | 'single'> etc. For a tool I am writing to generate XMI exports from Smalltalk (currently for import into case tools, specifically Sparxsystems Enterprise Architect) I am using a brute force approach to parse this information, but possibly someone has done some work on this I am not aware of. I am not using the ParserCompiler toolkit or SmaCC for now. The export to UML case tools is especially handy for eXploratory Modeling sessions, where Smalltalk is used to model the customers problem domain. _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Hi Rob,
I've some old code that exports our Smalltalk models into xmi to open it in Sparx' Enterprise Architect (EA). However, - it only exports classes which are subclass from a base class which is part or our framework. - our framework is heavily based on pragmas (in pragmas we describe types, relations etc), these pragmas are prerequisite for exporting to Sparx. - I made this exporter to get our code better documented with uml like diagrams. we don't have an importer. - An importer is important if you want to keep the visual layout which you altered withing EA - This exporter for EA was made in the beginning of 2006, and not used since, only made a few diagrams with it. You could drop by in our office (late in the afternoon) so I can show you what/how we did it, and this maybe helps you to make a better exporter (independent from our framework). This is probably the easiest way to reuse parts it. Let me know, Mathieu van Echtelt . On Sun, Mar 2, 2008 at 11:00 AM, Rob Vens <[hidden email]> wrote: > Has anybody done some work on parsing the class comments? > This uses a semi-formal notation, like: > > Subclasses should implement: > accessing > getPath > > Instance Variables: > name <String> the name of the thing > employers <Set of: Person> a collection > maritalStatus <'married' | 'single'> > > etc. > For a tool I am writing to generate XMI exports from Smalltalk (currently > for import into case tools, specifically Sparxsystems Enterprise Architect) > I am using a brute force approach to parse this information, but possibly > someone has done some work on this I am not aware of. I am not using the > ParserCompiler toolkit or SmaCC for now. > The export to UML case tools is especially handy for eXploratory Modeling > sessions, where Smalltalk is used to model the customers problem domain. > > _______________________________________________ > vwnc mailing list > [hidden email] > http://lists.cs.uiuc.edu/mailman/listinfo/vwnc > > vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by Rob Vens-2
Rob Vens schrieb am 02.03.2008 11:00:
> Has anybody done some work on parsing the class comments? If I am not mistaken, the Advance modeling tool parses the class comments to determine the types of instance variables. HTH, Joachim Geidel _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by Rob Vens-2
Rob Vens schrieb am 02.03.2008 11:00:
> For a tool I am writing to generate XMI exports from Smalltalk (currently > for import into case tools, specifically Sparxsystems Enterprise Architect) By the way, thank you very much for publishing it in the public repository! It may help us in our current project. Joachim Geidel _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by Rob Vens-2
The RBCodeModelWithVariables tool parses comments.
R - On Mar 2, 2008, at 11:00 AM, Rob Vens wrote: > Has anybody done some work on parsing the class comments? > This uses a semi-formal notation, like: > > Subclasses should implement: > accessing > getPath > > Instance Variables: > name <String> the name of the thing > employers <Set of: Person> a collection > maritalStatus <'married' | 'single'> > > etc. > For a tool I am writing to generate XMI exports from Smalltalk > (currently for import into case tools, specifically Sparxsystems > Enterprise Architect) I am using a brute force approach to parse > this information, but possibly someone has done some work on this I > am not aware of. I am not using the ParserCompiler toolkit or SmaCC > for now. > The export to UML case tools is especially handy for eXploratory > Modeling sessions, where Smalltalk is used to model the customers > problem domain. > _______________________________________________ > vwnc mailing list > [hidden email] > http://lists.cs.uiuc.edu/mailman/listinfo/vwnc _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by Joachim Geidel
you were quick to find out that I indeed published a first draft version of the tool to the public repository.
It is called XMI-Mapper. I will make a fuller announcement on the list when I have done a few things, like method parameter names and types, that makes it almost complete in the sense that all Smalltalk information is captured into XMI. 2008/3/2, Joachim Geidel <[hidden email]>: Rob Vens schrieb am 02.03.2008 11:00: _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by Rob Vens-2
The standard smalltalk parser is also capable of parsing the type expressions, see Parser>>typeExpression, although I don't know off the top of my head how to apply it.
HTH, Martin Rob Vens wrote: > Has anybody done some work on parsing the class comments? > This uses a semi-formal notation, like: > > Subclasses should implement: > accessing > getPath > > Instance Variables: > name <String> the name of the thing > employers <Set of: Person> a collection > maritalStatus <'married' | 'single'> > > etc. > For a tool I am writing to generate XMI exports from Smalltalk > (currently for import into case tools, specifically Sparxsystems > Enterprise Architect) I am using a brute force approach to parse this > information, but possibly someone has done some work on this I am not > aware of. I am not using the ParserCompiler toolkit or SmaCC for now. > The export to UML case tools is especially handy for eXploratory > Modeling sessions, where Smalltalk is used to model the customers > problem domain. > > > ------------------------------------------------------------------------ > > _______________________________________________ > vwnc mailing list > [hidden email] > http://lists.cs.uiuc.edu/mailman/listinfo/vwnc _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
At 09:17 AM 3/3/2008, Martin Kobetic wrote:
>The standard smalltalk parser is also capable of parsing the type >expressions, see Parser>>typeExpression, although I don't know off >the top of my head how to apply it. It seems that you need to parse the class comment into pieces, and then feed each type expression to the parser. This bit of code will parse the type expression and give you a subclass of ProgramNode: Parser new parseType: 'Array of: (String | Symbol)' readStream builder: ProgramNodeBuilder new. M _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by Rob Vens-2
Hello Rob,
as Joachim Geidel mentioned in an answer to your email, ADvance resp. its IncerementalType package is doing such parsing. You may want to try the following: (1) Load the ADvance parcels or the ADvance store bundle into your image. (2) Using the ADvance workbench File menu, change the General Preferences, section Advanced, to use Class Comments. (3) Inspect "(IT1FullType baseClass: MyClass) clientRelationDeclarations" For each variable declaration, you will find an IT1ClientRelation holding the parsed information. I hope that helps, please let me know if we can be of any further assistance. Regards, Marc ________________________________________ Von: [hidden email] [mailto:[hidden email]] Im Auftrag von Rob Vens Gesendet: Sonntag, 2. März 2008 11:00 An: VWNC Betreff: [vwnc] parser for variable types in class comments Has anybody done some work on parsing the class comments? This uses a semi-formal notation, like: Subclasses should implement: accessing getPath Instance Variables: name <String> the name of the thing employers <Set of: Person> a collection maritalStatus <'married' | 'single'> etc. For a tool I am writing to generate XMI exports from Smalltalk (currently for import into case tools, specifically Sparxsystems Enterprise Architect) I am using a brute force approach to parse this information, but possibly someone has done some work on this I am not aware of. I am not using the ParserCompiler toolkit or SmaCC for now. The export to UML case tools is especially handy for eXploratory Modeling sessions, where Smalltalk is used to model the customers problem domain. _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by Rob Vens-2
I am afraid I do not completely understand your point Paul. So let me explain a bit further to make sure you understood my problem. Please let me know if you did understood me correctly, and help me understand your point.
I am not trying to parse comments from XML, but from Smalltalk ... to use it in order to generate the correct XMI definitions. I am generating XMI (not XML) from Smalltalk, and the type information is not easily available in Smalltalk (except from parsing it from argument names like "aString" but that is far from robust - or inferring it from existing objects or messages sent to objects in code). So I am requiring the modellers to write the correct and complete class comments, which by the way I check for completeness and correctness before parsing it. So for example this Smalltalk class: Sogyo.Resilience defineClass: #Individual superclass: #{Core.Object} indexedType: #none private: false instanceVariableNames: 'name title gender addresses birth ' classInstanceVariableNames: '' imports: '' category: '' Which this class comment: Natural persons. Instance Variables: birth <Sogyo.Resilience.Birth> addresses <Set of: Sogyo.Resilience.PlatformAddress> the addresses of the person on the various defined platforms gender <'male' | 'female'> title <String> describing any titles name <Sogyo.Resilience.PersonName> This is exported to XMI as: <UML:Class isRoot="false" name="Individual" visibility="public" xmi.id="Individual"> <UML:ModelElement.taggedValue> <UML:TaggedValue tag="documentation" value="Natural persons. Instance Variables: birth <Sogyo.Resilience.Birth> addresses <Set of: Sogyo.Resilience.PlatformAddress> the addresses of the person on the various defined platforms gender <'male' | 'female'> title <String> describing any titles name <Sogyo.Resilience.PersonName> " /> </UML:ModelElement.taggedValue> <UML:Classifier.feature> <UML:Operation name="initialize" ownerScope="instance" visibility="public"> <UML:ModelElement.taggedValue> <UML:TaggedValue tag="documentation" value="initialize name := nil. addresses := Set new" /> </UML:ModelElement.taggedValue> </UML:Operation> <UML:Operation name="name" ownerScope="instance" visibility="public"> <UML:ModelElement.taggedValue> <UML:TaggedValue tag="documentation" value="name ^name" /> </UML:ModelElement.taggedValue> </UML:Operation> <UML:Operation name="name:" ownerScope="instance" visibility="public"> <UML:ModelElement.taggedValue> <UML:TaggedValue tag="documentation" value="name: anObject name := anObject" /> </UML:ModelElement.taggedValue> </UML:Operation> <UML:Attribute name="title" ownerScope="instance" targetScope="instance" visibility="private"> <UML:Attribute.initialValue> <UML:Expression /> </UML:Attribute.initialValue> <UML:StructuralFeature.type> <UML:Classifier xmi.idref="SmalltalkDatatype00000002" /> </UML:StructuralFeature.type> <UML:ModelElement.taggedValue> <UML:TaggedValue tag="description" value="for description of title see class comment" /> </UML:ModelElement.taggedValue> </UML:Attribute> <UML:Attribute name="gender" ownerScope="instance" targetScope="instance" visibility="private"> <UML:Attribute.initialValue> <UML:Expression /> </UML:Attribute.initialValue> <UML:StructuralFeature.type> <UML:Classifier xmi.idref="SmalltalkDatatype00000003" /> </UML:StructuralFeature.type> <UML:ModelElement.taggedValue> <UML:TaggedValue tag="description" value="for description of gender see class comment" /> </UML:ModelElement.taggedValue> </UML:Attribute> </UML:Classifier.feature> </UML:Class> I am still working on the method argument XMI as you perhaps can see. Also I intend to implement a setting that will generate XMI using UML syntax for keyword messages, so that a method like name:address (with arguments aPersonName and anAddress) will be exported if desired as nameAddress(PersonName aPersonName, Address anAddress). 2008/3/3, Paul Baumann <[hidden email]>:
_______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
The code I showed would parse Smalltalk syntax comments
from Smalltalk code. You are trying to parse class comments that were
generated by a tool that I'm not familiar with. Those comments are not Smalltalk
code; therefore, the code I sent is not useful to you except perhaps as
something you can build on to recognize the comment syntax. You may find
that the class comments were first generated by a tool using information
that was discovered in the image; if so, you may be able to skip the class
comment parsing and go directly to the source of those comments. If you can
bypass the parsing of the comments then you'd eliminate the need to flog
modelers for not keeping class comments "complete and correct"--which you say
you have a way to check.
Sorry, I'm not familiar with XMI or what it is used
for. To me it looks XML encoding with a specific set of
tags.
Consider whether class comments are the best way to
store class meta data. One way to store class meta data is with a VW syntax
class definition that specifies attributes (look to
#extraAttributesForDefinition for example). Another way, usually better, is to
answer the meta-data by way of a class side method that can be queried
and that is maintained like all other code. Here is an example of a method
that returns class meta data used to describe observed attribute
types:
icxMyAttributeTypes
"Answer a collection of attribute names and bindings to observed types." ^#( (buttonHomes ( #{Dictionary} ) ) (currentView ( #{HistoryView} ) ) (viewDictionary ( #{Dictionary} ) ) (selectColor ( #{ColorValue} ) ) (unselectColor ( #{ColorValue} ) ) (selectedButton ( #{ByteSymbol} ) ) ) BTW, attribute type inference is not necessary
when you have the ability to turn on a feature that "observes and revises"
attribute types.
Paul Baumann
From: Rob Vens [mailto:[hidden email]] Sent: Monday, March 03, 2008 3:03 PM To: Paul Baumann; VWNC Subject: Re: [vwnc] parser for variable types in class comments Importance: High I am not trying to parse comments from XML, but from Smalltalk ... to use it in order to generate the correct XMI definitions. I am generating XMI (not XML) from Smalltalk, and the type information is not easily available in Smalltalk (except from parsing it from argument names like "aString" but that is far from robust - or inferring it from existing objects or messages sent to objects in code). So I am requiring the modellers to write the correct and complete class comments, which by the way I check for completeness and correctness before parsing it. So for example this Smalltalk class: Sogyo.Resilience defineClass: #Individual superclass: #{Core.Object} indexedType: #none private: false instanceVariableNames: 'name title gender addresses birth ' classInstanceVariableNames: '' imports: '' category: '' Which this class comment: Natural persons. Instance Variables: birth <Sogyo.Resilience.Birth> addresses <Set of: Sogyo.Resilience.PlatformAddress> the addresses of the person on the various defined platforms gender <'male' | 'female'> title <String> describing any titles name <Sogyo.Resilience.PersonName> This is exported to XMI as: <UML:Class isRoot="false" name="Individual" visibility="public" xmi.id="Individual"> <UML:ModelElement.taggedValue> <UML:TaggedValue tag="documentation" value="Natural persons. Instance Variables: birth <Sogyo.Resilience.Birth> addresses <Set of: Sogyo.Resilience.PlatformAddress> the addresses of the person on the various defined platforms gender <'male' | 'female'> title <String> describing any titles name <Sogyo.Resilience.PersonName> " /> </UML:ModelElement.taggedValue> <UML:Classifier.feature> <UML:Operation name="initialize" ownerScope="instance" visibility="public"> <UML:ModelElement.taggedValue> <UML:TaggedValue tag="documentation" value="initialize name := nil. addresses := Set new" /> </UML:ModelElement.taggedValue> </UML:Operation> <UML:Operation name="name" ownerScope="instance" visibility="public"> <UML:ModelElement.taggedValue> <UML:TaggedValue tag="documentation" value="name ^name" /> </UML:ModelElement.taggedValue> </UML:Operation> <UML:Operation name="name:" ownerScope="instance" visibility="public"> <UML:ModelElement.taggedValue> <UML:TaggedValue tag="documentation" value="name: anObject name := anObject" /> </UML:ModelElement.taggedValue> </UML:Operation> <UML:Attribute name="title" ownerScope="instance" targetScope="instance" visibility="private"> <UML:Attribute.initialValue> <UML:Expression /> </UML:Attribute.initialValue> <UML:StructuralFeature.type> <UML:Classifier xmi.idref="SmalltalkDatatype00000002" /> </UML:StructuralFeature.type> <UML:ModelElement.taggedValue> <UML:TaggedValue tag="description" value="for description of title see class comment" /> </UML:ModelElement.taggedValue> </UML:Attribute> <UML:Attribute name="gender" ownerScope="instance" targetScope="instance" visibility="private"> <UML:Attribute.initialValue> <UML:Expression /> </UML:Attribute.initialValue> <UML:StructuralFeature.type> <UML:Classifier xmi.idref="SmalltalkDatatype00000003" /> </UML:StructuralFeature.type> <UML:ModelElement.taggedValue> <UML:TaggedValue tag="description" value="for description of gender see class comment" /> </UML:ModelElement.taggedValue> </UML:Attribute> </UML:Classifier.feature> </UML:Class> I am still working on the method argument XMI as you perhaps can see. Also I intend to implement a setting that will generate XMI using UML syntax for keyword messages, so that a method like name:address (with arguments aPersonName and anAddress) will be exported if desired as nameAddress(PersonName aPersonName, Address anAddress). 2008/3/3, Paul Baumann <[hidden email]>:
This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange, Inc. (ICE), its subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired. _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Thank you Paul for elaborating, I think I now understand your proposed approach better.
I think it may be useful to realise that XMI is not just XML with a specific set of tags, but an official and open interchange format to exchange models, based on UML. From Smalltalk it is relatively easy to generate XMI (apart from the type information), which then enables the Smalltalk model to be imported in many case tools or modelling tools. And that is my short term goal: to import the Smalltalk model into a UML tool, specifically Enterprise Architect from Sparx Systems. It does that in its current version rather nicely already. Currently the ADvance toolkit has a switch to generate the type information into either a class comment, or a class side method. The last seems to be your approach, am I correct? The UI to do this checks for the correctness of the type info, because it is not possible to just enter a string with a class name, but the class names are actually checked. This is an elegant approach because the class comment, or at least that part describing the meta information of the class, is then generated, not hand-written and error-prone. The class side method would be Smalltalk code ( a bit like a window spec) and maybe more robust. Another tool currently used is the ClassDescription class in the Advanced Tools toolkit (in the AT System Analysis package). I currently use this class to check the correctness of the class comment, but it is useless to get the type information I need from, unless I modify this class. And also this class uses a more or less brute force approach to get the necessary information from basically free-format comment. Finally the RB does some work in checking class comments, and it could do that a lot better, or even provide a UI to do that comparable to what the ADvance tool does. Also I should mention that there is a switch in the Smalltalk parser (Parser>>initScanner) that enables "extendedLanguage" that seems to allow for type information in the form of <String> to be entered into the Smalltalk code. But I cannot seem to get it working and it is not documented or used anywhere I know. I am still investigating this problem but at the moment it seems to me my preferred solution would go into the direction of providing a UI to enter code component (class, package, bundle) meta information, which is then stored in XML, not a Smalltalk array like window specs, not in comment which is basically free-form however formal you want it to be. And a feature I certainly would welcome is run-time monitoring of and correcting type info (your "observe and revise" proposal). Furthermore I am aware of a lot of work that hase been done on typing in Smalltalk. Please do not understand me wrong, I am not advocating that Smalltalk should be more typed, but that it would enhance our environment if we could do more with it than we currently do. I would love to receive some input from people have worked on this issue. 2008/3/4, Paul Baumann <[hidden email]>:
_______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
I've been playing with creating user interfaces without the UI painter. The following code works in a workspace, but the input fields don't have a background color and they're invisible if they don't have any text in them. How can I set the background color to the standard one (white in this case)? Also, what's the right way to return the correct platform widget for check boxes? I hardcoded in the one for Windows XP, but that's wrong.
cp := CompositePart new. firstModel := '3' asValue. secondModel := '4' asValue. answerModel := '' asValue. first := InputFieldView model: firstModel. second := InputFieldView model: secondModel. answer := InputFieldView model: answerModel. (button := ActionButtonView new) labelString: '&Add'; action: [ answerModel value: (firstModel value asNumber + secondModel value asNumber) printString ]. (checkBox := WinXPCheckButtonView new) labelString: 'test'; model: true asValue. cp add: first in: (10@10 extent: 50@25). cp add: second in: (70@10 extent: 50@25). cp add: button in: (130@10 extent: 30@25). cp add: answer in: (170@10 extent: 50@25). cp add: checkBox in: (10@45 extent: 100@25). window := ScheduledWindow new. window component: cp. window label: 'my window'. window openWithExtent: 300@200. Thanks, -Carl Gundel http://www.libertybasic.com http://www.runbasic.com _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
You'll have more success using the spec objects in combination with a builder:
window := ScheduledWindow new. inputSpec := InputFieldSpec model: '' asValue
layout: ((LayoutFrame new) rightFraction: 1; bottomOffset: 24). builder := UIBuilder new. inputWrapper := builder add: inputSpec.
Michael On 15 March 2011 14:56, Carl Gundel <[hidden email]> wrote: I've been playing with creating user interfaces without the UI painter. The following code works in a workspace, but the input fields don't have a background color and they're invisible if they don't have any text in them. How can I set the background color to the standard one (white in this case)? Also, what's the right way to return the correct platform widget for check boxes? I hardcoded in the one for Windows XP, but that's wrong. _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
On Tue, 2011-03-15 at 15:08 -0700, Michael Lucas-Smith wrote:
> You'll have more success using the spec objects in combination with a > builder: > window := ScheduledWindow new. > inputSpec := InputFieldSpec model: '' asValue > layout: ((LayoutFrame new) rightFraction: 1; bottomOffset: 24). > builder := UIBuilder new. > inputWrapper := builder add: inputSpec. > > Michael > How do the results of the builder get hooked up with window? I've built an interface programmatically using a subclass of InputFieldView; it kind of works, but all the fields show the cursor (as if they had focus) all the time. So I'm looking to understand more. Ross Boylan _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
window component: inputWrapper.
For a more advanced set up you'd put a CompositeView in to the window and add the inputWrapper to that. Michael
On 20 March 2011 23:34, Ross Boylan <[hidden email]> wrote:
_______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Free forum by Nabble | Edit this page |