Skip to content

Commit

Permalink
For symbol tokens, do not put anything in "data" as it gets printed t…
Browse files Browse the repository at this point in the history
…wice in error messages.
  • Loading branch information
sparkprime committed Mar 13, 2016
1 parent 072ab09 commit c46d01d
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions core/lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,55 +375,46 @@ Tokens jsonnet_lex(const std::string &filename, const char *input)
// The following operators should never be combined with subsequent symbols.
case '{':
kind = Token::BRACE_L;
data = "{";
c++;
break;

case '}':
kind = Token::BRACE_R;
data = "}";
c++;
break;

case '[':
kind = Token::BRACKET_L;
data = "[";
c++;
break;

case ']':
kind = Token::BRACKET_R;
data = "]";
c++;
break;

case ',':
kind = Token::COMMA;
data = ",";
c++;
break;

case '.':
kind = Token::DOT;
data = ".";
c++;
break;

case '(':
kind = Token::PAREN_L;
data = "(";
c++;
break;

case ')':
kind = Token::PAREN_R;
data = ")";
c++;
break;

case ';':
kind = Token::SEMICOLON;
data = ";";
c++;
break;

Expand Down Expand Up @@ -691,7 +682,12 @@ Tokens jsonnet_lex(const std::string &filename, const char *input)
c--;
}
data += std::string(operator_begin, c);
kind = data == "$" ? Token::DOLLAR : Token::OPERATOR;
if (data == "$") {
kind = Token::DOLLAR;
data = "";
} else {
kind = Token::OPERATOR;
}
} else {
std::stringstream ss;
ss << "Could not lex the character ";
Expand Down

0 comments on commit c46d01d

Please sign in to comment.