Skip to content
Snippets Groups Projects
Commit 5498783e authored by Houtan Bastani's avatar Houtan Bastani
Browse files

macroprocessor: add support for passing macro values to @#include statement, closes #848

parent 431e9e59
No related branches found
No related tags found
No related merge requests found
...@@ -84,6 +84,32 @@ CONT \\\\ ...@@ -84,6 +84,32 @@ CONT \\\\
BEGIN(INITIAL); BEGIN(INITIAL);
} }
<INITIAL>^{SPC}*@#{SPC}*include{SPC}+[^\"\r\n]*{SPC}*{EOL} {
yylloc->lines(1);
yylloc->step();
// Get variable name
string *modvarname = new string(yytext);
int dblq_idx1 = modvarname->find("include");
modvarname->erase(0, dblq_idx1 + 7);
modvarname->erase(0, modvarname->find_first_not_of(" \t"));
size_t p = modvarname->find_last_not_of(" \t\n\r");
if (string::npos != p)
modvarname->erase(p+1);
string *filename;
try
{
filename = new string(driver.get_variable(*modvarname)->toString());
}
catch(MacroDriver::UnknownVariable(&e))
{
driver.error(*yylloc, "Unknown variable: " + *modvarname);
}
create_include_context(filename, yylloc, driver);
BEGIN(INITIAL);
}
<INITIAL>^{SPC}*@# { yylloc->step(); BEGIN(STMT); } <INITIAL>^{SPC}*@# { yylloc->step(); BEGIN(STMT); }
<INITIAL>@\{ { yylloc->step(); BEGIN(EXPR); } <INITIAL>@\{ { yylloc->step(); BEGIN(EXPR); }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment