小编Mel*_*ley的帖子

C中的符号表

我目前正在开发一种执行模式匹配的静态分析工具.我正在使用Flex生成词法分析器,我编写了代码来管理符号表.我对C不太熟悉,所以我决定将符号表实现为线性链表.

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

struct symtab {
   int id;
   char *name;
   int type;
   struct symtab *next;
};

enum types {
   KEYWORD = 1,
   CONSTANT,
   IDENTIFIER,
   OPERATOR,
   DELIMITER,
   WHITESPACE
};

struct symtab *last_entry(struct symtab *start)
{
   struct symtab *p;
   p = start;
   while(p -> next != NULL) {
      p = p -> next;
   }
   return p;
}

void add_entry(char* name, int type, struct symtab *start)
{
   struct symtab *new;
   new = last_entry(start);
   int id; …
Run Code Online (Sandbox Code Playgroud)

c linux symbol-table

4
推荐指数
1
解决办法
7117
查看次数

标签 统计

c ×1

linux ×1

symbol-table ×1