I insist on using lex and not the flex.
am developing an API in lex like the one existing in the flex util ( yy_switch_buffer, yy_create_buffer ...) offering the possibility to switch between multiple buffers .
This is the main difficulty for me until now :
- for example when I encounter a
#includetoken i should switch the buffer to the included file. So first i should interrupt the current parsing action( I triedfclose(yyin)FAILED) the parser complete the whole current yyin. NOT good because I should parse the included file to store structures (for example ) used in the main file.
Question is : How can I interrupt immediately a parser ? Is it enough for me to define a new buffer using yyin = fopen(somefile, "r"); ??
lexmay have problems, so you must use it? You could compile withflexon one machine and simply compile the Flex library (-lfl) on the native machine, plus the transferred C source generated from the Flex. Butflexcan be transported to those machines trivially. There is no 'native Lex' on Windows. You can either use MKS Lex & Yacc or Cygwin with Flex (and Bison if you need grammars too). - Jonathan Leffler