1

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.

2
  • It's not really clear what you are asking; can you rephrase? Commented Feb 7, 2015 at 11:46
  • In the documentation of the GNU preprocessor, it is written that the c source code is tokenized. Ex 2+3 is tokenized as Int(2) PLUS Int(3) Commented Feb 7, 2015 at 11:48

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

1 Comment

I believe that the code of the c-tokenizer must have been written in flex, as flex and bison are used in GCC. Can I get the source code of the c-tokenizer? I want to understand how does gcc compiler works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.