1 #include "parsetree/ParseTree.h"
7 #include "utils/DotPrinter.h"
12 if(type != Type::Integer)
return true;
15 const long long int x = std::strtol(value.c_str(), &endptr, 10);
16 const long long int INT_MAX = 2147483647ULL;
17 if(errno == ERANGE || *endptr !=
'\0')
return false;
18 if(x > INT_MAX && !isNegative_)
return false;
19 if(x > INT_MAX + 1 && isNegative_)
return false;
25 std::string
Operator::to_string()
const {
38 case T::LessThanOrEqual:
40 case T::GreaterThanOrEqual:
77 os <<
"(Id " << name <<
")";
82 std::string formattedValue{value};
83 std::replace(formattedValue.begin(), formattedValue.end(),
'\"',
' ');
84 os <<
"(Literal " << Type_to_string(type,
"??") <<
" " << formattedValue <<
")";
89 os <<
"(Modifier " << Type_to_string(modty,
"??") <<
")";
94 os <<
"(BasicType " << Type_to_string(type,
"??") <<
")";
122 os << Type_to_string(type,
"Unknown");
123 for(size_t i = 0; i < num_args; ++i) {
125 if(args[i] ==
nullptr) {
140 int Node::printDotRecursive(DotPrinter& dp,
const Node& node)
const {
141 const int id = dp
.id();
143 if(node.is_marked()) {
161 "fillcolor",
"lightblue"
173 if(child !=
nullptr) {
174 child_id = printDotRecursive(dp, *child);
181 "fillcolor",
"lightgrey",
194 DotPrinter dp
{os
, "35"};
196 printDotRecursive(dp, *
this);
201 std::ostream& operator<<(std::ostream& os,
Node const& n) {
return n
.print(os
); }