CppBase: struct template specialisation

git-svn-id: svn://ultimatepp.org/upp/trunk@8176 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2015-02-14 18:13:40 +00:00
parent d740b08fe4
commit 8d3508d1c2
3 changed files with 63 additions and 4 deletions

View file

@ -142,7 +142,9 @@ public:
const char *Pos(int pos = 0);
int operator[](int pos) { return Code(pos); }
operator int() { return Code(0); }
void operator++() { Get(); }
void operator++() { return Get(); }
void Dump(int pos);
void Init(const char *s, const Vector<String>& ignore);
void StartStatCollection();

View file

@ -380,7 +380,7 @@ String Parser::Name(String& name, bool& castoper)
s << h;
break;
}
if(lex == '<')
if(lex == '<') // void Fn<byte>(); situation
s << TemplateParams();
if(Key(t_dblcolon)) {
s << "::";
@ -1134,7 +1134,7 @@ bool Parser::Scope(const String& tp, const String& tn) {
return true;
}
if((lex == tk_class || lex == tk_struct || lex == tk_union) && lex[1] != '{') {
int t = lex.GetCode();
int t = lex.GetCode(); // t is now struct/class/union
context.typenames.FindAdd(lex);
Context cc;
cc <<= context;
@ -1158,7 +1158,9 @@ bool Parser::Scope(const String& tp, const String& tn) {
do {
Check(lex.IsId(), "Missing identifier");
context.typenames.FindAdd(lex);
name = lex.GetId();
name = lex.GetId(); // name of structure
if(lex == '<')
name << TemplateParams();
ScopeCat(context.scope, name);
}
while(Key(t_dblcolon));

View file

@ -1,5 +1,7 @@
#include "CppBase.h"
// #define LOGNEXT
NAMESPACE_UPP
#ifdef _MSC_VER
@ -400,6 +402,59 @@ void Lex::Get(int n)
if(term.GetCount() == 0)
break;
}
#ifdef LOGNEXT
Dump(0);
#endif
}
void Lex::Dump(int pos)
{
#ifdef LOGNEXT
int code = Code(pos);
switch(code) {
case t_string: LOG(AsCString(Text(pos))); break;
case t_double: LOG(Double(pos)); break;
case t_integer: LOG(Int(pos)); break;
case t_character: LOG("char " << AsCString(String(Chr(pos), 1))); break;
default:
if(code < 0)
LOG(decode(Code(),
t_dblcolon, "::",
t_mulass, "*=",
t_divass, "/=",
t_modass, "%=",
t_xorass, "^=",
t_neq, "!=",
t_dot_asteriks, ".*",
t_elipsis, "...",
t_inc, "++",
t_addass, "+=",
t_dec, "--",
t_arrow_asteriks, "->*",
t_arrow, "->",
t_subass, "-=",
t_and, "&&",
t_andass, "&=",
t_or, "||",
t_orass, "|=",
t_eq, "==",
t_shl, "<<",
t_shlass, "<<=",
t_le, "<=",
t_shr, ">>",
t_shrass, ">>=",
t_ge, ">=",
te_integeroverflow, "<integer overflow>",
te_badcharacter, "<bad char>",
te_badstring, "<bad string>",
"???"));
else
if(code < 256)
LOG((char)code);
else
LOG(id[code - 256]);
}
#endif
}
void Lex::SkipToGrounding()