1 #ifndef __TAN_SRC_AST_AST_BASE_H__
2 #define __TAN_SRC_AST_AST_BASE_H__
4 #include "source_traceable.h"
5 #include "precedence.h"
6 #include "ast_node_type.h"
27 [[nodiscard]] ASTNodeType get_node_type()
const;
28 void set_node_type(ASTNodeType node_type);
29 [[nodiscard]]
int get_bp()
const;
35 [[nodiscard]]
virtual vector<ASTBase *>
get_children()
const;
38 str
repr(
const str &prefix =
"-")
const;
41 virtual bool is_stmt()
const = 0;
42 virtual bool is_expr()
const = 0;
49 [[nodiscard]]
virtual str
to_string(
bool include_source_code =
false)
const;
57 ASTNodeType _node_type;
virtual ASTBase * get() const
Get the "actual" this. Used for implementing proxy classes.
static umap< ASTNodeType, str > ASTTypeNames
string representation of ASTNodeType
virtual str to_string(bool include_source_code=false) const
Different from repr, to_string output doesn't include child nodes.
str repr(const str &prefix="-") const
AST tree string representation.
static umap< ASTNodeType, int > OpPrecedence
operator precedence of tokens
virtual str terminal_token() const
Which terminal token is expected immediately after this node.
virtual vector< ASTBase * > get_children() const
Get a ordered list of child nodes.
Represents the nodes that can be traced back to tokens in the source file.
Different from SourceFile, TokenizedSourceFile manages the tokenized text of a source file.