mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-16 06:05:58 -06:00
94 lines
No EOL
1.8 KiB
C++
94 lines
No EOL
1.8 KiB
C++
#include "cpp.h"
|
|
|
|
#if 0
|
|
String MacroExpand(const char *s, ArrayMap<String, CppMacro>& macro, Index<String>& notmacro,
|
|
bool& incomment)
|
|
{
|
|
StringBuffer r;
|
|
while(*s) {
|
|
if(incomment) {
|
|
if(s[0] == '*' && s[1] == '/') {
|
|
incomment = false;
|
|
s += 2;
|
|
r.Cat("*/");
|
|
}
|
|
else
|
|
r.Cat(*s++);
|
|
}
|
|
else
|
|
if(iscib2(*s)) {
|
|
const char *b = s;
|
|
s++;
|
|
while(iscid2(*s))
|
|
s++;
|
|
String id(b, s);
|
|
if(notmacro.Find(id) < 0) {
|
|
const CppMacro *m = macro.FindPtr(id);
|
|
if(m && !id.StartsWith("__$allowed_on_")) {
|
|
Vector<String> param;
|
|
const char *s0 = s;
|
|
while(*s && (byte)*s <= ' ')
|
|
s++;
|
|
if(*s == '(') {
|
|
s++;
|
|
const char *b = s;
|
|
int level = 0;
|
|
for(;;)
|
|
if(*s == ',' && level == 0) {
|
|
ParamAdd(param, b, s);
|
|
s++;
|
|
b = s;
|
|
}
|
|
else
|
|
if(*s == ')') {
|
|
s++;
|
|
if(level == 0) {
|
|
ParamAdd(param, b, s - 1);
|
|
break;
|
|
}
|
|
level--;
|
|
}
|
|
else
|
|
if(*s == '(') {
|
|
s++;
|
|
level++;
|
|
}
|
|
else
|
|
if(*s == '\0')
|
|
break;
|
|
else
|
|
if(*s == '\"' || *s == '\'')
|
|
s = SkipString(s);
|
|
else
|
|
s++;
|
|
}
|
|
else
|
|
s = s0; // otherwise we eat spaces after parameterless macro
|
|
usedmacro.FindAdd(id);
|
|
int ti = notmacro.GetCount();
|
|
notmacro.Add(id);
|
|
id = '\x1a' + Expand(m->Expand(param));
|
|
notmacro.Trim(ti);
|
|
}
|
|
else
|
|
notmacro.Add(id);
|
|
}
|
|
r.Cat(id);
|
|
}
|
|
else
|
|
if(s[0] == '/' && s[1] == '*') {
|
|
incomment = true;
|
|
s += 2;
|
|
r.Cat("/*");
|
|
}
|
|
else
|
|
if(s[0] == '/' && s[1] == '/') {
|
|
r.Cat(s);
|
|
break;
|
|
}
|
|
else
|
|
r.Cat(*s++);
|
|
}
|
|
return r;
|
|
}
|
|
#endif
|