Website Summary Files Commits Branches @commit @diff @stats
path: root / JSImpl / src / ASTPrinter.cpp
diff options
context:
space:
mode:
1 files changed, 3 insertions, 32 deletions
-rw-r--r--JSImpl/src/ASTPrinter.cpp35
diff --git a/JSImpl/src/ASTPrinter.cpp b/JSImpl/src/ASTPrinter.cpp
index d8f5ff8..85bd9ab 100644
--- a/JSImpl/src/ASTPrinter.cpp
+++ b/JSImpl/src/ASTPrinter.cpp
@@ -36,12 +36,13 @@ void Print(std::ostream& os, ASTPrinter &printer, const char* name, const IPLVec
void Print(std::ostream& os, ASTPrinter &printer, const char* name, const IPLVector<IPLString>& list, bool isLast)
{
- os << "\"" << name << "\" : [ \n";
+ os << "\"" << name << "\" : [";
for (auto i = 0; i < list.size(); ++i)
{
+ os << "\"" << list[i] << "\"";
if (i + 1 != list.size())
{
- os << list[i] << ",";
+ os << ",";
}
}
os << "]";
@@ -85,26 +86,6 @@ void Print<const IPLString&>(std::ostream& os, ASTPrinter &printer, const char*
os << "\n";
}
-IPLString AsString(LiteralType type)
-{
- switch (type)
- {
- case LiteralType::Number:
- return "Number";
- case LiteralType::String:
- return "String";
- case LiteralType::Boolean:
- return "Boolean";
- case LiteralType::Null:
- return "Null";
- case LiteralType::Undefined:
- return "Undefined";
- default:
- break;
- }
- return "Undefined";
-}
-
std::ostream& operator<<(std::ostream& os, const TokenType& t)
{
switch (t)
@@ -203,16 +184,6 @@ std::ostream& operator<<(std::ostream& os, const TokenType& t)
return os;
}
-void ASTPrinter::Visit(LiteralExpression* e)
-{
- os << "{\n" << "\"ExpresionType\": \"LiteralExpression\"," << '\n';
- Print(os, *this, "BooleanValue", e->GetBooleanValue(), false);
- Print(os, *this, "LiteralType", AsString(e->GetLiteralType()), false);
- Print(os, *this, "NumValue", e->GetNumValue(), false);
- Print(os, *this, "StringValue", e->GetStringValue(), true);
- os << "}\n";
-}
-
#define MEMBERS_COUNT(type, name, def) ++membersCount;
#define VISIT_MEMBER(type, name, def) ++currentVisitCount; Print(os, *this, #name, e->Get##name(), currentVisitCount == membersCount);;