diff --git a/compiler.rst b/compiler.rst --- a/compiler.rst +++ b/compiler.rst @@ -41,8 +41,8 @@ The grammar file for Python can be found in Grammar/Grammar with the numeric value of grammar rules are stored in Include/graminit.h. The numeric values for types of tokens (literal tokens, such as ``:``, -numbers, etc.) are kept in Include/token.h). The parse tree made up of -``node *`` structs (as defined in Include/node.h). +numbers, etc.) are kept in Include/token.h). The parse tree is made up +of ``node *`` structs (as defined in Include/node.h). Querying data from the node structs can be done with the following macros (which are all defined in Include/node.h): @@ -65,14 +65,14 @@ retrieve the line number of the source code that led to the creation of the parse rule; defined in Python/ast.c -To tie all of this example, consider the rule for 'while':: +For example, consider the rule for 'while':: while_stmt: 'while' test ':' suite ['else' ':' suite] The node representing this will have ``TYPE(node) == while_stmt`` and -the number of children can be 4 or 7 depending on if there is an 'else' -statement. To access what should be the first ':' and require it be an -actual ':' token, `(REQ(CHILD(node, 2), COLON)``. +the number of children can be 4 or 7 depending on whether there is an +'else' statement. ``(REQ(CHILD(node, 2), COLON)`` can be used to access +what should be the first ``:`` and require it be an actual ``:`` token. Abstract Syntax Trees (AST)