diff options
Diffstat (limited to 'src/gram.y')
-rw-r--r-- | src/gram.y | 50 |
1 files changed, 37 insertions, 13 deletions
@@ -1,6 +1,6 @@ %{ /* This file is part of mailfromd. - Copyright (C) 2005, 2006, 2007 Sergey Poznyakoff + Copyright (C) 2005, 2006, 2007, 2008 Sergey Poznyakoff 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 @@ -281,7 +281,7 @@ static void register_macro(enum smtp_state tag, const char *macro); %} %error-verbose -%expect 26 +%expect 27 %union { struct literal *literal; @@ -341,12 +341,14 @@ static void register_macro(enum smtp_state tag, const char *macro); %token <locus> SWITCH CASE DEFAULT CONST %token <locus> FOR LOOP WHILE BREAK NEXT ARGCOUNT %token <literal> STRING CODE XCODE -%token <literal> SYMBOL VARIABLE IDENTIFIER +%token <literal> SYMBOL IDENTIFIER %token <number> ARG NUMBER BACKREF %token <builtin> BUILTIN BUILTIN_PROC BUILTIN_P %token <locus> OR AND EQ NE LT LE GT GE NOT LOGAND LOGOR LOGXOR LOGNOT %token <function> FUNCTION FUNCTION_PROC FUNCTION_P %token <type> TYPE +%token <var> VARIABLE +%token BOGUS %left CONCAT %left OR @@ -567,6 +569,18 @@ vardecl : TYPE IDENTIFIER constdecl : CONST IDENTIFIER expr { struct value value; + struct variable *pvar; + + /* FIXME: This is necessary because constants can be + referred to the same way as variables. */ + if (pvar = variable_lookup($2->text)) { + parse_warning(_("Constant name `%s' clashes with a variable name"), + $2->text); + parse_warning_locus(&pvar->locus, + _("This is the location of the " + "previous definition")); + } + if (optimization_level) optimize($3); @@ -1025,7 +1039,8 @@ value : STRING } | IDENTIFIER { - struct value *value_ptr = constant_lookup($1->text); + const struct value *value_ptr = + constant_lookup_value($1->text); if (value_ptr) $$ = *value_ptr; else { @@ -1655,17 +1670,15 @@ arglist : expr variable : VARIABLE { - $$ = variable_lookup($1->text); - if (!$$) { - parse_error(_("Variable %s is not defined"), - $1->text); - YYERROR; - } - add_xref($$, get_locus()); + add_xref($1, get_locus()); } - ; + | BOGUS + { + YYERROR; + } + ; -catch : CATCH catchlist DO +catch : CATCH catchlist DO { $<tie_in>$ = inner_context; inner_context = context_catch; catch_nesting++; } @@ -3440,6 +3453,7 @@ vardecl(const char *name, data_type_t type, storage_class_t sc, struct locus *loc) { struct variable *var; + const struct constant *cptr; if (type == dtype_unspecified) { parse_error(_("Cannot define variable of unspecified type")); @@ -3516,6 +3530,16 @@ vardecl(const char *name, data_type_t type, storage_class_t sc, } } + /* FIXME: This is necessary because constants can be + referred to the same way as variables. */ + if (cptr = constant_lookup(name)) { + parse_warning(_("Variable name `%s' clashes with a constant name"), + name); + parse_warning_locus(&cptr->locus, + _("This is the location of the " + "previous definition")); + } + var->type = type; var->storage_class = sc; switch (sc) { |