Skip to content

Commit

Permalink
use isReservedKeyword in other print functions
Browse files Browse the repository at this point in the history
  • Loading branch information
aakropotkin committed May 9, 2023
1 parent 227bf5a commit 10f40db
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libexpr/print.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ std::ostream &
printIdentifier(std::ostream & str, std::string_view s) {
if (s.empty())
str << "\"\"";
else if (s == "if") // FIXME: handle other keywords
else if (isReservedKeyword(s))
str << '"' << s << '"';
else {
char c = s[0];
Expand All @@ -66,10 +66,10 @@ printIdentifier(std::ostream & str, std::string_view s) {
return str;
}

// FIXME: keywords
static bool isVarName(std::string_view s)
{
if (s.size() == 0) return false;
if (isReservedKeyword(s)) return false;
char c = s[0];
if ((c >= '0' && c <= '9') || c == '-' || c == '\'') return false;
for (auto & i : s)
Expand Down

0 comments on commit 10f40db

Please sign in to comment.