From 9feacc3f07be032e90f2f3580dea3bd4e3797a3c Mon Sep 17 00:00:00 2001 From: Tobias Platen Date: Tue, 22 Oct 2019 21:10:11 +0200 Subject: [PATCH] ports as py nodes --- parse_sv.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/parse_sv.py b/parse_sv.py index 28530fc..0c6ad9c 100644 --- a/parse_sv.py +++ b/parse_sv.py @@ -101,14 +101,7 @@ NP_POUTPUT = 'POUTPUT' NP_PINOUT = 'PINOUT' NP_PREF = 'PREF' -def indent(s, i=4): - st = '' - for x in s: - st += str(x) - res = [] - for p in st.split('\n'): - res.append(' ' * i + "#"+p) - return '\n'.join(res) +indent = ' ' class DataType: @@ -5068,9 +5061,11 @@ def p_module_1(p): stmts = Node(syms.small_stmt, [pass_stmt, Leaf(token.NEWLINE, '\n')]) stmts = Node(syms.stmt, [stmts]) - # XXX TODO ports as py nodes ports = p[8] - stmts.children.append(Leaf(token.STRING, '\n' + indent(ports, 8))) + for port in ports: + stmts.children.append(Leaf(token.INDENT, indent*2)) + stmts.children.append(Leaf(token.STRING, port)) + suite = Node(syms.suite, [Leaf(token.NEWLINE, '\n'), Leaf(token.INDENT, ' '), stmts, -- 2.30.2