Separator character in class names

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Separator character in class names

Trygve
Hi,
I'm relying on decomposing composite class names.
An example class name is  BB5aBank
I decompose it into #(BB5a Bank) but am using ugly and error-prone hacks to achieve it.
It would be very helpful if I could use some kind of separator in the class name, e.g., BB5a:Bank

I've tried brute force by renaming class BB5aBank to BB5a:Bank
This is permitted and Smalltalk points to the renamed class.
Compiling a method that is using the new class name fails:
    bank :=  Expression expected ->BB5a:Bank new
   
I've looked into the Parser code, but got lost.

Anybody have any ideas?

--Trygve


Reply | Threaded
Open this post in threaded view
|

Re: Separator character in class names

Eliot Miranda-2
Hi Trygve,

On Thu, Nov 20, 2014 at 9:32 AM, Trygve Reenskaug <[hidden email]> wrote:
Hi,
I'm relying on decomposing composite class names.
An example class name is  BB5aBank
I decompose it into #(BB5a Bank) but am using ugly and error-prone hacks to achieve it.
It would be very helpful if I could use some kind of separator in the class name, e.g., BB5a:Bank

I've tried brute force by renaming class BB5aBank to BB5a:Bank
This is permitted and Smalltalk points to the renamed class.
Compiling a method that is using the new class name fails:
    bank :=  Expression expected ->BB5a:Bank new
   
I've looked into the Parser code, but got lost.

You probably need to dive down into the Scanner.  For example if you used period and modified Scanner>>xLetter to not terminate the scan if it sees a period followed by a capital letter you'll likely be able to parse e.g. BB5a.Bank as a single token.  If you look at the xLetter method you'll see it already tests self allowUnderscoreSelectors to accept underscores.

Ah, so an alternative would be to make sure the allowUnderscoreSelecctors preference is set and use underscore as your separator.

HTH



Anybody have any ideas?

--Trygve






--
best,
Eliot


Reply | Threaded
Open this post in threaded view
|

Re: Separator character in class names

Trygve
Many thanks. Sound good. I'll try it ASAP

The Squeak-dev list impressive. It has never failed me and has given answers within a few hours. (May be it was you who replied previously too, Eliot?)


On 20.11.2014 20:11, Eliot Miranda wrote:
Hi Trygve,

On Thu, Nov 20, 2014 at 9:32 AM, Trygve Reenskaug <[hidden email]> wrote:
Hi,
I'm relying on decomposing composite class names.
An example class name is  BB5aBank
I decompose it into #(BB5a Bank) but am using ugly and error-prone hacks to achieve it.
It would be very helpful if I could use some kind of separator in the class name, e.g., BB5a:Bank

I've tried brute force by renaming class BB5aBank to BB5a:Bank
This is permitted and Smalltalk points to the renamed class.
Compiling a method that is using the new class name fails:
    bank :=  Expression expected ->BB5a:Bank new
   
I've looked into the Parser code, but got lost.

You probably need to dive down into the Scanner.  For example if you used period and modified Scanner>>xLetter to not terminate the scan if it sees a period followed by a capital letter you'll likely be able to parse e.g. BB5a.Bank as a single token.  If you look at the xLetter method you'll see it already tests self allowUnderscoreSelectors to accept underscores.

Ah, so an alternative would be to make sure the allowUnderscoreSelecctors preference is set and use underscore as your separator.

HTH



Anybody have any ideas?

--Trygve






--
best,
Eliot



Reply | Threaded
Open this post in threaded view
|

Re: Separator character in class names

Trygve
In reply to this post by Eliot Miranda-2
It worked! Thank you.

On 20.11.2014 20:11, Eliot Miranda wrote:
Hi Trygve,

On Thu, Nov 20, 2014 at 9:32 AM, Trygve Reenskaug <[hidden email]> wrote:
Hi,
I'm relying on decomposing composite class names.
An example class name is  BB5aBank
I decompose it into #(BB5a Bank) but am using ugly and error-prone hacks to achieve it.
It would be very helpful if I could use some kind of separator in the class name, e.g., BB5a:Bank

I've tried brute force by renaming class BB5aBank to BB5a:Bank
This is permitted and Smalltalk points to the renamed class.
Compiling a method that is using the new class name fails:
    bank :=  Expression expected ->BB5a:Bank new
   
I've looked into the Parser code, but got lost.

You probably need to dive down into the Scanner.  For example if you used period and modified Scanner>>xLetter to not terminate the scan if it sees a period followed by a capital letter you'll likely be able to parse e.g. BB5a.Bank as a single token.  If you look at the xLetter method you'll see it already tests self allowUnderscoreSelectors to accept underscores.

Ah, so an alternative would be to make sure the allowUnderscoreSelecctors preference is set and use underscore as your separator.

HTH



Anybody have any ideas?

--Trygve






--
best,
Eliot



    

--

Trygve Reenskaug      mailto: [hidden email]
Morgedalsvn. 5A       http://folk.uio.no/trygver/
N-0378 Oslo             http://fullOO.info
Norway                     Tel: (+47) 22 49 57 27