2009-07-26 10:07:13 +00:00
|
|
|
#include "ASTNode.h"
|
|
|
|
|
2009-07-27 00:23:49 +00:00
|
|
|
/* ASTNodeList */
|
|
|
|
void ASTNodeList::removeLast()
|
|
|
|
{
|
|
|
|
list_t::iterator it = m_nodes.end();
|
|
|
|
--it;
|
|
|
|
m_nodes.erase(it);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ASTNodeList::removeFirst()
|
|
|
|
{
|
2019-10-04 15:56:24 -07:00
|
|
|
m_nodes.erase(m_nodes.cbegin());
|
2009-07-27 00:23:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-03 23:13:50 +00:00
|
|
|
/* ASTUnary */
|
|
|
|
const char* ASTUnary::op_str() const
|
|
|
|
{
|
|
|
|
static const char* s_op_strings[] = {
|
2011-01-01 02:31:31 -08:00
|
|
|
"+", "-", "~", "not "
|
2009-08-03 23:13:50 +00:00
|
|
|
};
|
|
|
|
return s_op_strings[op()];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-27 00:23:49 +00:00
|
|
|
/* ASTBinary */
|
|
|
|
const char* ASTBinary::op_str() const
|
|
|
|
{
|
|
|
|
static const char* s_op_strings[] = {
|
2009-08-03 23:13:50 +00:00
|
|
|
".", " ** ", " * ", " / ", " // ", " % ", " + ", " - ",
|
2019-10-10 11:47:48 -07:00
|
|
|
" << ", " >> ", " & ", " ^ ", " | ", " and ", " or ", " @ ",
|
2010-08-31 23:17:38 -07:00
|
|
|
" += ", " -= ", " *= ", " /= ", " %= ", " **= ", " <<= ",
|
2019-10-10 11:47:48 -07:00
|
|
|
" >>= ", " &= ", " ^= ", " |= ", " //= ", " @= ",
|
2009-07-27 00:23:49 +00:00
|
|
|
};
|
|
|
|
return s_op_strings[op()];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-26 10:07:13 +00:00
|
|
|
/* ASTCompare */
|
|
|
|
const char* ASTCompare::op_str() const
|
|
|
|
{
|
|
|
|
static const char* s_cmp_strings[] = {
|
2010-08-31 23:17:38 -07:00
|
|
|
" < ", " <= ", " == ", " != ", " > ", " >= ", " in ", " not in ", " is ", " is not ",
|
2009-07-26 10:07:13 +00:00
|
|
|
"<EXCEPTION MATCH>", "<BAD>"
|
|
|
|
};
|
2009-07-27 00:23:49 +00:00
|
|
|
return s_cmp_strings[op()];
|
2009-07-26 10:07:13 +00:00
|
|
|
}
|
2010-12-20 22:58:44 -08:00
|
|
|
|
2011-01-01 02:31:31 -08:00
|
|
|
|
|
|
|
/* ASTKeyword */
|
|
|
|
const char* ASTKeyword::word_str() const
|
|
|
|
{
|
|
|
|
static const char* s_word_strings[] = {
|
2019-10-08 13:12:31 -07:00
|
|
|
"pass", "break", "continue"
|
2011-01-01 02:31:31 -08:00
|
|
|
};
|
|
|
|
return s_word_strings[key()];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-20 22:58:44 -08:00
|
|
|
/* ASTBlock */
|
|
|
|
void ASTBlock::removeLast()
|
|
|
|
{
|
|
|
|
list_t::iterator it = m_nodes.end();
|
|
|
|
--it;
|
|
|
|
m_nodes.erase(it);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ASTBlock::removeFirst()
|
|
|
|
{
|
2019-10-04 15:56:24 -07:00
|
|
|
m_nodes.erase(m_nodes.begin());
|
2010-12-20 22:58:44 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
const char* ASTBlock::type_str() const
|
|
|
|
{
|
|
|
|
static const char* s_type_strings[] = {
|
2011-10-01 19:40:34 -07:00
|
|
|
"", "if", "else", "elif", "try", "CONTAINER", "except",
|
2012-06-03 20:39:45 -07:00
|
|
|
"finally", "while", "for", "with",
|
2010-12-20 22:58:44 -08:00
|
|
|
};
|
2010-12-24 20:25:55 -08:00
|
|
|
return s_type_strings[blktype()];
|
2010-12-20 22:58:44 -08:00
|
|
|
}
|