aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authoreli.bendersky <devnull@localhost>2010-10-29 16:25:43 +0200
committereli.bendersky <devnull@localhost>2010-10-29 16:25:43 +0200
commitef29ff9272ec225a0f324eca82cc204f556e91eb (patch)
tree8b4cc378c8370abca67954528f878a74d0ed2a49 /examples
parent2e907fada2916053a4130cd7f51b4bad41006f6a (diff)
downloadpycparser-ef29ff9272ec225a0f324eca82cc204f556e91eb.tar.gz
Implemented mixing of declarations and statements in compound statements for C99.
-> In the Compound AST node, decls and stmts were removed and replaced by a single list named block_items (this is an API change!)
Diffstat (limited to 'examples')
-rw-r--r--examples/cdecl.py2
-rw-r--r--examples/explore_ast.py20
2 files changed, 9 insertions, 13 deletions
diff --git a/examples/cdecl.py b/examples/cdecl.py
index 1db5149..3df6efc 100644
--- a/examples/cdecl.py
+++ b/examples/cdecl.py
@@ -17,7 +17,7 @@
# =>
# ar is a pointer to array[10] of pointer to const Node
#
-# Copyright (C) 2008, Eli Bendersky
+# Copyright (C) 2008-2010, Eli Bendersky
# License: LGPL
#-----------------------------------------------------------------
import sys
diff --git a/examples/explore_ast.py b/examples/explore_ast.py
index 7daf15b..f845c0f 100644
--- a/examples/explore_ast.py
+++ b/examples/explore_ast.py
@@ -9,7 +9,7 @@
# information from the AST.
# It helps to have the _c_ast.yaml file in front of you.
#
-# Copyright (C) 2008, Eli Bendersky
+# Copyright (C) 2008-2010, Eli Bendersky
# License: LGPL
#-----------------------------------------------------------------
import sys
@@ -92,23 +92,19 @@ ast = parser.parse(text, filename='<none>')
#
function_body = ast.ext[2].body
-# The following displays the variable declarations in the function
+# The following displays the declarations and statements in the function
# body
#
-#~ for decl in function_body.decls:
+#~ for decl in function_body.block_items:
#~ decl.show()
-# We can see a single variable, i, declared to be a simple type
-# declaration of type 'unsigned int'.
+# We can see a single variable declaration, i, declared to be a simple type
+# declaration of type 'unsigned int', followed by statements.
#
-# Let's look at the statemts now:
-#
-#~ for stmt in function_body.stmts:
- #~ stmt.show()
-# stmts is a list, so the second element is the For statement:
+# block_items is a list, so the third element is the For statement:
#
-for_stmt = function_body.stmts[1]
+for_stmt = function_body.block_items[2]
#~ for_stmt.show()
# As you can see in _c_ast.yaml, For's children are 'init, cond,
@@ -118,7 +114,7 @@ for_stmt = function_body.stmts[1]
#
# Let's dig deeper, to the while statement inside the for loop:
#
-while_stmt = for_stmt.stmt.stmts[0]
+while_stmt = for_stmt.stmt.block_items[1]
#~ while_stmt.show()
# While is simpler, it only has a condition node and a stmt node.