diff --git a/uppsrc/Core/Parser.h b/uppsrc/Core/Parser.h index 754e20839..0200e008f 100644 --- a/uppsrc/Core/Parser.h +++ b/uppsrc/Core/Parser.h @@ -1,5 +1,5 @@ inline bool iscib(int c) { - return c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_'; + return c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_' || c == '$'; } inline bool iscid(int c) { diff --git a/uppsrc/Core/src.tpp/CParser$en-us.tpp b/uppsrc/Core/src.tpp/CParser$en-us.tpp index 2479511cf..868bac05b 100644 --- a/uppsrc/Core/src.tpp/CParser$en-us.tpp +++ b/uppsrc/Core/src.tpp/CParser$en-us.tpp @@ -23,7 +23,12 @@ Text has to exist during the time it is processed by CParser indicate the failure to parse required symbol. When using CParser to build concrete parser, it is common to use this exception (preferably via ThrowError method) to indicate errors as well.&] +[s9;%% Routines handling with identifiers allow ascii letters, digits +and characters `'`_`' and `'`$`'. `'`$`' is not exactly in C +standard, but is allowed by JavaSript, JSON, Java and most C/C`+`+ +compiler as extension.&] [s9;%% CParser objects cannot be transfered (copied).&] +[s9;%% &] [s3;%% &] [s0;%% &] [ {{10000F(128)G(128)@1 [s0;%% [* Constructor Detail]]}}&] diff --git a/uppsrc/CppBase/CppBase.h b/uppsrc/CppBase/CppBase.h index d8658f35d..d51e2fc67 100644 --- a/uppsrc/CppBase/CppBase.h +++ b/uppsrc/CppBase/CppBase.h @@ -5,17 +5,6 @@ NAMESPACE_UPP - -inline bool iscib2(int c) -{ - return iscib(c) || c == '$'; -} - -inline bool iscid2(int c) -{ - return c >= '0' && c <= '9' || iscib2(c); -} - int GetCppFileIndex(const String& path); const String& GetCppFile(int i); Vector GetCppFiles(); diff --git a/uppsrc/CppBase/Parser.cpp b/uppsrc/CppBase/Parser.cpp index 6f6263fcc..3946910a7 100644 --- a/uppsrc/CppBase/Parser.cpp +++ b/uppsrc/CppBase/Parser.cpp @@ -43,7 +43,7 @@ String FnItem(const char *s, const char *pname, const char *qname, const String& String res; while(*s && (byte)*s <= ' ') s++; while(*s) { // Get the name of function into res - while(*s && !iscid2(*s) && *s != '~') + while(*s && !iscid(*s) && *s != '~') s++; int lvl = 0; int plvl = 0; @@ -64,7 +64,7 @@ String FnItem(const char *s, const char *pname, const char *qname, const String& res.Cat(*s++); plvl--; } - if(iscid2(*s) || *s == '~' || *s && lvl) + if(iscid(*s) || *s == '~' || *s && lvl) res.Cat(*s++); else break; @@ -86,19 +86,19 @@ String FnItem(const char *s, const char *pname, const char *qname, const String& while(*s) { const char *w = bew(qname, s); byte c = *s; - if(w && !iscid2(*w)) { - if(iscid2(*res.Last())) + if(w && !iscid(*w)) { + if(iscid(*res.Last())) res.Cat(' '); res.Cat(name); s = w; } else - if(iscid2(c)) { + if(iscid(c)) { const char *b = s++; - while(iscid2(*s)) s++; + while(iscid(*s)) s++; String q(b, s); if(q != s_virtual && q != s_inline && q != s_static && !InScList(q, pname)) { - if(iscid2(*res.Last())) + if(iscid(*res.Last())) res.Cat(' '); res.Cat(q); } @@ -142,9 +142,9 @@ String Purify(const char *s, const char *qname, const String& name) { s = w; } else - if(iscid2(*s)) { + if(iscid(*s)) { const char *b = s++; - while(iscid2(*s)) s++; + while(iscid(*s)) s++; String q(b, s); if(q != s_virtual && q != s_inline && q != s_static) res.Cat(q); @@ -162,9 +162,9 @@ String Purify(const char *s) { String res; while(*s && (byte)*s <= ' ') s++; while(*s) { - if(iscid2(*s)) { + if(iscid(*s)) { const char *b = s++; - while(iscid2(*s)) s++; + while(iscid(*s)) s++; String q(b, s); if(q != s_virtual && q != s_inline) res.Cat(q); @@ -376,7 +376,7 @@ String Parser::ReadOper(bool& castoper) { bool spc = false; while(p < lex.Pos()) { if((byte)*p > ' ') { - if(spc && iscid2(*p)) { + if(spc && iscid(*p)) { castoper = true; r.Cat(' '); } @@ -1450,7 +1450,7 @@ void Parser::Do() String n = lex.GetText(); String name; const char *s = n; - while(*s && iscid2(*s)) + while(*s && iscid(*s)) name.Cat(*s++); CppItem& im = Item(context.scope, n, name); im.kind = MACRO; @@ -1459,7 +1459,7 @@ void Parser::Do() s++; String p; for(;;) { - if(iscid2(*s)) + if(iscid(*s)) p.Cat(*s++); else { ScAdd(im.pname, p); diff --git a/uppsrc/CppBase/Pre.cpp b/uppsrc/CppBase/Pre.cpp index 556543174..2fa5855db 100644 --- a/uppsrc/CppBase/Pre.cpp +++ b/uppsrc/CppBase/Pre.cpp @@ -98,11 +98,11 @@ SrcFile PreProcess(Stream& in) if(*rm == '#') { if(rm[1] == 'd' && rm[2] == 'e' && rm[3] == 'f' && - rm[4] == 'i' && rm[5] == 'n' && rm[6] == 'e' && !iscid2(rm[7])) { + rm[4] == 'i' && rm[5] == 'n' && rm[6] == 'e' && !iscid(rm[7])) { const char *s = rm + 8; while(*s == ' ') s++; String macro; - while(iscid2(*s)) + while(iscid(*s)) macro.Cat(*s++); if(*s == '(') { while(*s != ')' && *s) diff --git a/uppsrc/CppBase/Qualify.cpp b/uppsrc/CppBase/Qualify.cpp index 288e6bb93..d9e6b641c 100644 --- a/uppsrc/CppBase/Qualify.cpp +++ b/uppsrc/CppBase/Qualify.cpp @@ -131,9 +131,9 @@ String QualifyIds(Scopefo& nf, const String& k, bool all) int c = *s; if(c == ':') { const char *b = s++; - while(*s == ':' || iscid2(*s)) s++; + while(*s == ':' || iscid(*s)) s++; if(all) { - if(iscid2(*r.Last())) + if(iscid(*r.Last())) r << ' '; Scopefo nnf(nf.GetScope(), nf.base); Qualify(r, nnf, b, s); @@ -142,26 +142,26 @@ String QualifyIds(Scopefo& nf, const String& k, bool all) r.Cat(b, s); } else - if(iscid2(c)) { - if(iscid2(*r.Last())) + if(iscid(c)) { + if(iscid(*r.Last())) r << ' '; - if(s[0] == 'c' && s[1] == 'o' && s[2] == 'n' && s[3] == 's' && s[4] == 't' && !iscid2(s[5])) { + if(s[0] == 'c' && s[1] == 'o' && s[2] == 'n' && s[3] == 's' && s[4] == 't' && !iscid(s[5])) { r << s_const; s += 5; } else - if(s[0] == 'm' && s[1] == 'u' && s[2] == 't' && s[3] == 'a' && s[4] == 'b' && s[5] == 'l' && s[6] == 'e' && !iscid2(s[7])) { + if(s[0] == 'm' && s[1] == 'u' && s[2] == 't' && s[3] == 'a' && s[4] == 'b' && s[5] == 'l' && s[6] == 'e' && !iscid(s[7])) { r << "mutable"; s += 7; } else - if(s[0] == 'v' && s[1] == 'o' && s[2] == 'l' && s[3] == 'a' && s[4] == 't' && s[5] == 'i' && s[6] == 'l' && s[7] == 'e' && !iscid2(s[8])) { + if(s[0] == 'v' && s[1] == 'o' && s[2] == 'l' && s[3] == 'a' && s[4] == 't' && s[5] == 'i' && s[6] == 'l' && s[7] == 'e' && !iscid(s[8])) { r << "volatile"; s += 8; } else { const char *b = s++; - while(*s == ':' || iscid2(*s)) s++; + while(*s == ':' || iscid(*s)) s++; if(all) Qualify(r, nf, b, s); else diff --git a/uppsrc/CppBase/cpplex.cpp b/uppsrc/CppBase/cpplex.cpp index 10315a053..98bf833d6 100644 --- a/uppsrc/CppBase/cpplex.cpp +++ b/uppsrc/CppBase/cpplex.cpp @@ -166,7 +166,7 @@ void Lex::Next() String x; x.Reserve(12); x.Cat(c); - while(iscid2(*ptr)) + while(iscid(*ptr)) x.Cat(*ptr++); int q = id.FindAdd(x); if(q == tk_rval_ - 256) { // simple hack for transitionary macro