Nearly CC
An educational compiler skeleton
Public Member Functions | List of all members
ASTVisitor Class Reference

Base class for AST visitors. More...

#include "ast_visitor.h"

Inheritance diagram for ASTVisitor:
Inheritance graph
[legend]

Public Member Functions

virtual void visit (Node *n)
 Visit given AST Node. More...
 
virtual void visit_unit (Node *n)
 Visit a Node with the AST_UNIT tag value. More...
 
virtual void visit_variable_declaration (Node *n)
 Visit a Node with the AST_VARIABLE_DECLARATION tag value. More...
 
virtual void visit_struct_type (Node *n)
 Visit a Node with the AST_STRUCT_TYPE tag value. More...
 
virtual void visit_union_type (Node *n)
 Visit a Node with the AST_UNION_TYPE tag value. More...
 
virtual void visit_basic_type (Node *n)
 Visit a Node with the AST_BASIC_TYPE tag value. More...
 
virtual void visit_declarator_list (Node *n)
 Visit a Node with the AST_DECLARATOR_LIST tag value. More...
 
virtual void visit_named_declarator (Node *n)
 Visit a Node with the AST_NAMED_DECLARATOR tag value. More...
 
virtual void visit_pointer_declarator (Node *n)
 Visit a Node with the AST_POINTER_DECLARATOR tag value. More...
 
virtual void visit_array_declarator (Node *n)
 Visit a Node with the AST_ARRAY_DECLARATOR tag value. More...
 
virtual void visit_function_definition (Node *n)
 Visit a Node with the AST_FUNCTION_DEFINITION tag value. More...
 
virtual void visit_function_declaration (Node *n)
 Visit a Node with the AST_FUNCTION_DECLARATION tag value. More...
 
virtual void visit_function_parameter_list (Node *n)
 Visit a Node with the AST_FUNCTION_PARAMETER_LIST tag value. More...
 
virtual void visit_function_parameter (Node *n)
 Visit a Node with the AST_FUNCTION_PARAMETER tag value. More...
 
virtual void visit_statement_list (Node *n)
 Visit a Node with the AST_STATEMENT_LIST tag value. More...
 
virtual void visit_empty_statement (Node *n)
 Visit a Node with the AST_EMPTY_STATEMENT tag value. More...
 
virtual void visit_expression_statement (Node *n)
 Visit a Node with the AST_EXPRESSION_STATEMENT tag value. More...
 
virtual void visit_return_statement (Node *n)
 Visit a Node with the AST_RETURN_STATEMENT tag value. More...
 
virtual void visit_return_expression_statement (Node *n)
 Visit a Node with the AST_RETURN_EXPRESSION_STATEMENT tag value. More...
 
virtual void visit_while_statement (Node *n)
 Visit a Node with the AST_WHILE_STATEMENT tag value. More...
 
virtual void visit_do_while_statement (Node *n)
 Visit a Node with the AST_DO_WHILE_STATEMENT tag value. More...
 
virtual void visit_for_statement (Node *n)
 Visit a Node with the AST_FOR_STATEMENT tag value. More...
 
virtual void visit_if_statement (Node *n)
 Visit a Node with the AST_IF_STATEMENT tag value. More...
 
virtual void visit_if_else_statement (Node *n)
 Visit a Node with the AST_IF_ELSE_STATEMENT tag value. More...
 
virtual void visit_struct_type_definition (Node *n)
 Visit a Node with the AST_STRUCT_TYPE_DEFINITION tag value. More...
 
virtual void visit_union_type_definition (Node *n)
 Visit a Node with the AST_UNION_TYPE_DEFINITION tag value. More...
 
virtual void visit_field_definition_list (Node *n)
 Visit a Node with the AST_FIELD_DEFINITION_LIST tag value. More...
 
virtual void visit_binary_expression (Node *n)
 Visit a Node with the AST_BINARY_EXPRESSION tag value. More...
 
virtual void visit_unary_expression (Node *n)
 Visit a Node with the AST_UNARY_EXPRESSION tag value. More...
 
virtual void visit_postfix_expression (Node *n)
 Visit a Node with the AST_POSTFIX_EXPRESSION tag value. More...
 
virtual void visit_conditional_expression (Node *n)
 Visit a Node with the AST_CONDITIONAL_EXPRESSION tag value. More...
 
virtual void visit_cast_expression (Node *n)
 Visit a Node with the AST_CAST_EXPRESSION tag value. More...
 
virtual void visit_function_call_expression (Node *n)
 Visit a Node with the AST_FUNCTION_CALL_EXPRESSION tag value. More...
 
