📄 codegenerator.cpp
字号:
// odeGenerator.cpp: implementation of the CodeGenerator class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "SymbolTable.h"
#include "CodeGenerator.h"
#include <iostream>
using namespace std;
extern SymbolTable symbol_table;
CodeGenerator::CodeGenerator()
{
}
void CodeGenerator::emit(const Token& tk) {
switch(tk.type) {
case '+': case '-': case '*': case '/':
cout << (char) tk.type;
break;
case Token::DIV:
cout << "DIV";
break;
case Token::MOD:
cout << "MOD";
break;
case Token::NUM:
cout << tk.value;
break;
case Token::ID:
cout << symbol_table.getLexeme(tk.value);
break;
case ';':
cout << endl;
break;
default:
cout << "(token: " << tk.type << ", value: " << tk.value;
break;
}//switch
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -