FGO自动化工具终极指南:如何快速实现高效刷本与智能资源管理
2025/12/18 7:18:59
在许多flex或bison程序中,符号表起着至关重要的作用,它用于跟踪输入中使用的名称。下面我们将从一个简单的索引生成程序开始,逐步深入探讨如何利用符号表来实现不同功能,最后还会介绍一个较为实用的C语言交叉引用程序。
索引生成器的符号表用于记录每个单词及其出现的文件和行号。以下是索引生成器的声明部分代码:
/* fb2-4 text concordance */ %option noyywrap nodefault yylineno case-insensitive /* the symbol table */ %{ struct symbol { /* a word */ char *name; struct ref *reflist; }; struct ref { struct ref *next; char *filename; int flags; int lineno; }; /* simple symtab of fixed size */ #define NHASH 9997 struct symbol symtab[NHASH]; struct symbol *lookup(char*); void addref(int, char*, char*,int); char *curfilename; /* name of current input f