[Flex-help] multiple input buffer problem using yy_scan_string and yypop_buffer_state()
flex is a tool for generating scanners
Brought to you by:
wlestes
From: Georg T. <ge...@te...> - 2007-10-08 03:31:20
|
Hi, I'm writing a lexer for a project of mine using flex 2.5.33 an ran into a problem which could be a bug, a missinterpretation of the docs or my simply mistake. Anyhow I need someones advice: The problem I wanna solve is a lexer for shellscript like variable-definitions: Var=Value. I do need the values in some C code. As this is supposed tu run under Linux/Unix as well as Windows just sourcing the script and reading in the variables isn't an option. Additionaly shell quoted characters are allowed. The Values can, but need not bee enclosed in single or double quotes, even only parts of them and need to be parsed again afterwords for further processing. To accomplish this I read in the whole Value-part into a string (an array of char to be exact) and parse this with: yypush_buffer_state( yy_scan_string ( &string_buf[0] )); which works so far. But I failed restoring the previous puffer state using yypop_buffer_state(); which is what I do not understand!? Also trying to redefine yywrap or calling yyrestart() at locations seeming sensfull did not help. What did I miss? Actually calling LastBuffPtr = YY_CURRENT_BUFFER; AktBuffPtr = yy_scan_string ( string_buf_ptr ); yy_switch_to_buffer(AktBuffPtr); in the first and yy_delete_buffer( YY_CURRENT_BUFFER ); yy_switch_to_buffer( LastBuffPtr ); in the second did the yob! The same is true for the multiple buffer examples on http://flex.sourceforge.net/manual/Multiple-Input-Buffers.html#Multiple-Input-Buffers working on file buffers! Thanks for your help in advance! Georg Tenckhoff |