help-flex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Buffer state stack and yy_scan_string


From: Carlos Sánchez de La Lama
Subject: Buffer state stack and yy_scan_string
Date: Thu, 28 Feb 2013 09:55:27 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

Hi all,

I am trying to use yy_scan_string on a program which also uses buffer
state stacks ({yypush, yypop}_buffer_state). According to the
documentation, yy_scan_string switches current buffer so a string is
parsed, but my desired behaviour is to get back to parsing the file
(using yypop?) once the string has been parsed.

I have seen some references on the web to using

yypush_buffer_state(yy_parse_string(...))

but I have noticed the inner yy_parse_string subsitutes the current
buffer state, which then gets pushed, and the original state gets lost
(no way to get back to file parsing).

The solution I have found is a little bit weird:

yypush_buffer_state (YY_CURRENT_BUFFER);
yy_scan_string (m.definition.c_str());

Thus first the *current* state is pushed (effectively creating a copy),
but then the yy_scan_string changes current buffer to the string.

It works, but just wanted to ask if somebody knows a better way to do
it.

Thanks!

Carlos




reply via email to

[Prev in Thread] Current Thread [Next in Thread]