mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
.developing preprocessor
git-svn-id: svn://ultimatepp.org/upp/trunk@8157 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
5193e84ff2
commit
3224e8d4ca
4 changed files with 59 additions and 4 deletions
|
|
@ -256,6 +256,22 @@ String Cpp::Preprocess(Stream& in, bool needresult)
|
|||
if(p.IsId())
|
||||
macro.UnlinkKey(p.ReadId());
|
||||
}
|
||||
else
|
||||
if(strncmp(s + 1, "include", 7) == 0 && level < 100) {
|
||||
String path = GetIncludePath(s + 8);
|
||||
DDUMP(path);
|
||||
if(path.GetCount()) {
|
||||
Cpp inc;
|
||||
inc.level = level + 1;
|
||||
inc.filedir = filedir;
|
||||
inc.include_path = include_path;
|
||||
FileIn in(path);
|
||||
inc.Preprocess(in, false);
|
||||
inc.macro.Sweep();
|
||||
for(int i = 0; i < inc.macro.GetCount(); i++)
|
||||
macro.GetAdd(inc.macro.GetKey(i)) = inc.macro[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if(needresult)
|
||||
|
|
@ -272,7 +288,11 @@ String Cpp::Preprocess(Stream& in, bool needresult)
|
|||
incomment = false;
|
||||
s += 2;
|
||||
}
|
||||
s++;
|
||||
else
|
||||
if(s[0] == '/' && s[1] == '/' && !incomment)
|
||||
break;
|
||||
else
|
||||
s++;
|
||||
}
|
||||
}
|
||||
if(needresult)
|
||||
|
|
@ -281,3 +301,27 @@ String Cpp::Preprocess(Stream& in, bool needresult)
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
String Cpp::GetIncludePath(const char *s)
|
||||
{
|
||||
while(IsSpace(*s))
|
||||
s++;
|
||||
int type = *s;
|
||||
if(type == '<' || type == '\"' || type == '?') {
|
||||
s++;
|
||||
String name;
|
||||
if(type == '<') type = '>';
|
||||
while(*s != '\r' && *s != '\n') {
|
||||
if(*s == type) {
|
||||
if(type == '\"') {
|
||||
String fn = NormalizePath(name, filedir);
|
||||
if(FileExists(fn))
|
||||
return fn;
|
||||
}
|
||||
return GetFileOnPath(name, include_path, false);
|
||||
}
|
||||
name.Cat(*s++);
|
||||
}
|
||||
}
|
||||
return Null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue