Thanks for the answers of my last question.
But I still confuse about how to get a standard C compiler by using ANTLR.
antlr3 official website. Trying to combine them to get a full c compiler.
From what I learn these days, I found two ways to do this:
1. Rewrite the C parser grammar based on C preprocessor output file.
(I found someone get this done by writing a C parser based on the .i file created
by gcc using gcc -E command.)
2. "Combine the preprocessing engine with a lexer."
This way seems to separate the preprocessor and parser in logic, but combine
together in ANTLR.
I am planing to try both for learning. Can someone give me more details or advices?
For the first way I am stuck on how to get C preprocessor output as the output file created by antlr
just can recognize the input.
Should I add some ANTLR action or write a tree grammar in ANTLR to create an output file, And then
the rewrite the C parser grammar to parser the output file?
For the second way seem I need to write a Lexer grammar which combine the C preprocessor, and then write a parser
for it. That means I should rewrite all the grammar, it will be a huge work to me.