diff options
author | Robert Hensing <robert@roberthensing.nl> | 2023-04-16 14:07:35 +0200 |
---|---|---|
committer | Robert Hensing <robert@roberthensing.nl> | 2023-04-16 14:07:35 +0200 |
commit | b6125772d7d5f82d48873fc93a7f261832154b14 (patch) | |
tree | 2700c6ab861df273c949739d06d6b1e6745d1819 /src/libexpr/nixexpr.cc | |
parent | 28a5cdde02964306e7eb443f696c8d5d59ebf9e9 (diff) |
libexpr: Move identifier-like printing to print.cc
Diffstat (limited to 'src/libexpr/nixexpr.cc')
-rw-r--r-- | src/libexpr/nixexpr.cc | 27 |
1 files changed, 3 insertions, 24 deletions
diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc index d8f3cd701..1557cbbeb 100644 --- a/src/libexpr/nixexpr.cc +++ b/src/libexpr/nixexpr.cc @@ -61,33 +61,12 @@ Pos::operator std::shared_ptr<AbstractPos>() const return pos; } -/* Displaying abstract syntax trees. */ - +// FIXME: remove, because *symbols* are abstract and do not have a single +// textual representation; see printIdentifier() std::ostream & operator <<(std::ostream & str, const SymbolStr & symbol) { std::string_view s = symbol; - - if (s.empty()) - str << "\"\""; - else if (s == "if") // FIXME: handle other keywords - str << '"' << s << '"'; - else { - char c = s[0]; - if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_')) { - printLiteralString(str, s); - return str; - } - for (auto c : s) - if (!((c >= 'a' && c <= 'z') || - (c >= 'A' && c <= 'Z') || - (c >= '0' && c <= '9') || - c == '_' || c == '\'' || c == '-')) { - printLiteralString(str, s); - return str; - } - str << s; - } - return str; + return printIdentifier(str, s); } void Expr::show(const SymbolTable & symbols, std::ostream & str) const |