This is the mail archive of the
mailing list for the GCC project.
Re: libcpp how-to question: Tokenizing and spaces & tabs â or special Fortran needs
- From: Dodji Seketeli <dodji at redhat dot com>
- To: Tobias Burnus <burnus at net-b dot de>
- Cc: Tom Tromey <tom at tromey dot com>, "Joseph S. Myers" <joseph at codesourcery dot com>, Manuel LÃpez-IbÃÃez <lopezibanez at gmail dot com>, gfortran <fortran at gcc dot gnu dot org>, gcc <gcc at gcc dot gnu dot org>
- Date: Mon, 01 Dec 2014 10:46:35 +0100
- Subject: Re: libcpp how-to question: Tokenizing and spaces & tabs â or special Fortran needs
- Authentication-results: sourceware.org; auth=none
- References: <5479E1EB dot 3080204 at net-b dot de>
[I have changed Tom Tromey's email address to his current one]
Just for the record -- as I am trimming the original post for legibility
-- the initial message I am replying to can be read at
Tobias Burnus <firstname.lastname@example.org> writes:
> Do you have a suggestion how to best implement this white-space
> preserving with libcpp? It can (and presumably should) be a special
> flag/function for Fortran.
I would propose that libcpp gets extended to gain a new kind of token
which type would be something like 'CPP_WHITESPACE', which would contain
the exact spelling of the continuous non-vertical spaces that are
There would then be a new libcpp option that would actually make
cpp_get_token() yield that kind of token. The rest of the behaviour of
cpp_get_token() that is today associated with white spaces would remain
The Fortran front-end would then initialize the cpp_reader type with the
new option so that cpp_get_token() yields the verbatim non-vertical
white space tokens.
For the case of strings that could have comments in the middle, with
associated continuation lines, I guess we could handle these especially
in the lex_string() function in libcpp/lex.c. But then the comment
would be dropped on the floor.
Would these changes be useful enough?