Skip to content

Commit

Permalink
Fix the parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaudov, Stanislav Tomov committed Sep 21, 2020
1 parent 391839b commit 31d5cee
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions src/alisp/include/alisp/alisp/alisp_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,6 @@ template<class Environment> class ALParser : public ParserBase
case 't': m_str.push_back('\t'); return true;
case 'n': m_str.push_back('\n'); return true;
case 'r': m_str.push_back('\r'); return true;
case 't': m_str.push_back('\t'); return true;
case 'v': m_str.push_back('\v'); return true;
default: return false;
}
Expand Down Expand Up @@ -920,41 +919,41 @@ template<class Environment> class ALParser : public ParserBase
PARSE_ERROR("Expected \'?\'");
}
++position;

if (check_char('\\'))
{
++position;
switch (*position)
{
case '\'': ++position; return make_char(static_cast<ALObject::int_type>('\''));
case '\"': ++position; return make_char(static_cast<ALObject::int_type>('\"'));
case 'a': ++position; return make_char(static_cast<ALObject::int_type>('\a'));
case 'b': ++position; return make_char(static_cast<ALObject::int_type>('\b'));
case 't': ++position; return make_char(static_cast<ALObject::int_type>('\t'));
case 'n': ++position; return make_char(static_cast<ALObject::int_type>('\n'));
case 'v': ++position; return make_char(static_cast<ALObject::int_type>('\v'));
case 'f': ++position; return make_char(static_cast<ALObject::int_type>('\f'));
case 'r': ++position; return make_char(static_cast<ALObject::int_type>('\r'));
case 'e': ++position; return make_char(static_cast<ALObject::int_type>(27));
case 'd': ++position; return make_char(static_cast<ALObject::int_type>(127));
case 's': ++position; return make_char(static_cast<ALObject::int_type>(' '));
case '\\': ++position; return make_char(static_cast<ALObject::int_type>('\\'));
case '\'': ++position; return make_char(static_cast<ALObject::int_type>('\''));
case '\"': ++position; return make_char(static_cast<ALObject::int_type>('\"'));
case 'a': ++position; return make_char(static_cast<ALObject::int_type>('\a'));
case 'b': ++position; return make_char(static_cast<ALObject::int_type>('\b'));
case 't': ++position; return make_char(static_cast<ALObject::int_type>('\t'));
case 'n': ++position; return make_char(static_cast<ALObject::int_type>('\n'));
case 'v': ++position; return make_char(static_cast<ALObject::int_type>('\v'));
case 'f': ++position; return make_char(static_cast<ALObject::int_type>('\f'));
case 'r': ++position; return make_char(static_cast<ALObject::int_type>('\r'));
case 'e': ++position; return make_char(static_cast<ALObject::int_type>(27));
case 'd': ++position; return make_char(static_cast<ALObject::int_type>(127));
case 's': ++position; return make_char(static_cast<ALObject::int_type>(' '));
case '\\': ++position; return make_char(static_cast<ALObject::int_type>('\\'));
default: {

std::string str{};
StringParser parser{str};
StringParser<std::string> parser{str};
parser.is_escaped = true;
while(!str.is_empty)

while(str.empty())
{
parser.parse(*position);
if (parser.parse(*position)) {
PARSE_ERROR("Unknown escape sequence \'?\'");
}
++position;
}

return make_char(static_cast<ALObject::int_type>(str[0]));
// PARSE_ERROR("Unknown escape sequence \'?\'");
}
}

}
else
{
Expand Down

0 comments on commit 31d5cee

Please sign in to comment.