You are not logged in.

#1 2008-01-24 09:42:14

ezzetabi
Member
Registered: 2006-08-27
Posts: 947

gcc preprocessor # lines meaning.

For my thesis I have to develop a parser that take as input a gcc preprocessed c file and returns its abstract tree.
I need to keep track of the program points. So the parser needs also to understand the #lines gcc puts in the preprocessed file.

And example line is:
# 1 "/usr/include/sys/types.h" 1 3 4

The octothorpe, a number, a filename, 0, 1 ,2 or 3 numbers.
The octothorpe only distinguish between those lines and the real code.
The first number is the line number where find the code that follows.
The filename is the original file where the code has been taken.

I ignore what the other numbers mean.
Do anyone have a clue?

Offline

#2 2008-01-24 10:21:33

LE_Shatai
Member
Registered: 2007-01-04
Posts: 26

Re: gcc preprocessor # lines meaning.

So actually what is your problem?

Think about a syntax, put this into bison, and use flex to read from the preprocced file.
Then bison will build a parse the input, which you can use to build your AST.

Offline

Board footer

Powered by FluxBB