From 0a1ed1b9701552b09379f142e60e1364390f4b69 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 17 Feb 2010 15:35:15 -0500 Subject: [PATCH] Lemon fix: don't let grammar define the same nonterminal %type more than once. --- misc/lemon.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/misc/lemon.c b/misc/lemon.c index a5fa3388..31efa0ea 100644 --- a/misc/lemon.c +++ b/misc/lemon.c @@ -2357,10 +2357,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: