📄 globals.h
字号:
/****************************************************/
/* File: globals.h */
/* Global types and vars for C_Minus compiler */
/* must come before other include files */
/****************************************************/
#ifndef _GLOBALS_H_
#define _GLOBALS_H_
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
#define MAXRESERVED 6
/* MAXTOKENLEN is the maximum size of a token */
#define BUFLEN 256
extern FILE* source;
extern FILE* scan;//词法分析结果
extern FILE* stree;//分析树
extern FILE* parse;//语法分析结果
extern lineno;
extern int EchoSource;
extern int TraceScan;
extern int ParseError;
extern int Error;
static char lineBuf[BUFLEN]; /* holds the current line */
static int linepos = 0; /* current position in LineBuf */
static int bufsize = 0; /* current size of buffer string */
static int EOF_flag = FALSE; /* corrects ungetNextChar behavior on EOF */
static int tokenno=0;
#define NontmlTypeNum (arg_list_+1)//一共为39+1=40个~一定要注意括号!
#define GrammarNum 73
#define GrammarMaxLength 9
#define TmlTypeNum EMPTY-arg_list_//70-39=31个
#define GrammarTokenNum EMPTY//70+1=71个
typedef enum
{
program ,//0
declaration_list,
declaration_list_ ,
declaration,
declaration_ ,//
var_declaration,
//var_declaration_ ,
//type_specifier,
fun_declaration,
fun_declaration_ ,//
params,
param_list,
param_list_ ,
param,
param_,
compound_stmt,
local_declarations,
statement_list,
statement,
expression_stmt,
selection_stmt,
selection_stmt_,
iteration_stmt,
return_stmt,
return_stmt_,
expression,
var,
var_,
simple_expression,
simple_expression_,
relop,
additive_expression,
additive_expression_,
addop,
term,
term_,
mulop,
factor,
call,
args,
arg_list,
arg_list_//39
} NontmlType;//非终结符
typedef enum
/* book-keeping tokens */
{ENDFILE=NontmlTypeNum,ERROR,
/* reserved words */
IF,ELSE,INT,RETURN,VOID,WHILE,
/* multicharacter tokens */
ID,NUM,
/* special symbols */
ASSIGN,EQ,LT,GT,PLUS,MINUS,TIMES,OVER,LPAREN,RPAREN,SEMI,COMMA,LINDEX,RINDEX,LE,GE,LBRACE,RBRACE,NOEQ//
,EMPTY/*parsing tokens*/
} TokenType;
/*所有终极符,取自单词的TokenType的枚举定义,可参考globals.h头文件*/
typedef TokenType TmlType;
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -