Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Yacc Parsers

Name: Anonymous 2011-11-23 22:39

How to properly release heap-based symbols in a POSIX-compliant parser generated by Yacc? Standard Yacc does not support the convenient %destructor directive present in modern versions of GNU Bison.

The only possible alternatives I see in this behalf are:
    - Avoid heap allocation and use static allocation; (easy but bad)
    - Provide some means to save every allocated pointer during grammar traversal in some context and release the pointers appropriately afterwards; (boring to implement, bloats the code, not worth the hassle)
    - Use some pool allocator. (Inconvenient and yield pointers without free()-semantics)

Suggestions are appreciated.

Name: Anonymous 2011-11-23 22:43

use bison

Name: Anonymous 2011-11-23 23:17

easy but bad
Why? If it works, use it.

Name: Anonymous 2011-11-24 0:21

>>2
I want it to be compliant instead of relying on the presence of the GNU toolchain. Specifically I want it to work on byacc (and possibly other implementations).

>>3
It is hard to predict a reasonable limit. Any reasonable (for example, some KBs for a string, to be conservative) amount will be harmful in several ways; specially harmful if the generated parser creates (that is, declares in its generated code) symbols unnecessarily in its scope and the data is declared to be large enough to contain some expected values during runtime, trashing the stack to a large extent, and creating incredible overhead due to copying (since you cannot manipulate pointers).

Name: Anonymous 2011-11-24 7:14

not anime

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List