I want to use the start states of flex inside functions (and external files). Therefore I need the state definitions to be inside an external header file.
Is there any way of letting the definitions be written to an external file?
The code below shows an example of using the states inside functions defined inside the l-file
lexer.l
%{
void changeState(){
YY_START = MY_STATE;
}
%}
%x MY_STATE
%%
[ rules ]
%%
The following should work:
lexer.l
%x MY_STATE
%%
[ rules ]
%%
void changeState(){
BEGIN(MY_STATE);
}
Don't forget, that the upper section is actually only for declarations. Definitions should go in the last section. That way, they are places after the #define
section