Core: CParser::IsId(const char *), improved 'visuals' for ValueArray::ToString

git-svn-id: svn://ultimatepp.org/upp/trunk@4114 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2011-11-01 19:41:01 +00:00
parent 88728e492b
commit 9d9f62f182
4 changed files with 21 additions and 8 deletions

View file

@ -15,6 +15,7 @@ protected:
bool skipspaces;
bool Spaces0();
const char *IsId0(const char *s);
bool Id0(const char *id);
void DoSpaces() { if(skipspaces) Spaces(); }
@ -43,6 +44,7 @@ public:
bool Id(const char *s) { return term[0] == s[0] && (s[1] == 0 || term[1] == s[1]) && Id0(s); }
void PassId(const char *s) throw(Error);
bool IsId() { return iscib(*term); }
bool IsId(const char *s) { return term[0] == s[0] && (s[1] == 0 || term[1] == s[1]) && IsId0(s); }
String ReadId() throw(Error);
String ReadIdt() throw(Error);
bool IsInt();

View file

@ -290,12 +290,12 @@ bool ValueArray::operator==(const ValueArray& v) const
static String sAsString(const Vector<Value>& v)
{
String s;
s << "{ ";
s << "[";
for(int i = 0; i < v.GetCount(); i++) {
if(i) s << ", ";
s << v[i];
}
s << " }";
s << "]";
return s;
}
@ -471,7 +471,7 @@ String ValueMap::Data::AsString() const
s << "{ ";
for(int i = 0; i < key.GetCount(); i++) {
if(i) s << ", ";
s << "(" << key[i] << ", " << value[i] << ")";
s << key[i] << ": " << value[i];
}
s << " }";
return s;

View file

@ -48,17 +48,22 @@ bool CParser::Spaces0() {
return true;
}
bool CParser::Id0(const char *s) {
LTIMING("Id");
const char *CParser::IsId0(const char *s) {
const char *t = term + 1;
s++;
while(*s) {
if(*t != *s)
return false;
return NULL;
t++;
s++;
}
if(IsAlNum(*t) || *t == '_')
return IsAlNum(*t) || *t == '_' ? NULL : t;
}
bool CParser::Id0(const char *s) {
LTIMING("Id");
const char *t = IsId0(s);
if(!t)
return false;
term = t;
DoSpaces();

View file

@ -168,11 +168,17 @@ d] method with [%-*@3 s] as parameter. If it returns [* false], throws
].&]
[s3; &]
[s4; &]
[s5;:CParser`:`:IsId`(`): [@(0.0.255) bool]_[* IsId]()&]
[s5;:CParser`:`:IsId`(`)const: [@(0.0.255) bool]_[* IsId]()_const&]
[s2;%% Tests whether there is any C`-like identifier at the current
position.&]
[s3; &]
[s4; &]
[s5;:CParser`:`:IsId`(const char`*`): [@(0.0.255) bool]_[* IsId]([@(0.0.255) const]_[@(0.0.255) c
har]_`*[*@3 s])_const&]
[s2;%% Tests whether there is C`-like identifier [%-*@3 s] at current
position.&]
[s3;%% &]
[s4; &]
[s5;:CParser`:`:ReadId`(`)throw`(CParser`:`:Error`): [_^String^ String]_[* ReadId]()_[@(0.0.255) t
hrow](Error)&]
[s2;%% Reads C`-like identifier from the current position. If there