Fix preprocessor grammar.
Closed this issue · 1 comments
Oblivious-Oblivious commented
Grammar for preprocessor does not compile correctly.
external_declaration:
preprocessor_directive {
$$ = string_dup($1);
}
| function_definition {
$$ = string_dup($1);
}
| declaration {
$$ = string_dup($1);
}
| object_specifier {
$$ = string_dup($1);
}
;
The preprocessor_directive
rule is either higher up or lower down on the syntax precedence.
Oblivious-Oblivious commented
Solution: Remove all preprocessor grammar and keep the #include
directive
preprocessor_control_line:
INCLUDE '<' HEADER '>' {
$$ = new_string("\n#include <");
string_add_str($$, string_get($3));
string_add_str($$, ">\n");
}
| INCLUDE STRING {
$$ = new_string("\n#include ");
string_add_str($$, string_get($2));
string_add_char($$, '\n');
/* Newline is added on the string */
}