📄 scanner.h
字号:
/****************************************************/
/* File: scanner.h */
/* The scanner implementation for the C- compiler */
/* Xiang Cui (sean) */
/* 230030782 */
/****************************************************/
#include <iostream>
#include <iomanip.h>
#include <string>
#include <map>
#include <fstream>
#include "stdlib.h"
#include "stdio.h"
#include "string.h"
#include "ctype.h"
typedef enum
/* book-keeping tokens */
{ERROR,ENDFILE,
/* keywords */
ELSE,IF,INT,RETURN,VOID,WHILE,
/* multicharacter tokens */
ID,NUM,
/* special symbols */
PLUS,MINUS,TIMES,DIV,LT,LTEQ,GT,GTEQ,EQ,NEQ,ASSIGN,SEMI,
COMMA,LPAREN,RPAREN,LSQR,RSQR,LCRLY,RCRLY,LCMNT,RCMNT
} TokenType;
/* states in scanner DFA */
typedef enum
{ START,INNUM,INID,DONE,INLT,INGT,INEQ,INNEQ,INSLASH,INLCMNT,INRCMNT,ERR}
StateType;
class Myscanner
{
public:
Myscanner(const char *);
TokenType scan(); /*scan procedure*/
void printToken(TokenType token, string tokenString);/*print out tokens*/
TokenType reservedLookup (string str);/*look up the Keywords table*/
string tokens;
int lineno;
ifstream sf;//source file
private:
bool save;
char c;
StateType state;
TokenType currentToken;
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -