'Flex lexer modifying constant in output .lex.c file
I'm working with flex to generate custom language. I'm wondering if there is a possibility to add in some way a setting that will change a part of generated .lex.c file. Namely, a part of code which flex generates is an array in yy_accept, in my case with ~1500 elements:
static const flex_int16_t yy_accept[1453] =
{ 0,
122, 122, ...
I want to set certain variables generated automatically to be stored in FLASH memory of my arduino board. For example there are libs in C which force variable to be stored in FLASH, resulting in something like:
FLASH static const flex_int16_t yy_accept[1453] =
{ 0,
122, 122, ...
Now I need to change it manually everywhere I want. Can it be done automatically with some options? Or maybe it's possible to redirect all variables into FLASH?
Solution 1:[1]
Okay, so after some research and multiple tries I've sticked to sed editor and added post processing as a command in make file, so this is sample solution:
sed -i "s/static const/FLASH static const/g" "myFile.cpp"
del sed* /a /s
2nd line removes temp file created by sed.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | KubaJ |