[cfe-dev] Returning original parsing state after parsing arbitrary tokens
Eli Friedman
eli.friedman at gmail.com
Tue Oct 23 03:02:31 PDT 2012
On Tue, Oct 23, 2012 at 2:44 AM, ja_comp <ja_comp at yahoo.com> wrote:
> Assume that a program did the following:
>
> 1) Called EnterTokenStream with arbitrary tokens (followed by a Semicolon
> and Eof)
> 2) Called setSuppressAllDiagnostics(true) to keep from emitting errors (in
> case the next step fails)
> 3) Called ParseStatement to produce a StmtResult from the additional tokens
> (which may or may not produce a valid result)
> 4) Lexed tokens (if necessary) to remove any unlexed added tokens
> 5) Called setSuppressAllDiagnostics(false) to restore error handling
>
> What variables and/or other states should be saved to return the
> Preprocessor/Parser/Lexer to the state they were in before step 1?
It's impossible to completely save/restore the state of semantic
analysis short of using fork() or equivalent. You might be able to
get away with an approximation depending on your exact requirements,
though.
At a higher level, what are you trying to do?
-Eli
More information about the cfe-dev
mailing list