virtual void visit_field_ref_expression (Node *n)
 Visit a Node with the AST_FIELD_REF_EXPRESSION tag value. More...
 
virtual void visit_indirect_field_ref_expression (Node *n)
 Visit a Node with the AST_INDIRECT_FIELD_REF_EXPRESSION tag value. More...
 
virtual void visit_array_element_ref_expression (Node *n)
 Visit a Node with the AST_ARRAY_ELEMENT_REF_EXPRESSION tag value. More...
 
virtual void visit_argument_expression_list (Node *n)
 Visit a Node with the AST_ARGUMENT_EXPRESSION_LIST tag value. More...
 
virtual void visit_variable_ref (Node *n)
 Visit a Node with the AST_VARIABLE_REF tag value. More...
 
virtual void visit_literal_value (Node *n)
 Visit a Node with the AST_LITERAL_VALUE tag value. More...
 
virtual void visit_implicit_conversion (Node *n)
 Visit a Node with the AST_IMPLICIT_CONVERSION tag value. More...
 
virtual void visit_children (Node *n)
 Call visit on each child Node of the given parent Node. More...
 
virtual void visit_token (Node *n)
 This method is called if the Node being visited is a token (terminal symbol). More...
 

Detailed Description

Base class for AST visitors.

Member Function Documentation

◆ visit()

void ASTVisitor::visit ( Node n)
virtual

Visit given AST Node.

This will result in a call to an appropriate visitation member function depending on the Node object's tag value. For example, if the tag value is AST_STATEMENT_LIST, the visit_statement_list member function will be called.

Parameters
nthe Node to visit

◆ visit_argument_expression_list()

void ASTVisitor::visit_argument_expression_list ( Node n)
virtual

Visit a Node with the AST_ARGUMENT_EXPRESSION_LIST tag value.

Parameters
na Node with the AST_ARGUMENT_EXPRESSION_LIST tag value

◆ visit_array_declarator()

void ASTVisitor::visit_array_declarator ( Node n)
virtual

Visit a Node with the AST_ARRAY_DECLARATOR tag value.

Parameters
na Node with the AST_ARRAY_DECLARATOR tag value

◆ visit_array_element_ref_expression()

void ASTVisitor::visit_array_element_ref_expression ( Node n)
virtual

Visit a Node with the AST_ARRAY_ELEMENT_REF_EXPRESSION tag value.

Parameters
na Node with the AST_ARRAY_ELEMENT_REF_EXPRESSION tag value

Reimplemented in SemanticAnalysis, and HighLevelCodegen.

◆ visit_basic_type()

void ASTVisitor::visit_basic_type ( Node n)
virtual

Visit a Node with the AST_BASIC_TYPE tag value.

Parameters
na Node with the AST_BASIC_TYPE tag value

Reimplemented in SemanticAnalysis.

◆ visit_binary_expression()

void ASTVisitor::visit_binary_expression ( Node n)
virtual

Visit a Node with the AST_BINARY_EXPRESSION tag value.

Parameters
na Node with the AST_BINARY_EXPRESSION tag value

Reimplemented in SemanticAnalysis, and HighLevelCodegen.

◆ visit_cast_expression()

void ASTVisitor::visit_cast_expression ( Node n)
virtual

Visit a Node with the AST_CAST_EXPRESSION tag value.

Parameters
na Node with the AST_CAST_EXPRESSION tag value

Reimplemented in SemanticAnalysis.

◆ visit_children()

void ASTVisitor::visit_children ( Node n)
virtual

Call visit on each child Node of the given parent Node.

Parameters
nthe parent Node whose children should be visited

◆ visit_conditional_expression()

void ASTVisitor::visit_conditional_expression ( Node n)
virtual

Visit a Node with the AST_CONDITIONAL_EXPRESSION tag value.

Parameters
na Node with the AST_CONDITIONAL_EXPRESSION tag value

Reimplemented in SemanticAnalysis.

◆ visit_declarator_list()

void ASTVisitor::visit_declarator_list ( Node n)
virtual

Visit a Node with the AST_DECLARATOR_LIST tag value.

Parameters
na Node with the AST_DECLARATOR_LIST tag value

Reimplemented in LocalStorageAllocation.

◆ visit_do_while_statement()

void ASTVisitor::visit_do_while_statement ( Node n)
virtual

Visit a Node with the AST_DO_WHILE_STATEMENT tag value.

Parameters
na Node with the AST_DO_WHILE_STATEMENT tag value

Reimplemented in LoopVars, and HighLevelCodegen.

◆ visit_empty_statement()

void ASTVisitor::visit_empty_statement ( Node n)
virtual

