Search code examples
ccompiler-constructiontokenize

Tokenized output of C source code


I want to look at the tokenized output my c-source code. The cpp processor first process the cpp-directives and then it tokenizes the c source code. Then the this tokenized output is parsed.

After that assembler does the job and process continues.

I have written my tokenizer using flex. I just want to see how gcc compiler tokenizes c source code.

Correct me if I am wrong.


Solution

  • GCC can output the result of the preprocessing step, and there is another option (intended for debugging the preprocessor) to show you details of the tokens:

    gcc  -E  -fdebug-cpp  yourinpufile.c