本文整理汇总了C++中TokenPtr::get_column方法的典型用法代码示例。如果您正苦于以下问题:C++ TokenPtr::get_column方法的具体用法?C++ TokenPtr::get_column怎么用?C++ TokenPtr::get_column使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TokenPtr
的用法示例。
在下文中一共展示了TokenPtr::get_column方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: translate
SymbolPtr CodeBlock::translate(TokenPtr token) {
if (token->get_token() == MP_ID) {
string search_lexeme = token->get_lexeme();
unsigned int search_level = this->get_nesting_level();
SymbolListPtr filtered_data = this->get_analyzer()->get_symtable()->data_in_scope_at(search_lexeme, search_level);
if (this->check_filter_size(filtered_data)) {
SymbolPtr found = *filtered_data->begin();
found->set_col(token->get_column());
found->set_row(token->get_line());
return found;
} else {
SymbolListPtr global_data = this->get_analyzer()->get_symtable()->data_in_scope_at(search_lexeme, 0);
if (this->check_filter_size(global_data)) {
SymbolPtr found = *global_data->begin();
found->set_col(token->get_column());
found->set_row(token->get_line());
return found;
} else {
if (global_data == nullptr) {
report_error_lc("Semantic Error", "ID '" + search_lexeme + "' not found",
token->get_line(), token->get_column());
} else {
report_error("Semantic Error", "ID '" + search_lexeme + "' redefined as...");
for (auto it = global_data->begin(); it != global_data->end(); it++) {
SymDataPtr dptr = static_pointer_cast<SymData>(*it);
report_error_lc("Definition @", (*it)->get_symbol_name() + " as " + var_type_to_string(dptr->get_var_type()), (*it)->get_row(), (*it)->get_col());
}
}
this->valid = false;
return nullptr;
}
}
} else if (token->get_token() == MP_INT_LITERAL) {
SymbolPtr s = SymbolPtr(new SymConstant(token->get_lexeme(), INTEGER_LITERAL));
s->set_row(token->get_line());
s->set_col(token->get_column());
return s;
} else if (token->get_token() == MP_STRING_LITERAL) {
SymbolPtr s = SymbolPtr(new SymConstant(token->get_lexeme(), STRING_LITERAL));
s->set_row(token->get_line());
s->set_col(token->get_column());
return s;
} else if (token->get_token() == MP_FLOAT_LITERAL) {
SymbolPtr s = SymbolPtr(new SymConstant(token->get_lexeme(), FLOATING_LITERAL));
s->set_row(token->get_line());
s->set_col(token->get_column());
return s;
} else if (token->get_token() == MP_TRUE) {
SymbolPtr s = SymbolPtr(new SymConstant(token->get_lexeme(), BOOLEAN_LITERAL_T));
s->set_row(token->get_line());
s->set_col(token->get_column());
return s;
} else if (token->get_token() == MP_FALSE) {
SymbolPtr s = SymbolPtr(new SymConstant(token->get_lexeme(), BOOLEAN_LITERAL_F));
s->set_row(token->get_line());
s->set_col(token->get_column());
return s;
} else if (token->get_token() == MP_LEFT_PAREN) {
SymbolPtr s = SymbolPtr(new SymConstant(token->get_lexeme(), LPAREN));
s->set_row(token->get_line());
s->set_col(token->get_column());
return s;
} else if (token->get_token() == MP_RIGHT_PAREN) {
SymbolPtr s = SymbolPtr(new SymConstant(token->get_lexeme(), RPAREN));
s->set_row(token->get_line());
s->set_col(token->get_column());
return s;
} else if (token->get_token() == MP_PLUS) {
SymbolPtr s = SymbolPtr(new SymConstant(token->get_lexeme(), ADD));
s->set_row(token->get_line());
s->set_col(token->get_column());
return s;
} else if (token->get_token() == MP_MINUS) {
SymbolPtr s = SymbolPtr(new SymConstant(token->get_lexeme(), SUB));
s->set_row(token->get_line());
s->set_col(token->get_column());
return s;
} else if (token->get_token() == MP_MULT) {
SymbolPtr s = SymbolPtr(new SymConstant(token->get_lexeme(), MUL));
s->set_row(token->get_line());
s->set_col(token->get_column());
return s;
} else if (token->get_token() == MP_DIV) {
SymbolPtr s = SymbolPtr(new SymConstant(token->get_lexeme(), DIV));
s->set_row(token->get_line());
s->set_col(token->get_column());
return s;
} else if (token->get_token() == MP_DIV_KW) {
SymbolPtr s = SymbolPtr(new SymConstant(token->get_lexeme(), DIV));
s->set_row(token->get_line());
s->set_col(token->get_column());
return s;
} else if (token->get_token() == MP_MOD_KW) {
SymbolPtr s = SymbolPtr(new SymConstant(token->get_lexeme(), MOD));
s->set_row(token->get_line());
s->set_col(token->get_column());
return s;
} else if (token->get_token() == MP_AND) {
SymbolPtr s = SymbolPtr(new SymConstant(token->get_lexeme(), AND));
s->set_row(token->get_line());
//.........这里部分代码省略.........