Pretty print THIS_TOKEN and SUPER_TOKEN

Internally the special THIS_TOKEN("@") and SUPER_TOKEN("#") are used
to represent the special `this` and `super` keywords in a component
name.

When printing an identifier replace the tokens with their keywords.
This generates nicer error and debug messages.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2022-09-25 15:45:33 +02:00
parent 862b118098
commit 7188f7b210
1 changed files with 6 additions and 1 deletions

View File

@ -87,7 +87,12 @@ ostream& operator<< (ostream&out, const index_component_t&that)
ostream& operator<< (ostream&out, const name_component_t&that)
{
out << that.name.str();
if (that.name == THIS_TOKEN)
out << "this";
else if (that.name == SUPER_TOKEN)
out << "super";
else
out << that.name.str();
typedef std::list<index_component_t>::const_iterator index_it_t;
for (index_it_t idx = that.index.begin()