加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
token.h 1.71 KB
一键复制 编辑 原始数据 按行查看 历史
zpf 提交于 2023-03-24 11:14 . debug
#pragma once
namespace compiler
{
enum class token_type
{
type_name,
Operator,
variate,
assignment,
immediate_int,
immediate_float,
//Բ
l_parenthesis,
r_parenthesis,
//
l_square_brackets,
r_square_brackets,
//
l_brace,
r_brace,
For,
If,
Else,
While,
Return,
String,
stmt_end,
comma,
INVALID
};
std::ostream& operator<<(std::ostream& out, token_type& t)
{
switch (t)
{
case token_type:: type_name:
out << "type_name";break;
case token_type:: Operator:
out << "Operator";break;
case token_type:: variate:
out << "variate";break;
case token_type:: assignment:
out << "assignment";break;
case token_type:: immediate_int:
out << "immediate_int";break;
case token_type:: immediate_float:
out << "immediate_float";break;
case token_type:: l_parenthesis:
out << "l_parenthesis";break;
case token_type:: r_parenthesis:
out << "r_parenthesis";break;
case token_type:: l_square_brackets:
out << "l_square_brackets";break;
case token_type:: r_square_brackets:
out << "r_square_brackets";break;
case token_type:: l_brace:
out << "tl_brace";break;
case token_type:: r_brace:
out << "r_brace";break;
case token_type:: For:
out << "For";break;
case token_type:: If:
out << "If";break;
case token_type:: Else:
out << "Else";break;
case token_type::While:
out << "While";break;
case token_type::Return:
out << "Return";break;
case token_type::String:
out << "String";break;
case token_type::stmt_end:
out << "stmt_end";break;
case token_type::comma:
out << "comma";break;
default:
break;
}
return out;
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化