Visit a Node with the AST_EMPTY_STATEMENT tag value.

Parameters
na Node with the AST_EMPTY_STATEMENT tag value

◆ visit_expression_statement()

void ASTVisitor::visit_expression_statement ( Node n)
virtual

Visit a Node with the AST_EXPRESSION_STATEMENT tag value.

Parameters
na Node with the AST_EXPRESSION_STATEMENT tag value

Reimplemented in HighLevelCodegen.

◆ visit_field_definition_list()

void ASTVisitor::visit_field_definition_list ( Node n)
virtual

Visit a Node with the AST_FIELD_DEFINITION_LIST tag value.

Parameters
na Node with the AST_FIELD_DEFINITION_LIST tag value

◆ visit_field_ref_expression()

void ASTVisitor::visit_field_ref_expression ( Node n)
virtual

Visit a Node with the AST_FIELD_REF_EXPRESSION tag value.

Parameters
na Node with the AST_FIELD_REF_EXPRESSION tag value

Reimplemented in SemanticAnalysis, and HighLevelCodegen.

◆ visit_for_statement()

void ASTVisitor::visit_for_statement ( Node n)
virtual

Visit a Node with the AST_FOR_STATEMENT tag value.

Parameters
na Node with the AST_FOR_STATEMENT tag value

Reimplemented in LoopVars, and HighLevelCodegen.

◆ visit_function_call_expression()

void ASTVisitor::visit_function_call_expression ( Node n)
virtual

Visit a Node with the AST_FUNCTION_CALL_EXPRESSION tag value.

Parameters
na Node with the AST_FUNCTION_CALL_EXPRESSION tag value

Reimplemented in SemanticAnalysis, and HighLevelCodegen.

◆ visit_function_declaration()

void ASTVisitor::visit_function_declaration ( Node n)
virtual

Visit a Node with the AST_FUNCTION_DECLARATION tag value.

Parameters
na Node with the AST_FUNCTION_DECLARATION tag value

Reimplemented in SemanticAnalysis.

◆ visit_function_definition()

void ASTVisitor::visit_function_definition ( Node n)
virtual

Visit a Node with the AST_FUNCTION_DEFINITION tag value.

Parameters
na Node with the AST_FUNCTION_DEFINITION tag value

Reimplemented in SemanticAnalysis, LocalStorageAllocation, and HighLevelCodegen.

◆ visit_function_parameter()

void ASTVisitor::visit_function_parameter ( Node n)
virtual

Visit a Node with the AST_FUNCTION_PARAMETER tag value.

Parameters
na Node with the AST_FUNCTION_PARAMETER tag value

Reimplemented in SemanticAnalysis, and LocalStorageAllocation.

◆ visit_function_parameter_list()

void ASTVisitor::visit_function_parameter_list ( Node n)
virtual

Visit a Node with the AST_FUNCTION_PARAMETER_LIST tag value.

Parameters
na Node with the AST_FUNCTION_PARAMETER_LIST tag value

◆ visit_if_else_statement()

void ASTVisitor::visit_if_else_statement ( Node n)
virtual

Visit a Node with the AST_IF_ELSE_STATEMENT tag value.

Parameters
na Node with the AST_IF_ELSE_STATEMENT tag value

Reimplemented in HighLevelCodegen.

◆ visit_if_statement()

void ASTVisitor::visit_if_statement ( Node n)
virtual

Visit a Node with the AST_IF_STATEMENT tag value.

Parameters
na Node with the AST_IF_STATEMENT tag value

Reimplemented in HighLevelCodegen.

◆ visit_implicit_conversion()

void ASTVisitor::visit_implicit_conversion ( Node n)
virtual

Visit a Node with the AST_IMPLICIT_CONVERSION tag value.

Parameters
na Node with the AST_IMPLICIT_CONVERSION tag value

Reimplemented in HighLevelCodegen.

◆ visit_indirect_field_ref_expression()

void ASTVisitor::visit_indirect_field_ref_expression ( Node n)
virtual

Visit a Node with the AST_INDIRECT_FIELD_REF_EXPRESSION tag value.

Parameters
na Node with the AST_INDIRECT_FIELD_REF_EXPRESSION tag value

Reimplemented in SemanticAnalysis, and HighLevelCodegen.

◆ visit_literal_value()

void ASTVisitor::visit_literal_value ( Node n)
virtual

Visit a Node with the AST_LITERAL_VALUE tag value.

Parameters
na Node with the AST_LITERAL_VALUE tag value

Reimplemented in SemanticAnalysis, and HighLevelCodegen.

◆ visit_named_declarator()

