main.c (forgot the ";" on purpose)
#define MULTI_LINE_DEFINE int x = 1;\
int y = 2;\
int z = 3\
int v = 4;
void main()
{
MULTI_LINE_DEFINE
int w = 10;
}
gcc -E main.c -omain.pp
main.pp
# 1 "main.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "main.c"
void main()
{
int x = 1;int y = 2;int z = 3int v = 4;
int w = 10;
}
main.c:8:3: error: invalid suffix "int" on integer constant
main.c: In function 'main':
main.c:8: error: expected ',' or ';' before 'v'
how did the compiler know if the error was at "line 8" of main.cpp if it was fed the output of the preprocessor ("main.pp")?
I was expecting "#line ..." directives in the output of preprocessor (main.pp)
I am using yacc and lex to simulate gcc behaviour but on my own language.
file1 => lex1+yacc1 => file2 => lex2+yacc2 => file3
Is it possible to emulate gcc like this in lex and yacc then?
file2 corresponds to ouput of gcc preprocessor
file3 corresponds to output of gcc compiler
I want errors in file 2 to reference line numbers in file1
# 1
are treated as though they were#line
directives. – rici