Fix line number tracking in sexpr parser
This commit is contained in:
parent
cf1003955d
commit
d29f39dce4
|
@ -31,7 +31,7 @@ namespace SEXPR
|
||||||
}
|
}
|
||||||
|
|
||||||
SEXPR::SEXPR(SEXPR_TYPE type) :
|
SEXPR::SEXPR(SEXPR_TYPE type) :
|
||||||
m_type(type), m_lineNumber(0)
|
m_type(type), m_lineNumber(1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace SEXPR
|
||||||
{
|
{
|
||||||
const std::string PARSER::whitespaceCharacters = " \t\n\r\b\f\v";
|
const std::string PARSER::whitespaceCharacters = " \t\n\r\b\f\v";
|
||||||
|
|
||||||
PARSER::PARSER() : m_lineNumber(0), m_lineOffset(0)
|
PARSER::PARSER() : m_lineNumber(1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,6 @@ namespace SEXPR
|
||||||
if (*it == '\n')
|
if (*it == '\n')
|
||||||
{
|
{
|
||||||
m_lineNumber++;
|
m_lineNumber++;
|
||||||
m_lineOffset = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (whitespaceCharacters.find(*it) != std::string::npos)
|
if (whitespaceCharacters.find(*it) != std::string::npos)
|
||||||
|
@ -95,6 +94,12 @@ namespace SEXPR
|
||||||
SEXPR_LIST* list = new SEXPR_LIST(m_lineNumber);
|
SEXPR_LIST* list = new SEXPR_LIST(m_lineNumber);
|
||||||
while (it != aString.end() && *it != ')')
|
while (it != aString.end() && *it != ')')
|
||||||
{
|
{
|
||||||
|
//there may be newlines in between atoms of a list, so detect these here
|
||||||
|
if (*it == '\n')
|
||||||
|
{
|
||||||
|
m_lineNumber++;
|
||||||
|
}
|
||||||
|
|
||||||
if (whitespaceCharacters.find(*it) != std::string::npos)
|
if (whitespaceCharacters.find(*it) != std::string::npos)
|
||||||
{
|
{
|
||||||
std::advance(it, 1);
|
std::advance(it, 1);
|
||||||
|
|
|
@ -38,7 +38,6 @@ namespace SEXPR
|
||||||
SEXPR* parseString(const std::string& aString, std::string::const_iterator& it);
|
SEXPR* parseString(const std::string& aString, std::string::const_iterator& it);
|
||||||
static const std::string whitespaceCharacters;
|
static const std::string whitespaceCharacters;
|
||||||
int m_lineNumber;
|
int m_lineNumber;
|
||||||
int m_lineOffset;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue