Adding location info to the C++ parser

Roberto Raggi roberto at kdevelop.org
Tue Mar 21 10:24:07 UTC 2006


Hi Matt!

On Friday 17 March 2006 04:53, Matt Rogers wrote:
> Hi,
>
> I've come up with a plan that I intend to use to modify the c++ parser so
> that it provides proper location info for use in KDevelop. I submit my plan
> here so that it can be reviewed, suggestions can be provided, or i can be
> flat out told I'm wrong.  :)
COOL!

>
> ==========================
>
> Plan:
>
> Change: Modify the preprocessor so it does not strip indentation or blank
> lines (blank lines are mostly when comments are being removed)
make sense.. I know rpp's code is pretty weird.. I was trying to be cool when 
I wrote it(I used a lot of STL crap :-), but now I understand it was a stupid 
idea. We really should replace all that crap with *cute* Qt code ;-) BTW let 
me know if you have any problem with source code.. 

> Change: Verify the preprocessor outputs line number markers similar to
> those output by gcc -E and if it does not, modify the preprocessor to
> output line number markers similar to the output of gcc -E
my original plan for the KDevelop's C++ engine was to use the preprocessor as 
tokenizer. ATM the preprocessor generates plain C++ code (as g++ -E), but 
would be nice to generate the token stream, and not plain C++ code. This is 
possible and it shouldn't be too difficult. This approch has many advantages, 
like:
  - the C++ engine will use less memory (no needs to generate a temp buffer)
  - we can use the same trick I used in KDevelop 3 to *fix* the column 
positions after the macro expansion
  - less code to maintain (we kill the C++ tokenizer)

> Please let me know what you think, if i'm on the right track, if i'm just
> completely wrong, if i've left out something, etc. I would appreciate any
> feedback. I will attempt to keep the parser as fast as it is now, but i
> can't guarantee anything.
well.. I think it's cool plan, and I'm sure you will make it. As I said before 
let me know if you have any problem.

ciao robe

-- 
Roberto Raggi - roberto at kdevelop.org
KDevelop http://www.kdevelop.org




More information about the KDevelop-devel mailing list