Lex and Yacc without dynamic memory allocation

I am developing software for working in an embedded environment where the use of dynamic memory is prohibited. Lex and Yacc are well suited for the application.

Can I customize 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 therefore limit the use of dynamic memory to this predefined space?

Can I limit the use of dynamic memory to only initialize a program (i.e. when the program starts first)?

edit In response to TonyK, I want the analyzer not to use dynamic memory.

thanks

+5
source share
3 answers

Of course, you can, if you yourself can collect Lex and Yakka. You just need to implement your own malloc both for free and a link to them. (Assuming Lex and Yacc are pure C, which I think is the case.)

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

+2
source

Not sure if you can do this - if C generates these tools for dynamic allocation, it will be difficult for you to stop them. Perhaps it's best to create your own distribution system using the reserved memory you want to allow.

0
source

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

0
source

Source: https://habr.com/ru/post/1334948/


All Articles