def p_code_block(self, p): """ CODE_BLOCK : CODE_BLOCK instruction | instruction """ if len(p) == 3: p[1].instructions.append(p[2]) p[0] = p[1] else: p[0] = ast.CodeBlock(p[1])
def p_code_block_braces(self, p): """ CODE_BLOCK : CODE_BLOCK LBRACE CODE_BLOCK RBRACE | LBRACE CODE_BLOCK RBRACE """ if len(p) == 5: p[1].instructions.append(p[3]) p[0] = p[1] else: p[0] = ast.CodeBlock(p[2])