32 #include "esql_grammar.h" 39 #define MAX_LONGS_ALLOWED 1 94 #define TOK_AUTO "auto" 95 #define TOK_CONST "const" 96 #define TOK_EXTERN "extern" 97 #define TOK_CHAR "char" 98 #define TOK_DOUBLE "double" 99 #define TOK_FLOAT "float" 100 #define TOK_INT "int" 101 #define TOK_LONG "long" 102 #define TOK_REGISTER "register" 103 #define TOK_SHORT "short" 104 #define TOK_STATIC "static" 105 #define TOK_TYPEDEF "typedef" 106 #define TOK_UNSIGNED "unsigned" 107 #define TOK_VOID "void" 108 #define TOK_VOLATILE "volatile" 109 #define TOK_INVALID "whoknows" 139 switch (storage_class)
215 LINK *clone_start, *clone_end;
217 for (; decl_chain; decl_chain = decl_chain->
next)
220 if (clone_start ==
NULL)
231 old_etype = decl_chain->
etype;
241 sprintf (tmp,
" = { %s, \"\" }", old_etype->
decl.
d.
num_ele);
245 sprintf (tmp,
" = { ((%s)+7)/8, \"\" }", old_etype->
decl.
d.
num_ele);
250 if (decl_chain->
type == old_etype)
257 for (parent = decl_chain->
type; parent->
next != old_etype; parent = parent->
next)
262 decl_chain->
etype = parent;
268 decl_chain->
type = clone_start;
275 decl_chain->
etype = clone_end;
288 decl_chain->
type->
tdef = decl_chain;
308 for (pnew = sym; pnew; pnew = next)
365 for (sym = sym_chain; sym; sym = sym->
next)
384 for (sdef = struct_chain; sdef; sdef = sdef->
next)
422 new_scope = pp_current_name_scope ? (pp_current_name_scope + 1) : pp_name_scope_base;
424 if (new_scope >= pp_name_scope_limit)
426 int nframes = (int) (pp_name_scope_limit - pp_name_scope_base);
427 SCOPE *
const realloc_pp_name_scope_base
429 if (realloc_pp_name_scope_base ==
NULL)
437 pp_name_scope_base = realloc_pp_name_scope_base;
440 pp_name_scope_limit = pp_name_scope_base + nframes +
NFRAMES;
441 if (pp_current_name_scope)
443 pp_current_name_scope = pp_name_scope_base + nframes - 1;
445 new_scope = pp_name_scope_base + nframes;
454 pp_current_name_scope = new_scope;
467 SCOPE *current, *next;
480 if (pp_current_name_scope == pp_name_scope_base)
486 next = pp_current_name_scope - 1;
500 pp_current_name_scope = next;
517 if (pp_current_name_scope)
535 memset (pp_name_scope_base, 0,
NFRAMES *
sizeof (
SCOPE));
536 pp_name_scope_limit = pp_name_scope_base +
NFRAMES;
537 pp_current_name_scope =
NULL;
541 memset (pp_spec_scope_base, 0, NFRAMES *
sizeof (
SPEC_STATE));
542 pp_spec_scope_limit = pp_spec_scope_base +
NFRAMES;
543 pp_current_spec_scope =
NULL;
557 while (pp_current_name_scope)
562 while (pp_current_spec_scope)
581 p = pp_current_spec_scope ? (pp_current_spec_scope + 1) : pp_spec_scope_base;
583 if (p >= pp_spec_scope_limit)
585 int nframes = (int) (pp_spec_scope_limit - pp_spec_scope_base);
588 if (realloc_pp_spec_scope_base ==
NULL)
596 pp_spec_scope_base = realloc_pp_spec_scope_base;
599 pp_spec_scope_limit = pp_spec_scope_base + nframes +
NFRAMES;
600 if (pp_current_spec_scope)
602 pp_current_spec_scope = pp_spec_scope_base + nframes - 1;
604 p = pp_spec_scope_base + nframes;
617 pp_current_spec_scope =
p;
629 pp_current_spec_scope = (pp_current_spec_scope == pp_spec_scope_base ?
NULL : (pp_current_spec_scope - 1));
665 return pp_current_spec_scope->
spec;
1017 for (q = spec; q->
next; q = q->
next)
1395 for (; decl_chain; decl_chain = decl_chain->
next)
void *(* add_symbol)(HASH_TAB *tbl, void *sym)
SYMBOL * pp_findsym(SYMTAB *symtab, unsigned char *name)
unsigned char is_volatile
int vs_append(varstring *vstr, const char *suffix)
unsigned char is_unsigned
varstring * vs_new(varstring *vstr)
SYMBOL * pp_new_symbol(const char *name, int scope)
ESQL_TRANSLATE_TABLE esql_Translate_table
static void pp_print_decl(SYMBOL *sym, varstring *buf, int preechoed)
LINK * pp_clone_type(LINK *tchain, LINK **endp)
LINK * pp_current_type_spec(void)
void pp_print_syms(FILE *fp)
struct status_field fields[FIELD_LAST+1]
void pp_add_initializer(SYMBOL *sym)
void esql_yyverror(const char *,...)
void pp_add_type_adj(int adj)
int vs_prepend(varstring *vstr, const char *prefix)
void pp_do_enum(SYMBOL *sym)
const char * pp_get_msg(int msg_set, int msg_num)
void pp_finish_whenever_scope(WHENEVER_SCOPE *scope, WHENEVER_SCOPE *new_scope)
int vs_strcpy(varstring *vstr, const char *str)
void pp_print_specs(LINK *link)
int vs_sprintf(varstring *vstr, const char *fmt,...)
const char * pp_type_str(LINK *link)
static LINK * pp_new_type_spec(void)
void pp_print_decls(SYMBOL *decl_chain, int preechoed)
char * vs_str(varstring *vstr)
void pp_remove_cursors_from_table(CURSOR *chain)
int recognizing_typedef_names
static SPEC_STATE * pp_current_spec_scope
static void pp_remove_structdefs_from_table(STRUCTDEF *struct_chain)
void vs_free(varstring *vstr)
enum when_action WHEN_ACTION
static SPEC_STATE * pp_spec_scope_base
void(* tr_whenever)(WHEN_CONDITION condition, WHEN_ACTION action, const char *name)
#define IS_PSEUDO_TYPE(p)
static SCOPE * pp_name_scope_base
int pp_recognizing_typedef_names
void pp_disallow_storage_classes(void)
static SCOPE * pp_name_scope_limit
void pp_decl_finish(void)
void pp_make_typedef_names_visible(int sense)
void pp_discard_link(LINK *p)
void(* remove_symbol)(HASH_TAB *tbl, void *sym)
void pp_push_spec_scope(void)
#define MAX_LONGS_ALLOWED
void pp_reset_current_type_spec(void)
void pp_add_whenever_to_scope(WHEN_CONDITION when, WHEN_ACTION action, char *name)
unsigned char is_register
void vs_clear(varstring *vstr)
void pp_discard_cursor_chain(CURSOR *chain)
void pp_discard_link_chain(LINK *p)
void pp_discard_structdef(STRUCTDEF *sdef)
enum when_condition WHEN_CONDITION
void pp_print_cursors(FILE *fp)
static SCOPE * pp_current_name_scope
void pp_discard_symbol(SYMBOL *sym)
static void pp_set_class_bit(int storage_class, LINK *p)
void pp_add_spec_to_decl(LINK *p_spec, SYMBOL *decl_chain)
void pp_add_typedefed_spec(LINK *spec)
void pp_add_struct_spec(STRUCTDEF *sdef)
STRUCTDEF * pp_new_pseudo_def(SPECIFIER_NOUN type, const char *subscript)
int vs_strcat(varstring *vstr, const char *str)
#define free_and_init(ptr)
void pp_add_cursor_to_scope(CURSOR *cursor)
void pp_push_name_scope(void)
void pp_add_type_noun(int type)
void pp_pop_spec_scope(void)
void pp_init_whenever_scope(WHENEVER_SCOPE *scope, WHENEVER_SCOPE *old_scope)
void pp_add_storage_class(int sc)
char * strdup(const char *str)
void esql_yyredef(char *)
static void pp_print_link(LINK *p, varstring *buf, int context, int preechoed)
int pp_the_same_type(LINK *p1, LINK *p2, int relax)
void pp_pop_name_scope(void)
static SPEC_STATE * pp_spec_scope_limit
void pp_add_symbols_to_table(SYMBOL *sym)
int pp_disable_varchar_length
void pp_discard_structdef_chain(STRUCTDEF *sdef)
void pp_discard_symbol_chain(SYMBOL *sym)
void pp_remove_symbols_from_table(SYMBOL *sym_chain)
const unsigned char * type_string