[Pharo-project] Issue 3525 in pharo: Compiler>>parserClass is broken and does not querying the class for providing the parser class

Eliot Miranda eliot.miranda at gmail.com
Mon Jan 10 15:32:53 EST 2011


On Mon, Jan 10, 2011 at 11:42 AM, Nicolas Cellier <
nicolas.cellier.aka.nice at gmail.com> wrote:

> Will it work ?
>
> because Compiler class>>new
>        ^ super new parser: self parserClass new
>
> sets the parser ivar with Compiler parserClass new.
> Maybe you'll need to remove this definition of new too.
>

I think it works.  Behavior>>parser class gets compilerClass parserClass:

Behavior>>parserClass
"Answer a parser class to use for parsing method headers."

^self compilerClass parserClass

So one is supposed to implement a Compiler subclass that defines a
class-side parserClass method.  e.g.

MySpecialClass>>compilerClass
    ^MySpecialCompiler

MySpecialCompiler class>>parserClass
    ^MySpecialParser

So then

Compiler>>parserClass

^parser ifNil: [(class ifNil: [self class]) parserClass] ifNotNil: [parser
class]

will also find MySpecialParser.

Yes, its heavyweight because the Compiler subclass isn't providing anything
other than the reference to the parser. But that's the way the system is
written so far.

what do you think?

best
Eliot


> Nicolas
>
> 2011/1/10 Eliot Miranda <eliot.miranda at gmail.com>:
> >
> >
> > On Mon, Jan 10, 2011 at 9:46 AM, <pharo at googlecode.com> wrote:
> >>
> >> Status: Accepted
> >> Owner: siguctua
> >>
> >> New issue 3525 by siguctua: Compiler>>parserClass is broken and does not
> >> querying the class for providing the parser class
> >> http://code.google.com/p/pharo/issues/detail?id=3525
> >>
> >> In the following:
> >>
> >> Compiler>>parserClass
> >>
> >>        ^parser ifNil: [self class parserClass] ifNotNil: [parser class]
> >
> > Who writes this stuff ?? ;)
> > <blush>
> > I suggest the attached:
> > parserClass
> > ^parser ifNil: [(class ifNil: [self class]) parserClass] ifNotNil:
> [parser
> > class]
> >
> >>
> >> 'self class' should actually be 'class parserClass'
> >>
> >> So, any class could override the default parser by own. In that way a
> >> default parser class is answered by Behavior, not by Compiler.
> >> A Compiler class>>parserClass is useless.
> >>
> >>
> >> But even more than that, due to initializing 'parser' ivar in
> >> Compiler>>new,
> >> it never gets to that code, and evaluating 'parser class'
> >> So, a class can't specify a custom parser class to compiler.
> >>
> >>
> >>
> >>
> >
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/attachments/20110110/6735eb83/attachment-0001.html>


More information about the Pharo-dev mailing list