Announcement

Collapse
No announcement yet.

YACC Stack Overload

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • YACC Stack Overload

    Quick question.

    Can anyone tell me what a YACC Stack Overload error means when running a slic file. Its a biggie, 32 pages, but not as big as script.slc. Could it be 74 elseif statements in a row?

  • #2
    Re: YACC Stack Overload

    Originally posted by stankarp
    Quick question.

    Can anyone tell me what a YACC Stack Overload error means when running a slic file. Its a biggie, 32 pages, but not as big as script.slc. Could it be 74 elseif statements in a row?
    The short answer is: Yes, the 74 elseif statements in a row are probably to blame.

    The jargon-filled answer is:

    yacc uses an LALR(1) parser which works as a finite state automaton with a stack attached to it which runs along the file, finding the handle (the last production required to produce the current sentential form in rightmost-production-first order) and undoing that production first. The stack must maintain all of the symbols to the left of the last token in the handle. If the elseif statements are right-associative when the time comes to parse them the last one will be the handle, and all the previous ones will have to be stored in the stack at the same time, and this could well be several symbols per elseif block, which could easily result in a stack of more than 256 symbols, which might well be the limit.

    If this is the problem then it might be possible to fix this by changing the grammar so that elseif statements are made left-associative, rather than right-associative.

    Comment


    • #3
      I changed one of the "elseif" statements to an "if " and the error did not occur.

      Thanks.

      Comment


      • #4
        Glad to be of (very little) assistance .

        Really yacc should use a stack with an unlimited size to avoid this kind of problem, but I guess thry think that would slow it too much...

        Comment

        Working...
        X