Skip to content

Commit

Permalink
Support negative defined values (#3001)
Browse files Browse the repository at this point in the history
  • Loading branch information
alkino authored Jul 18, 2024
1 parent b925999 commit c48d7d5
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions src/nmodl/parse1.ypp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c48d7d5

Please sign in to comment.