Skip to content

Commit

Permalink
AsmToken had more special cases than I thought
Browse files Browse the repository at this point in the history
  • Loading branch information
chuggafan committed Apr 19, 2024
1 parent 3343a8d commit 55b9507
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/ocpp/Token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@ bool NumericToken::ansi;
bool NumericToken::c99;
bool StringToken::Start(const std::string& line)
{
if (line[0] == '"')
return true;
bool isOasm = TokenizerSettings::Instance()->GetDialect() == Dialect::oasm;
if (isOasm)
{
if (line[0] == '\'')
return true;
}
if (line[0] == '"' || (isOasm && line[0] == '\''))
return true;
if (line[0] == 'L')
{
size_t n = line.find_first_not_of(' ', 1);
Expand All @@ -37,8 +32,9 @@ void StringToken::Parse(std::string& line)
while (isspace(*start))
start++;
}
int quote = *start;
start++; // past the quote
while (*start && *start != '\"')
while (*start && *start != quote)
{
int n;
const char* cur = start;
Expand Down Expand Up @@ -67,7 +63,7 @@ void StringToken::Parse(std::string& line)
*q = 0;
raw += Raw;
}
if (*start != '"')
if (*start != quote)
Errors::Error("Unterminated string constant");
else
start++;
Expand All @@ -76,6 +72,9 @@ void StringToken::Parse(std::string& line)
}
bool CharacterToken::Start(const std::string& line)
{
bool isOasm = TokenizerSettings::Instance()->GetDialect() == Dialect::oasm;
if (isOasm)
return false;
if (line[0] == '\'')
return true;
if (line[0] == 'L')
Expand Down Expand Up @@ -108,6 +107,12 @@ void CharacterToken::Parse(std::string& line)
}
int CharacterToken::QuotedChar(int bytes, const char** source)
{
// No clue why we need to special case AsmToken here...
bool isOasm = TokenizerSettings::Instance()->GetDialect() == Dialect::oasm;
if (isOasm)
{
return *(*source)++;
}
int i = *(*source)++, j;
if (**source == '\n')
return INT_MIN;
Expand Down

0 comments on commit 55b9507

Please sign in to comment.