ports as py nodes
authorTobias Platen <tplaten@posteo.de>
Tue, 22 Oct 2019 19:10:11 +0000 (21:10 +0200)
committerTobias Platen <tplaten@posteo.de>
Tue, 22 Oct 2019 19:10:11 +0000 (21:10 +0200)
parse_sv.py

index 28530fcf3c7a1bd96207f8888a1c36c7ccda2b90..0c6ad9c6453cd9b558da36e2065a47567aedc424 100644 (file)
@@ -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,