changed: in SpaceParser: now we do not parse special characters when reading commentaries

so we can parse:
         # such a \n string
         beforehand this \n was treated as a new line character
         and the parser was returning syntax error when reading above 'string'



git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@432 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
2012-09-25 16:50:01 +00:00
parent c6c079f8aa
commit 02abfe62fa
2 changed files with 43 additions and 15 deletions

View File

@@ -202,6 +202,7 @@ void SpaceParser::Parse()
line = 1;
status = ok;
space = root_space;
reading_commentary = false;
ReadChar();
SkipWhiteLines();
@@ -300,13 +301,15 @@ return false;
}
void SpaceParser::SkipWhite()
/*
skip_lines is default false
*/
void SpaceParser::SkipWhite(bool skip_lines)
{
while( IsWhite(lastc) || lastc == commentary )
while( IsWhite(lastc) || lastc == commentary || (skip_lines && lastc=='\n'))
{
if( lastc == commentary )
SkipLine();
SkipComment();
else
ReadChar();
}
@@ -315,16 +318,13 @@ void SpaceParser::SkipWhite()
void SpaceParser::SkipWhiteLines()
{
while( IsWhite(lastc) || lastc == commentary || lastc=='\n' )
{
if( lastc == commentary )
SkipLine();
else
ReadChar();
}
SkipWhite(true);
}
/*
do not skip the last \n character
*/
void SpaceParser::SkipLine()
{
while( lastc != -1 && lastc != '\n' )
@@ -332,6 +332,17 @@ void SpaceParser::SkipLine()
}
/*
do not skip the last \n character
*/
void SpaceParser::SkipComment()
{
reading_commentary = true;
SkipLine();
reading_commentary = false;
}
void SpaceParser::Trim(std::wstring & s)
{
@@ -411,7 +422,7 @@ void SpaceParser::ReadTokenSingle(bool white_delimit, bool new_line_delimit, int
while( true )
{
if( lastc == commentary )
SkipLine();
SkipComment();
if( lastc == -1 ||
(!char_was_escaped &&
@@ -662,7 +673,7 @@ int SpaceParser::ReadChar()
char_was_escaped = false;
ReadCharNoEscape();
if( use_escape_char && lastc == '\\' )
if( !reading_commentary && use_escape_char && lastc == '\\' )
{
char_was_escaped = true;
ReadCharNoEscape();