The Trunk: ShoutCore-mt.81.mcz

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

The Trunk: ShoutCore-mt.81.mcz

commits-2
Marcel Taeumel uploaded a new version of ShoutCore to project The Trunk:
http://source.squeak.org/trunk/ShoutCore-mt.81.mcz

==================== Summary ====================

Name: ShoutCore-mt.81
Author: mt
Time: 15 June 2020, 4:41:07.031209 pm
UUID: b5dfda57-678c-bd4b-91ba-3eae94326352
Ancestors: ShoutCore-mt.80

Avoid breaking new hook for <pragmaParser> when subclassing SHParserST80. That is, re-use all existing pragma parsers automatically in subclasses. Note that #methodDict was chosen over #lookupSelector: for performance reasons.

=============== Diff against ShoutCore-mt.80 ===============

Item was changed:
  ----- Method: SHParserST80>>parsePragmaStatement (in category 'parse pragma') -----
  parsePragmaStatement
 
  | parserSelector |
  (currentToken last == $:
  and: [(parserSelector := Symbol lookup: currentToken allButLast) notNil])
  ifFalse: ["Quick exit to not break one-word pragmas such as <primitive> and <foobar>; also avoid interning new symbols for made-up pragmas such as for <my: 1 new: 2 pragma: 3> not interning #my."
  ^ self parsePragmaStatementKeywords].
 
+ SHParserST80 methodDict
- self class methodDict
  at: parserSelector
  ifPresent: [:parserMethod |
  (parserMethod pragmas
  anySatisfy: [:pragma | pragma keyword == #pragmaParser])
  ifTrue: [^ self executeMethod: parserMethod]].
 
  ^ self parsePragmaStatementKeywords!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: ShoutCore-mt.81.mcz

Levente Uzonyi
Hi Marcel,

On Mon, 15 Jun 2020, [hidden email] wrote:

> Marcel Taeumel uploaded a new version of ShoutCore to project The Trunk:
> http://source.squeak.org/trunk/ShoutCore-mt.81.mcz
>
> ==================== Summary ====================
>
> Name: ShoutCore-mt.81
> Author: mt
> Time: 15 June 2020, 4:41:07.031209 pm
> UUID: b5dfda57-678c-bd4b-91ba-3eae94326352
> Ancestors: ShoutCore-mt.80
>
> Avoid breaking new hook for <pragmaParser> when subclassing SHParserST80. That is, re-use all existing pragma parsers automatically in subclasses. Note that #methodDict was chosen over #lookupSelector: for performance reasons.

I think it would be worth adding a few test cases custom pragma parsers.

>
> =============== Diff against ShoutCore-mt.80 ===============
>
> Item was changed:
>  ----- Method: SHParserST80>>parsePragmaStatement (in category 'parse pragma') -----
>  parsePragmaStatement
>
>   | parserSelector |
>   (currentToken last == $:
>   and: [(parserSelector := Symbol lookup: currentToken allButLast) notNil])
>   ifFalse: ["Quick exit to not break one-word pragmas such as <primitive> and <foobar>; also avoid interning new symbols for made-up pragmas such as for <my: 1 new: 2 pragma: 3> not interning #my."
>   ^ self parsePragmaStatementKeywords].

I think it would be easier to read the above lines in the following form:

  currentToken last == $: ifTrue: [
  (Symbol lookup: currentToken allButLast) ifNotNil: [ :parserSelector |
  "Quick exit to not break one-word pragmas such as <primitive> and <foobar>; also avoid interning new symbols for made-up pragmas such as for <my: 1 new: 2 pragma: 3> not interning #my."
  ^self parsePragmaStatementKeywords ] ].

>
> + SHParserST80 methodDict
> - self class methodDict
>   at: parserSelector
>   ifPresent: [:parserMethod |
>   (parserMethod pragmas
>   anySatisfy: [:pragma | pragma keyword == #pragmaParser])
>   ifTrue: [^ self executeMethod: parserMethod]].

How about using #hasPragma: here?

  (parserMethod hasPragma: #pragmaParser) ifTrue: [
  ^self executeMethod: parserMethod ]


Levente

>
>   ^ self parsePragmaStatementKeywords!

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: ShoutCore-mt.81.mcz

marcel.taeumel
Hi Levente.

How about using #hasPragma: here?

Now we have a first use of it in Trunk. :-D



Best,
Marcel

Am 15.06.2020 18:22:27 schrieb Levente Uzonyi <[hidden email]>:

Hi Marcel,

On Mon, 15 Jun 2020, [hidden email] wrote:

> Marcel Taeumel uploaded a new version of ShoutCore to project The Trunk:
> http://source.squeak.org/trunk/ShoutCore-mt.81.mcz
>
> ==================== Summary ====================
>
> Name: ShoutCore-mt.81
> Author: mt
> Time: 15 June 2020, 4:41:07.031209 pm
> UUID: b5dfda57-678c-bd4b-91ba-3eae94326352
> Ancestors: ShoutCore-mt.80
>
> Avoid breaking new hook for when subclassing SHParserST80. That is, re-use all existing pragma parsers automatically in subclasses. Note that #methodDict was chosen over #lookupSelector: for performance reasons.

I think it would be worth adding a few test cases custom pragma parsers.

>
> =============== Diff against ShoutCore-mt.80 ===============
>
> Item was changed:
> ----- Method: SHParserST80>>parsePragmaStatement (in category 'parse pragma') -----
> parsePragmaStatement
>
> | parserSelector |
> (currentToken last == $:
> and: [(parserSelector := Symbol lookup: currentToken allButLast) notNil])
> ifFalse: ["Quick exit to not break one-word pragmas such as and ; also avoid interning new symbols for made-up pragmas such as for not interning #my."
> ^ self parsePragmaStatementKeywords].

I think it would be easier to read the above lines in the following form:

currentToken last == $: ifTrue: [
(Symbol lookup: currentToken allButLast) ifNotNil: [ :parserSelector |
"Quick exit to not break one-word pragmas such as and ; also avoid interning new symbols for made-up pragmas such as for not interning #my."
^self parsePragmaStatementKeywords ] ].

>
> + SHParserST80 methodDict
> - self class methodDict
> at: parserSelector
> ifPresent: [:parserMethod |
> (parserMethod pragmas
> anySatisfy: [:pragma | pragma keyword == #pragmaParser])
> ifTrue: [^ self executeMethod: parserMethod]].

How about using #hasPragma: here?

(parserMethod hasPragma: #pragmaParser) ifTrue: [
^self executeMethod: parserMethod ]


Levente

>
> ^ self parsePragmaStatementKeywords!