diff --git a/uppsrc/CppBase/CppBase.h b/uppsrc/CppBase/CppBase.h index b6017a154..9f08b848b 100644 --- a/uppsrc/CppBase/CppBase.h +++ b/uppsrc/CppBase/CppBase.h @@ -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& ignore); void StartStatCollection(); diff --git a/uppsrc/CppBase/Parser.cpp b/uppsrc/CppBase/Parser.cpp index ccb3c1052..1fc330137 100644 --- a/uppsrc/CppBase/Parser.cpp +++ b/uppsrc/CppBase/Parser.cpp @@ -380,7 +380,7 @@ String Parser::Name(String& name, bool& castoper) s << h; break; } - if(lex == '<') + if(lex == '<') // void Fn(); 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)); diff --git a/uppsrc/CppBase/cpplex.cpp b/uppsrc/CppBase/cpplex.cpp index 68816a943..ea211de13 100644 --- a/uppsrc/CppBase/cpplex.cpp +++ b/uppsrc/CppBase/cpplex.cpp @@ -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, "", + te_badcharacter, "", + te_badstring, "", + "???")); + else + if(code < 256) + LOG((char)code); + else + LOG(id[code - 256]); + } +#endif } void Lex::SkipToGrounding()