开发者

Lex and Yacc without Dynamic Memory Allocation

开发者 https://www.devze.com 2023-02-04 12:24 出处:网络
I\'m in the process of designing software to run in an embedded environment where the use of dynamic memory is prohibited.Lex and Yacc are well suited for the application.

I'm in the process of designing software to run in an embedded environment where the use of dynamic memory is prohibited. Lex and Yacc are well suited for the application.

Can I configure Lex and Yacc to not use dynamic memory allocation at all?

Can I configure Lex and Yacc to use a predefined block of memory and therefor limit dynamic memory usage to that predefined space?

Can I limit the use of dynamic memory to program initialization only (i.e. when the program first runs)?

edit: In response to TonyK, I want the parser to not开发者_如何学C use dynamic memory.

Thank you


Sure you can, if you can compile Lex and Yacc yourself. You just have to implement your own malloc and free, and link to those. (Assuming Lex and Yacc are pure C, which I think is the case.)

Edit Have I misunderstood yet another question? Do you want Lex and Yacc themselves to use a limited amount of memory, or do you want them to generate parsers that use a limited amount of memory?


Not sure you can do that - if the C those tools generate want to do dynamic allocation then you'll have a hard time stopping them. Perhaps the best thing would be to create your own allocation system, using the reserved memory to want to allow.


You can use noyyalloc, noyyfree and noyyrealloc and then implement these yourself.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号