token.h

来自「Compiler with latex grammar」· C头文件 代码 · 共 53 行

H
53
字号
#ifndef TOKEN_H
#define TOKEN_H

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <string>

using namespace std;

class Token{
private:
	int tipo;
	string lexema;
	int linea;
    
public:
	Token()
	{
		tipo=-1;
		linea = -1;
	}
	Token(int tip, string lexe,int lin){
		tipo=tip;
		lexema=lexe;
		linea=lin;
	}
	int getTipo()
	{	return tipo;	}
	string getLexema()
	{	return lexema;	}
	int getLinea()
	{	return linea;	}
	bool operator < ( Token &tmp )
	{
		return tmp.getLexema().compare(lexema) < 0 ;
	}
	
	void Imprimir()
	{
		cout<<"Token :"<<lexema;
		
		if( tipo>=100 && tipo<500 )
			cout<<"\t Palabra Reservada"<<endl;
		else if( tipo>=500 )
			cout<<"\t Simbolos Puntuacion"<<endl;
		else
			cout<<"\t Otro "<<endl;
	}
};

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?