Minor update to walk AST via node.children[i] instead of node[i]
authorNick Downing <nick@ndcode.org>
Mon, 27 Dec 2021 06:42:54 +0000 (17:42 +1100)
committerNick Downing <nick@ndcode.org>
Mon, 27 Dec 2021 06:42:54 +0000 (17:42 +1100)
ansi_c.l
ansi_c.py

index 218d1e6..1115fba 100644 (file)
--- a/ansi_c.l
+++ b/ansi_c.l
@@ -80,7 +80,7 @@ WS  [ \t\v\n\f]
 "_Thread_local"                                return y_tab.THREAD_LOCAL
 "__func__"                             return y_tab.FUNC_NAME
 
-FILE|GRAM_STYPE|YYLTYPE|assoc|bool|boundary|code_props|code_props_type|location|muscle_kind|named_ref|param_type|scanflags_t|size_t|symbol|symbol_class|symbol_list|uniqstr|variant|warnings|u?int(8|16|32|64)_t|BaseType_t|TickType_t {
+FILE|GRAM_STYPE|YYLTYPE|assoc|bool|boundary|code_props|code_props_type|location|muscle_kind|named_ref|param_type|scanflags_t|size_t|symbol|symbol_class|symbol_list|uniqstr|variant|warnings|u?int(8|16|32|64)_t|BaseType_t|TickType_t|AmazonGetFfsDeviceTypeIdProductId|AmazonStateFfsDeviceTypeIdProductId|AmazonGetFfsPin|AmazonStateFfsPin|AmazonGetFfsX509Csr|AmazonStateFfsX509Csr|AmazonSetFfsX509CertChainDownload|AmazonGetFfsX509CertChainStatus|AmazonFfsX509CertChainStorageStatus|AmazonStateFfsX509CertChainStatus|AmazonSetFfsStaticKey {
   # THIS IS A HACK FOR NOW
   return y_tab.TYPEDEF_NAME
 }
index 172b8eb..70c55e9 100755 (executable)
--- a/ansi_c.py
+++ b/ansi_c.py
@@ -25,11 +25,11 @@ import y_tab
 root = y_tab.yyparse(t_def.AST.TranslationUnit)
 element.serialize(root, 'a.xml', 'utf-8')
 root = element.deserialize('a.xml', t_def.factory, 'utf-8')
-xml.etree.ElementTree.dump(root)
+#xml.etree.ElementTree.dump(root)
 
-for i in root:
+for i in root.children:
   if isinstance(i, t_def.AST.Declaration):
-    base_type = i[0].get_type()
-    for j in i[1]:
-      type, name = j[0].get_type_and_name(base_type)
+    base_type = i.children[0].get_type()
+    for j in i.children[1].children:
+      type, name = j.children[0].get_type_and_name(base_type)
       sys.stdout.write('{0:s} {1:s}\n'.format(str(type), name))