Skip to content

Commit 46171dc

Browse files
committed
MINT: CONTROL layer support, _fromMINT.json output, token/context fixes
- Parser/lexer: idParam, ID_BIG in ufname/uftarget, controlBlock _ctx restore - Compiler: idParam handling, uftarget token .text vs getText for Channel/Net - Output: write <stem>_fromMINT.json to match LFR _fromLFR.json naming
1 parent f9b9f0a commit 46171dc

6 files changed

Lines changed: 323 additions & 62 deletions

File tree

mint.g4

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,12 @@ paramStat:
130130
| widthParam
131131
| constraintParams
132132
| lengthParam
133-
| spacingParam;
133+
| spacingParam
134+
| idParam;
135+
136+
idParam: param_element WS* '=' WS* id_value;
137+
138+
id_value: ID | ID_BIG;
134139

135140
constraintParams:
136141
rotationParam
@@ -174,9 +179,9 @@ ufterminal: INT;
174179

175180
uftargets: uftarget WS* (',' WS* uftarget)+;
176181

177-
uftarget: target_name = ID (WS+ target_terminal = INT)?;
182+
uftarget: target_name = (ID | ID_BIG) (WS+ target_terminal = INT)?;
178183

179-
ufname: ID;
184+
ufname: (ID | ID_BIG);
180185

181186
ufnames: ufname WS* (',' WS* ufname)* WS*;
182187

@@ -200,7 +205,7 @@ ID: ('a' ..'z' | '_') (
200205
| '_'
201206
)*;
202207

203-
ID_BIG: ('A' ..'Z' | '_') ('A' ..'Z' | '_' | '0' ..'9')*;
208+
ID_BIG: ('A' ..'Z' | '_') ('A' ..'Z' | 'a' ..'z' | '_' | '0' ..'9')*;
204209

205210
INT: [0-9]+; // Define token INT as one or more digits
206211

pymint/antlrgen/mintLexer.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,5 +242,24 @@ def __init__(self, input=None, output:TextIO = sys.stdout):
242242
self._interp = LexerATNSimulator(self, self.atn, self.decisionsToDFA, PredictionContextCache())
243243
self._actions = None
244244
self._predicates = None
245+
self._pending_token = None
246+
247+
def nextToken(self):
248+
"""Override to merge single-char ID_BIG with following ID (e.g. C + port_0 -> Cport_0)."""
249+
if self._pending_token is not None:
250+
t = self._pending_token
251+
self._pending_token = None
252+
return t
253+
t = super().nextToken()
254+
if t.type == mintLexer.ID_BIG and t.text and len(t.text) == 1 and t.text[0].isupper():
255+
n = super().nextToken()
256+
if n.type == mintLexer.ID and n.text:
257+
merged = t.clone()
258+
merged.type = mintLexer.ID_BIG
259+
merged.stop = n.stop
260+
merged._text = t.text + n.text
261+
return merged
262+
self._pending_token = n
263+
return t
245264

246265

pymint/antlrgen/mintListener.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,24 @@ def exitParamStat(self, ctx:mintParser.ParamStatContext):
323323
pass
324324

325325

326+
# Enter a parse tree produced by mintParser#idParam.
327+
def enterIdParam(self, ctx:mintParser.IdParamContext):
328+
pass
329+
330+
# Exit a parse tree produced by mintParser#idParam.
331+
def exitIdParam(self, ctx:mintParser.IdParamContext):
332+
pass
333+
334+
335+
# Enter a parse tree produced by mintParser#id_value.
336+
def enterId_value(self, ctx:mintParser.Id_valueContext):
337+
pass
338+
339+
# Exit a parse tree produced by mintParser#id_value.
340+
def exitId_value(self, ctx:mintParser.Id_valueContext):
341+
pass
342+
343+
326344
# Enter a parse tree produced by mintParser#constraintParams.
327345
def enterConstraintParams(self, ctx:mintParser.ConstraintParamsContext):
328346
pass

0 commit comments

Comments
 (0)