⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lab3.h

📁 c—语言的句法分析器。读入一个C--语言程序
💻 H
字号:
/*
 * file : lab3.h
 *----------------------------------
 * headfile for lab3.l & lab3.y
 */
#ifndef LAB3_H_
#define LAB3_H_

#include <stdio.h>
#include <string.h>

#define HASHTABLESIZE 1511
#define BUCKETSIZE    211
#define SYMBOLSIZE    100
#define FUNCTIONSIZE  1009
#define BUFFERSIZE    100
#define BUFFINCREMENT 50

typedef struct {
    char *name;
    int  scope;
    int  type;
}symbol;

typedef struct {
    int type;      /* char type=CHAR char* type=CHAR+100 ... */
    int value;
    char *string;
    symbol *symadd;
}expr;

struct id_entry {
    char *id;
    struct id_entry *next;
};

struct sym_entry {
    symbol sym;
    struct sym_entry *next;    
};

struct table {
    int level;
    struct table *previous;
    struct sym_entry *buckets[BUCKETSIZE];
};

struct fun {
    char *funame;
    int retype;
    int count;
    int *type;
    struct fun *next;
};

struct buffer {
    int *temp;
    int size;
};

FILE *yyin;
int lineno;    /* number of line */
int debug;     /* debug flag */
int right;     /* error flag */
struct id_entry *id_hash_table[HASHTABLESIZE];
struct table *symboltable[SYMBOLSIZE];
struct table *globaltable;
int tablelen;           /* symboltable length */
int level;              /* nested depth */
struct fun *funtable[FUNCTIONSIZE];
struct buffer argtemp;  /* argument list buffer */
int typecount;
struct buffer arg_in;   /* argument check buffer */
int typecheck;

char *InsertID(char *name);
char *InsertFun(char *name, int returntype);
int LookUpFun(char *name);
struct table *MakeTable(struct table *previous, int level);
symbol *InsertSym(char *name, struct table *tp);
symbol *LookUp(char *name, struct table *tp);

#endif /* LAB3_H_ */

⌨️ 快捷键说明

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