--- /dev/null
+#include <stdlib.h>
+#include <string.h>
+#include "token.h"
+#include "lex.h"
+
+#define sizeof_a(_x) (sizeof(_x) / sizeof((_x)[0]))
+
+struct type_qualifier {
+ struct token *token;
+};
+
+const char *_type_qualifiers[] = {
+ "const",
+ "volatile",
+ "restrict",
+ NULL
+};
+
+#if 0
+struct translation_unit {
+ struct translation_unit *tunit;
+ struct external_declaration *edecl;
+};
+
+struct external_declaration {
+ external_declaration_type type;
+};
+
+struct function_definition {
+ struct external_declaration parent;
+};
+
+struct declaration {
+ struct external_declaration parent;
+};
+
+struct translation_unit *parse_translation_unit(void)
+{
+ struct translation_unit *tu;
+ struct token *tok;
+
+ tu = translation_unit_new();
+
+ if(tu) {
+ tu->edecx = parse_external_declaration(void);
+
+ if(lex_peek()) {
+ tu->tunit = parse_translation_unit();
+ }
+ }
+
+ return(tu);
+}
+
+struct external_declaration *parse_external_declaration(void)
+{
+ struct external_declaration *ed;
+
+ ed = (struct external_declaration*)parse_function_definition();
+
+ if(!ed) {
+ ed = (struct external_declaration*)parse_declaration();
+ }
+
+ return(ed);
+}
+#endif
+
+struct type_qualifier *type_qualifier_new(struct token *tok)
+{
+ struct type_qualifier *tq;
+
+ tq = malloc(sizeof(*tq));
+
+ if(tq) {
+ memset(tq, 0, sizeof(*tq));
+ tq->token = tok;
+ }
+
+ return(tq);
+}
+
+struct type_qualifier *parse_type_qualifier(void)
+{
+ struct type_qualifier *ret_val;
+ struct token *tok;
+ int pos;
+
+ pos = lex_getpos();
+ tok = lex_gettoken();
+ ret_val = NULL;
+
+ if(tok) {
+ switch(tok->type) {
+ case TOKEN_CONST:
+ case TOKEN_VOLATILE:
+ case TOKEN_RESTRICT:
+ ret_val = type_qualifier_new(tok);
+ break;
+
+ default:
+ lex_setpos(pos);
+ break;
+ }
+ }
+
+ return(ret_val);
+}