lkml.org 
[lkml]   [2018]   [May]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] proc: use #pragma once
On Fri, May 04, 2018 at 01:23:12AM +0200, Rasmus Villemoes wrote:
> > Note that sequence of preprocessor tokens does not depend upon the ifdefs;
> > anything under #if 0 *is* tokenized all the same. So it's not even that
> > "parsing" (tokenizing, actually) has to be repeated.
>
> Are you sure about that? Maybe formally it has to (if the phases are
> done strictly sequentially), but can't it go into some fast-forward mode
> under #if 0 (or #ifndef $some-defined-macro) where it only looks for
> string and char literals, comments and "control-flow" directives?

What else do you expect preprocessor tokenizer to do? It must take care
of line continuations, it must recognize and skip whitespace (including
comments) and if it recognizes string and character literals, what else
is left to do? pp-numbers? Sure - that'd be
[.]?[0-9]([0-9a-zA-Z_.]|[epEP][-+])*
Horribly hard to recognize, that... Identifiers are no harder, obviously
(especially since keywords are _not_ something special at that level)
and punctuators are also easily taken care of.

Preprocessor tokens are nowhere near as much work as C ones. And you
can't do mapping to C ones before the preprocessing is done - if nothing
else, quoting and token concatenation needs to happen first.

\
 
 \ /
  Last update: 2018-05-04 04:59    [W:0.878 / U:0.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site