lab3.h

来自「c—语言的句法分析器。读入一个C--语言程序」· C头文件 代码 · 共 84 行

H
84
字号
/*
 * 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 + =
减小字号Ctrl + -
显示快捷键?