diff --git a/tools/qfcc/include/expr.h b/tools/qfcc/include/expr.h index cf353048f..83968c2dc 100644 --- a/tools/qfcc/include/expr.h +++ b/tools/qfcc/include/expr.h @@ -51,7 +51,6 @@ typedef enum { #include "tools/qfcc/include/expr_names.h" ex_count, ///< number of valid expression types } expr_type; -#undef EX_EXPR /** Binary and unary expressions. diff --git a/tools/qfcc/include/expr_names.h b/tools/qfcc/include/expr_names.h index 411940139..6061104fa 100644 --- a/tools/qfcc/include/expr_names.h +++ b/tools/qfcc/include/expr_names.h @@ -70,4 +70,6 @@ EX_EXPR(multivec) ///< geometric algebra multivector (::ex_multivec_t) EX_EXPR(list) ///< non-invasive list of expressions (::ex_list_t) EX_EXPR(type) ///< type expression for generics +#undef EX_EXPR + ///@} diff --git a/tools/qfcc/include/sy_type_names.h b/tools/qfcc/include/sy_type_names.h new file mode 100644 index 000000000..2f47908ce --- /dev/null +++ b/tools/qfcc/include/sy_type_names.h @@ -0,0 +1,52 @@ +/* + sy_type_names.h + + Symbol type names + + Copyright (C) 2011 Bill Currie + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to: + + Free Software Foundation, Inc. + 59 Temple Place - Suite 330 + Boston, MA 02111-1307, USA + +*/ + +/** \defgroup qfcc_symtab_sy_type_names Symbol Types + \ingroup qfcc_symtab +*/ +///@{ + +#ifndef SY_TYPE +#define SY_TYPE(type) +#endif + +SY_TYPE(name) ///< just a name (referent tbd) +SY_TYPE(var) ///< symbol refers to a variable +SY_TYPE(const) ///< symbol refers to a constant +SY_TYPE(type) ///< symbol refers to a type +SY_TYPE(type_param) ///< symbol refers to a generic type parameter +SY_TYPE(expr) ///< symbol refers to an expression +SY_TYPE(func) ///< symbol refers to a function +SY_TYPE(class) ///< symbol refers to a class +SY_TYPE(convert) ///< symbol refers to a conversion function +SY_TYPE(macro) ///< symbol refers to a macro definition +SY_TYPE(namespace) ///< symbol refers to a namespace definition +SY_TYPE(list) + +#undef SY_TYPE + +///@} diff --git a/tools/qfcc/include/symtab.h b/tools/qfcc/include/symtab.h index 1867c7cd6..60d27c58d 100644 --- a/tools/qfcc/include/symtab.h +++ b/tools/qfcc/include/symtab.h @@ -48,19 +48,10 @@ typedef enum vis_e { vis_anonymous, } vis_t; -typedef enum { - sy_name, ///< just a name (referent tbd) - sy_var, ///< symbol refers to a variable - sy_const, ///< symbol refers to a constant - sy_type, ///< symbol refers to a type - sy_type_param, ///< symbol refers to a generic type parameter - sy_expr, ///< symbol refers to an expression - sy_func, ///< symbol refers to a function - sy_class, ///< symbol refers to a class - sy_convert, ///< symbol refers to a conversion function - sy_macro, ///< symbol refers to a macro definition - sy_namespace, ///< symbol refers to a namespace definition - sy_list, +#define SY_TYPE(type) sy_##type, +typedef enum : unsigned { +#include "tools/qfcc/include/sy_type_names.h" + sy_num_types ///< number of symtab types } sy_type_e; typedef struct symconv_s { diff --git a/tools/qfcc/source/dot_expr.c b/tools/qfcc/source/dot_expr.c index df2dcbc27..a958e82a4 100644 --- a/tools/qfcc/source/dot_expr.c +++ b/tools/qfcc/source/dot_expr.c @@ -62,7 +62,6 @@ const char *expr_names[] = #include "tools/qfcc/include/expr_names.h" 0 }; -#undef EX_EXPR const char * get_op_string (int op) diff --git a/tools/qfcc/source/expr_assign.c b/tools/qfcc/source/expr_assign.c index cb6322ab2..37462157e 100644 --- a/tools/qfcc/source/expr_assign.c +++ b/tools/qfcc/source/expr_assign.c @@ -109,6 +109,7 @@ is_lvalue (const expr_t *expr) case sy_macro: case sy_namespace: case sy_list: + case sy_num_types: break; } break; diff --git a/tools/qfcc/source/symtab.c b/tools/qfcc/source/symtab.c index 5e6310ec2..17140c9c1 100644 --- a/tools/qfcc/source/symtab.c +++ b/tools/qfcc/source/symtab.c @@ -52,25 +52,18 @@ ALLOC_STATE (symtab_t, symtabs); ALLOC_STATE (symbol_t, symbols); -static const char * const sy_type_names[] = { - "sy_name", - "sy_var", - "sy_const", - "sy_type", - "sy_type_param", - "sy_expr", - "sy_func", - "sy_class", - "sy_convert", - "sy_macro", +#define SY_TYPE(type) #type, +static const char * const sy_type_names[sy_num_types] = { +#include "tools/qfcc/include/sy_type_names.h" }; const char * symtype_str (sy_type_e type) { - if (type > sy_convert) - return ""; - return sy_type_names[type]; + if (type < sy_num_types) { + return sy_type_names[type]; + } + return ""; } symbol_t *