[squeak-dev] Parser Pragma Issue and Fix
Levente Uzonyi
leves at caesar.elte.hu
Tue Aug 18 19:49:38 UTC 2020
Hi Patrick,
On Mon, 17 Aug 2020, Rein, Patrick wrote:
> Hi everyone,
>
> while working on a parser framework I recently discovered an issue when parsing the following method:
>
> someTestMethod
> '<' first
>
> This method can not be parsed by the current Squeak parser, as it expects a closing angle bracket after the message send. The parser misinterprets the bracket in the string as the beginning of a pragma. The fault is in the Parser class which did not respect the type of the token to be parsed. The attached changeset is a proposed fix for the fault. It boils down to checking for the #binary token type in the the responsible parser method:
>
> Parser>>#pragmaSequence
> "Parse a sequence of method pragmas."
>
> [ (hereType == #binary and: [self matchToken: #<])
> ifFalse: [ ^ self ].
> self pragmaStatement.
> (self matchToken: #>)
> ifFalse: [ ^ self expected: '>' ] ] repeat
>
> As this is somewhat of a fundamental change, I wanted to bring this up for discussion before merging it.
The issue exists the other way around with the closing bracket as well.
After applying your fix compile:
someTestMethod
<itsAPragma'>'
^1
The same fix seems to work there too:
...
(hereType == #binary and: [self matchToken: #>])
ifFalse: [ ^ self expected: '>' ] ] repeat
Levente
>
> Thanks and best wishes,
> Patrick
More information about the Squeak-dev
mailing list
|