more fixes (nw)

This commit is contained in:
Miodrag Milanovic 2016-02-25 14:25:52 +01:00
parent 0f85f112c9
commit 0b2ea0800f
2 changed files with 18 additions and 18 deletions

View File

@ -21,22 +21,22 @@ pstring ptokenizer::currentline_str()
void ptokenizer::skipeol() void ptokenizer::skipeol()
{ {
pstring::code_t c = getc(); pstring::code_t c = _getc();
while (c) while (c)
{ {
if (c == 10) if (c == 10)
{ {
c = getc(); c = _getc();
if (c != 13) if (c != 13)
ungetc(); _ungetc();
return; return;
} }
c = getc(); c = _getc();
} }
} }
pstring::code_t ptokenizer::getc() pstring::code_t ptokenizer::_getc()
{ {
if (m_px >= m_cur_line.len()) if (m_px >= m_cur_line.len())
{ {
@ -51,7 +51,7 @@ pstring::code_t ptokenizer::getc()
return m_cur_line.code_at(m_px++); return m_cur_line.code_at(m_px++);
} }
void ptokenizer::ungetc() void ptokenizer::_ungetc()
{ {
m_px--; m_px--;
} }
@ -159,10 +159,10 @@ ptokenizer::token_t ptokenizer::get_token()
ptokenizer::token_t ptokenizer::get_token_internal() ptokenizer::token_t ptokenizer::get_token_internal()
{ {
/* skip ws */ /* skip ws */
pstring::code_t c = getc(); pstring::code_t c = _getc();
while (m_whitespace.find(c)>=0) while (m_whitespace.find(c)>=0)
{ {
c = getc(); c = _getc();
if (eof()) if (eof())
{ {
return token_t(ENDOFFILE); return token_t(ENDOFFILE);
@ -182,9 +182,9 @@ ptokenizer::token_t ptokenizer::get_token_internal()
else if (m_number_chars.find(c)<0) else if (m_number_chars.find(c)<0)
break; break;
tokstr += c; tokstr += c;
c = getc(); c = _getc();
} }
ungetc(); _ungetc();
return token_t(ret, tokstr); return token_t(ret, tokstr);
} }
else if (m_identifier_chars.find(c)>=0) else if (m_identifier_chars.find(c)>=0)
@ -193,9 +193,9 @@ ptokenizer::token_t ptokenizer::get_token_internal()
pstring tokstr = ""; pstring tokstr = "";
while (m_identifier_chars.find(c)>=0) { while (m_identifier_chars.find(c)>=0) {
tokstr += c; tokstr += c;
c = getc(); c = _getc();
} }
ungetc(); _ungetc();
token_id_t id = token_id_t(m_tokens.indexof(tokstr)); token_id_t id = token_id_t(m_tokens.indexof(tokstr));
if (id.id() >= 0) if (id.id() >= 0)
return token_t(id, tokstr); return token_t(id, tokstr);
@ -207,11 +207,11 @@ ptokenizer::token_t ptokenizer::get_token_internal()
else if (c == m_string) else if (c == m_string)
{ {
pstring tokstr = ""; pstring tokstr = "";
c = getc(); c = _getc();
while (c != m_string) while (c != m_string)
{ {
tokstr += c; tokstr += c;
c = getc(); c = _getc();
} }
return token_t(STRING, tokstr); return token_t(STRING, tokstr);
} }
@ -228,9 +228,9 @@ ptokenizer::token_t ptokenizer::get_token_internal()
if (id.id() >= 0) if (id.id() >= 0)
return token_t(id, tokstr); return token_t(id, tokstr);
} }
c = getc(); c = _getc();
} }
ungetc(); _ungetc();
token_id_t id = token_id_t(m_tokens.indexof(tokstr)); token_id_t id = token_id_t(m_tokens.indexof(tokstr));
if (id.id() >= 0) if (id.id() >= 0)
return token_t(id, tokstr); return token_t(id, tokstr);

View File

@ -120,8 +120,8 @@ protected:
private: private:
void skipeol(); void skipeol();
pstring::code_t getc(); pstring::code_t _getc();
void ungetc(); void _ungetc();
bool eof() { return m_strm.eof(); } bool eof() { return m_strm.eof(); }