void ASTVisitor::visit_named_declarator ( Node n)
virtual

Visit a Node with the AST_NAMED_DECLARATOR tag value.

Parameters
na Node with the AST_NAMED_DECLARATOR tag value

◆ visit_pointer_declarator()

void ASTVisitor::visit_pointer_declarator ( Node n)
virtual

Visit a Node with the AST_POINTER_DECLARATOR tag value.

Parameters
na Node with the AST_POINTER_DECLARATOR tag value

◆ visit_postfix_expression()

void ASTVisitor::visit_postfix_expression ( Node n)
virtual

Visit a Node with the AST_POSTFIX_EXPRESSION tag value.

Parameters
na Node with the AST_POSTFIX_EXPRESSION tag value

Reimplemented in SemanticAnalysis.

◆ visit_return_expression_statement()

void ASTVisitor::visit_return_expression_statement ( Node n)
virtual

Visit a Node with the AST_RETURN_EXPRESSION_STATEMENT tag value.

Parameters
na Node with the AST_RETURN_EXPRESSION_STATEMENT tag value

Reimplemented in SemanticAnalysis, and HighLevelCodegen.

◆ visit_return_statement()

void ASTVisitor::visit_return_statement ( Node n)
virtual

Visit a Node with the AST_RETURN_STATEMENT tag value.

Parameters
na Node with the AST_RETURN_STATEMENT tag value

Reimplemented in HighLevelCodegen.

◆ visit_statement_list()

void ASTVisitor::visit_statement_list ( Node n)
virtual

Visit a Node with the AST_STATEMENT_LIST tag value.

Parameters
na Node with the AST_STATEMENT_LIST tag value

Reimplemented in SemanticAnalysis, LocalStorageAllocation, and HighLevelCodegen.

◆ visit_struct_type()

void ASTVisitor::visit_struct_type ( Node n)
virtual

Visit a Node with the AST_STRUCT_TYPE tag value.

Parameters
na Node with the AST_STRUCT_TYPE tag value

Reimplemented in SemanticAnalysis.

◆ visit_struct_type_definition()

void ASTVisitor::visit_struct_type_definition ( Node n)
virtual

Visit a Node with the AST_STRUCT_TYPE_DEFINITION tag value.

Parameters
na Node with the AST_STRUCT_TYPE_DEFINITION tag value

Reimplemented in SemanticAnalysis, and LocalStorageAllocation.

◆ visit_token()

void ASTVisitor::visit_token ( Node n)
virtual

This method is called if the Node being visited is a token (terminal symbol).

Parameters
nthe token (terminal symbol) Node

◆ visit_unary_expression()

void ASTVisitor::visit_unary_expression ( Node n)
virtual

Visit a Node with the AST_UNARY_EXPRESSION tag value.

Parameters
na Node with the AST_UNARY_EXPRESSION tag value

Reimplemented in SemanticAnalysis, and HighLevelCodegen.

◆ visit_union_type()

void ASTVisitor::visit_union_type ( Node n)
virtual

Visit a Node with the AST_UNION_TYPE tag value.

Parameters
na Node with the AST_UNION_TYPE tag value

Reimplemented in SemanticAnalysis.

◆ visit_union_type_definition()

void ASTVisitor::visit_union_type_definition ( Node n)
virtual

Visit a Node with the AST_UNION_TYPE_DEFINITION tag value.

Parameters
na Node with the AST_UNION_TYPE_DEFINITION tag value

◆ visit_unit()

void ASTVisitor::visit_unit ( Node n)
virtual

Visit a Node with the AST_UNIT tag value.

Parameters
na Node with the AST_UNIT tag value

◆ visit_variable_declaration()

void ASTVisitor::visit_variable_declaration ( Node n)
virtual

Visit a Node with the AST_VARIABLE_DECLARATION tag value.

Parameters
na Node with the AST_VARIABLE_DECLARATION tag value

Reimplemented in SemanticAnalysis.

◆ visit_variable_ref()

void ASTVisitor::visit_variable_ref ( Node n)
virtual

Visit a Node with the AST_VARIABLE_REF tag value.

Parameters
na Node with the AST_VARIABLE_REF tag value

Reimplemented in SemanticAnalysis, LoopVars, and HighLevelCodegen.

◆ visit_while_statement()

void ASTVisitor::visit_while_statement ( Node n)
virtual

Visit a Node with the AST_WHILE_STATEMENT tag value.

Parameters
na Node with the AST_WHILE_STATEMENT tag value

Reimplemented in LoopVars, and HighLevelCodegen.


The documentation for this class was generated from the following files: