From c48d7d5bd099d8f1917702e8022af9bb725bb8be Mon Sep 17 00:00:00 2001 From: Nicolas Cornu Date: Thu, 18 Jul 2024 16:45:23 +0200 Subject: [PATCH] Support negative defined values (#3001) --- src/nmodl/parse1.ypp | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/nmodl/parse1.ypp b/src/nmodl/parse1.ypp index 443825a1ea..2d94253d41 100755 --- a/src/nmodl/parse1.ypp +++ b/src/nmodl/parse1.ypp @@ -172,14 +172,26 @@ model: MODEL line line: {$$ = inputline();} ; define1: DEFINE1 NAME INTEGER - /* all subsequent occurences of NAME will be replaced - by integer during parseing. See 'integer:' */ - { Symbol *sp = SYM($2); - if (sp->subtype) - diag(sp->name, " used before DEFINEed"); - sp->u.str = STR($3); - sp->type = DEFINEDVAR; - deltokens($1, $3);} + /* all subsequent occurences of NAME will be replaced + by integer during parseing. See 'integer:' */ + { + Symbol *sp = SYM($2); + if (sp->subtype) + diag(sp->name, " used before DEFINEed"); + sp->u.str = STR($3); + sp->type = DEFINEDVAR; + deltokens($1, $3); + } + | DEFINE1 NAME '-' INTEGER + { + Symbol *sp = SYM($2); + if (sp->subtype) + diag(sp->name, " used before DEFINEed"); + Sprintf(buf, "-%s", STR($4)); + sp->u.str = stralloc(buf, nullptr); + sp->type = DEFINEDVAR; + deltokens($1, $4); + } | DEFINE1 error {myerr("syntax: DEFINE name integer");} ; Name: NAME