Hi,
STInST.RBParser parseExpression: '#(-3)' is ending in memory failures. I am currently looking in what really happens but it is a bit tricky. _______________________________________________ help-smalltalk mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-smalltalk |
On Sat, Aug 10, 2013 at 05:31:56PM +0200, Gwenaƫl Casaccio wrote:
> I've made a fix and added few tests. Now I would like to see more > RBParser/Scanner tests :) Ah lovely! > + testNumberParsing [ > + > + | node | > + node := RBParser parseExpression: '3'. But RBParser parseExpression: '-3' parsed properly, it is the mix of array literal and this. I would like to add a testLiteralArrayParsing as well. But I can now parse the Grease tests and will look into updating Grease to the latest version. holger _______________________________________________ help-smalltalk mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-smalltalk |
On Sat, Aug 10, 2013 at 06:10:10PM +0200, Holger Hans Peter Freyther wrote:
> > But RBParser parseExpression: '-3' parsed properly, it is the mix of > array literal and this. I would like to add a testLiteralArrayParsing > as well. But I can now parse the Grease tests and will look into updating > Grease to the latest version. I have applied the below changes. Interestingly parsing '-16r3' is working after your change, it does not go into the isNegative branch. This means that someone else is consuming the '-' before it is reaching scanNumberValue. I will try to step through this with the MiniDebugger. diff --git a/packages/stinst/parser/RBParser.st b/packages/stinst/parser/RBParser.st index 25a4427..7e2804e 100644 --- a/packages/stinst/parser/RBParser.st +++ b/packages/stinst/parser/RBParser.st @@ -1042,7 +1042,7 @@ Stream subclass: RBScanner [ num := self scanDigits: currentCharacter base: 10. currentCharacter == $r ifTrue: - [isNegative ifTrue: [self error: 'malformed number']. + [ base := num truncated. self step "skip over 'r'". currentCharacter == $- diff --git a/packages/stinst/parser/RewriteTests.st b/packages/stinst/parser/RewriteTests.st index 5ba9ed2..489a4f8 100644 --- a/packages/stinst/parser/RewriteTests.st +++ b/packages/stinst/parser/RewriteTests.st @@ -362,9 +362,12 @@ TestCase subclass: TestParser [ self assert: node value = 3. node := RBParser parseExpression: '-3'. self assert: node value = -3. - self should: [ node := RBParser parseExpression: '-16r3' ] raise: Error. + node := RBParser parseExpression: '-16r3'. + self assert: node value = -3. node := RBParser parseExpression: '16r-3'. self assert: node value = -3. + node := RBParser parseExpression: '- 16r3'. + self assert: node value = -3. node := RBParser parseExpression: '16r-3.23'. self assert: node value = 16r-3.23. node := RBParser parseExpression: '16r-3s23_0'. @@ -378,6 +381,18 @@ TestCase subclass: TestParser [ node := RBParser parseExpression: '3_000_000q1233'. self assert: node value = 3_000_000q1233. ] + + testLiteralArrayParsing [ + | node | + + node := RBParser parseExpression: '#(-3 -2 -16r1)'. + self assert: node value first = -3. + self assert: node value second = -2. + self assert: node value third = -1. + + node := RBParser parseExpression: '#(16r-1)'. + self assert: node value first = -1. + ] ] TestCase subclass: TestRewrite [ diff --git a/packages/stinst/parser/package.xml b/packages/stinst/parser/package.xml index ba9ed69..a57efbb 100644 --- a/packages/stinst/parser/package.xml +++ b/packages/stinst/parser/package.xml @@ -29,6 +29,7 @@ <namespace>STInST.Tests</namespace> <sunit>STInST.Tests.TestStandardRewrites</sunit> <sunit>STInST.Tests.TestFormat</sunit> + <sunit>STInST.Tests.TestParser</sunit> <sunit>STInST.Tests.TestRewrite</sunit> <sunit>STInST.Tests.TestScanner</sunit> <sunit>STInST.Tests.TestDefaultPoolResolution</sunit> _______________________________________________ help-smalltalk mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-smalltalk |
On Mon, Aug 12, 2013 at 08:57:05AM +0200, Holger Hans Peter Freyther wrote:
> On Sat, Aug 10, 2013 at 06:10:10PM +0200, Holger Hans Peter Freyther wrote: > > > > But RBParser parseExpression: '-3' parsed properly, it is the mix of > > array literal and this. I would like to add a testLiteralArrayParsing > > as well. But I can now parse the Grease tests and will look into updating > > Grease to the latest version. > > > I have applied the below changes. Interestingly parsing '-16r3' is working > after your change, it does not go into the isNegative branch. This means > that someone else is consuming the '-' before it is reaching scanNumberValue. > I will try to step through this with the MiniDebugger. parseNegatedNumber will be called after the '-' has been consumed. I am running your change (and the changes I posted) through travis-ci and will then push it to master. kind regards holger _______________________________________________ help-smalltalk mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-smalltalk |
Free forum by Nabble | Edit this page |