shithub: scc

ref: 7d00111f794d7d658e9faeacdc136b2b28f80461
dir: /keyword.c/

View raw version
#include <stddef.h>

#include "tokens.h"
#include "symbol.h"


static struct keyword {
	char *str;
	unsigned char tok;
} keywords [] = {"auto", AUTO,
		 "break", BREAK,
		 "_Bool", CHAR,
		 "case", CASE,
		 "char", CHAR,
		 "const", CONST,
		 "continue", CONTINUE,
		 "default", DEFAULT,
		 "do", DO,
		 "double", DOUBLE,
		 "else", ELSE,
		 "enum", ENUM,
		 "extern", EXTERN,
		 "float", FLOAT,
		 "for", FOR,
		 "goto", GOTO,
		 "if", IF,
		 "int", INT,
		 "long", LONG,
		 "register", REGISTER,
		 "restricted", RESTRICT,
		 "return", RETURN,
		 "short", SHORT,
		 "signed", SIGNED,
		 "sizeof", SIZEOF,
		 "static", STATIC,
		 "struct", STRUCT,
		 "switch", SWITCH,
		 "typedef", TYPEDEF,
		 "union", UNION,
		 "unsigned", UNSIGNED,
		 "void", VOID,
		 "volatile", VOLATILE,
		 "while", WHILE,
		 NULL, 0,
};

void
init_keywords(void)
{
	register struct keyword *bp;
	register struct symbol *sym;

	for (bp = keywords; bp->str; bp++) {
		sym = install(bp->str);
		sym->tok = bp->tok;
		sym->ns = NS_KEYWORD;
	}
	new_ctx();
}