utils/sexp: add some convenience

Add some convenience function for dealing the head/tail
Some whitespace / cosmetics
Add operators ==
Add operator !=
Update command handler for this.
This commit is contained in:
Dirk-Jan C. Binnema
2023-06-04 14:26:37 +03:00
parent 3624fdd5f3
commit 9bab2a4050
4 changed files with 62 additions and 42 deletions

View File

@ -201,7 +201,7 @@ Sexp::to_string(Format fopts) const
else if (numberp())
sstrm << number();
else if (symbolp())
sstrm << symbol();
sstrm << symbol().name;
if (typeinfop)
sstrm << '<' << Sexp::type_name(type()) << '>';
@ -224,7 +224,7 @@ Sexp::to_json_string(Format fopts) const
auto it{list().begin()};
bool first{true};
while (it != list().end()) {
sstrm << (first ? "" : ",") << quote(it->symbol()) << ":";
sstrm << (first ? "" : ",") << quote(it->symbol().name) << ":";
++it;
sstrm << it->to_json_string();
++it;
@ -255,7 +255,7 @@ Sexp::to_json_string(Format fopts) const
else if (symbol() == "t")
sstrm << "true";
else
sstrm << quote(symbol());
sstrm << quote(symbol().name);
break;
case Type::Number:
sstrm << number();