From 54ff482d8fb76e8facd8b4b1fb871de9440b0608 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sun, 20 Mar 2016 09:56:17 -0500 Subject: [PATCH] Lemon update 2010-02-17 20:31:32 on branch lemon-update-2010 - Report error if the grammar has multiple %type lines for the same nonterminal. --- tools/lemon/lemon.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tools/lemon/lemon.c b/tools/lemon/lemon.c index f0a2e06e5..e21a4cffc 100644 --- a/tools/lemon/lemon.c +++ b/tools/lemon/lemon.c @@ -2291,10 +2291,20 @@ to follow the previous rule."); psp->errorcnt++; psp->state = RESYNC_AFTER_DECL_ERROR; }else{ - struct symbol *sp = Symbol_new(x); - psp->declargslot = &sp->datatype; - psp->insertLineMacro = 0; - psp->state = WAITING_FOR_DECL_ARG; + struct symbol *sp = Symbol_find(x); + if((sp) && (sp->datatype)){ + ErrorMsg(psp->filename,psp->tokenlineno, + "Symbol %%type \"%s\" already defined", x); + psp->errorcnt++; + psp->state = RESYNC_AFTER_DECL_ERROR; + }else{ + if (!sp){ + sp = Symbol_new(x); + } + psp->declargslot = &sp->datatype; + psp->insertLineMacro = 0; + psp->state = WAITING_FOR_DECL_ARG; + } } break; case WAITING_FOR_PRECEDENCE_SYMBOL: