This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [gomp] Parser for OpenMP directives
On Wed, 30 Mar 2005 21:14:19 +0000 (UTC), Joseph S. Myers
<joseph@codesourcery.com> wrote:
> The C++ front end lexes the whole file into an array of tokens before
> starting parsing any of it, thereby improving performance over calling
> back into the lexer whenever a new token is needed. Because pragmas are
> context-sensitive, their handlers need calling at the right point in
> parsing, so for C++ pragmas become single tokens in the token array and
> when these tokens are reached in parsing cpp_handle_deferred_pragma is
> called. This makes c_lex start returning tokens from within the pragma so
> that target pragma handlers work; whereas in the C front end when a
> #pragma is encountered the pragma handler is called immediately and c_lex
> returns the tokens from the pragma while the rest of the source file
> hasn't been lexed at all. The proposal is to change the C++ method from
> using a single token in the token array to represent the pragma to having
> a sequence of tokens representing the pragma. You still need to arrange
> for c_lex, called from the target pragma handlers, to return those tokens
> (from the token array used in the C++ front end) one by one and then
> CPP_EOF at the end of the pragma, so that target pragma handlers continue
> to work.
Thanks for the explanation.
--
Dmitry