Review Board

1.0

Avoid stack overflow in the Smalltalk parser.

Updated 1 year, 9 months ago

Truls Becken Reviewers
EtoileCore
None Etoile trunk (etoile/trunk/Etoile)
In order to make STOP a separator rather than terminator, the parser rules for statement_list and expression_list were written right-recursive. This made the parser stack grow with no fixed limit, and thus gave a stack overflow if a method was long/complex enough. The argument_list was written in a similar way.

This is now avoided by adding a layer which dispatches between including or leaving out the last STOP. This also eliminates the ugly-ish addObject:atIndex:0 code for building an array backwards.

 
Ship it!
Posted 1 year, 9 months ago (December 8th, 2008, 4:09 p.m.)
Looks cleaner.  Does this fix the bug I found with test.st?
  1. Yep, that was the first piece of code to trigger a stack overflow AFAIK. As usual, any problem in the parser results in an "unexpected token" message, which is a bit confusing.