Skip to content

Commit 54d85a9

Browse files
committed
issue114 liberty colons round 2
Signed-off-by: James Cherry <[email protected]>
1 parent d889f03 commit 54d85a9

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

liberty/LibertyLex.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ HNAME ({PIN_NAME}|{BUS_NAME}|{MIXED_NAME})([\/.]({PIN_NAME}|{BUS_NAME}|{MIXED_NA
7070
/* default_operating_conditions : slow_100_3.00 ; */
7171
/* revision : 1.0.17; */
7272
/* default_wire_load : xc2v250-5_avg; */
73-
TOKEN ({ALPHA}|{DIGIT}|_)({ALPHA}|{DIGIT}|[._\-:])*
73+
TOKEN ({ALPHA}|{DIGIT}|_)({ALPHA}|{DIGIT}|[._\-])*
7474
/* bus_naming_style : %s[%d] ; */
7575
BUS_STYLE "%s"{BUS_LEFT}"%d"{BUS_RIGHT}
7676
PUNCTUATION [,\:;|(){}+*&!'=]

liberty/LibertyParse.yy

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,18 @@ group:
8686
{ sta::libertyGroupBegin($1, $3, $5); }
8787
statements '}' semi_opt
8888
{ $$ = sta::libertyGroupEnd(); }
89+
/* group(name1:name2) { stmts } */
90+
| KEYWORD '(' KEYWORD ':' KEYWORD ')' line '{'
91+
{ sta::LibertyAttrValueSeq *args = sta::makeLibertyGroupColonArgs($3, $5);
92+
sta::libertyGroupBegin($1, args, $7); }
93+
statements '}' semi_opt
94+
{ $$ = sta::libertyGroupEnd(); }
95+
/* group(name1:name2); */
96+
| KEYWORD '(' KEYWORD ':' KEYWORD ')' line
97+
{ sta::LibertyAttrValueSeq *args = sta::makeLibertyGroupColonArgs($3, $5);
98+
sta::libertyGroupBegin($1, args, $7); }
99+
semi_opt
100+
{ $$ = sta::libertyGroupEnd(); }
89101
;
90102

91103
line: /* empty */

liberty/LibertyParser.cc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,21 @@ libertyGroupEnd()
127127
}
128128
}
129129

130+
// Helper for brain damaged group args with embedded colon.
131+
// group(name1:name2) { stmts }
132+
LibertyAttrValueSeq *
133+
makeLibertyGroupColonArgs(const char *name1,
134+
const char *name2)
135+
{
136+
LibertyAttrValueSeq *attr_values = new sta::LibertyAttrValueSeq;
137+
char *str_arg = stringPrint("%s:%s", name1, name2);
138+
stringDelete(name1);
139+
stringDelete(name2);
140+
LibertyAttrValue *arg = makeLibertyStringAttrValue(str_arg);
141+
attr_values->push_back(arg);
142+
return attr_values;
143+
}
144+
130145
////////////////////////////////////////////////////////////////
131146

132147
LibertyStmt::LibertyStmt(int line) :

liberty/LibertyParser.hh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ void
303303
libertyGroupBegin(const char *type,
304304
LibertyAttrValueSeq *params,
305305
int line);
306+
LibertyAttrValueSeq *
307+
makeLibertyGroupColonArgs(const char *name1,
308+
const char *name2);
306309
LibertyGroup *
307310
libertyGroupEnd();
308311
LibertyGroup *

0 commit comments

Comments
 (0)