tan  0.0.1
tanlang::If Class Reference

Represent if-[else] or if-elif-[else] statements. More...

#include <stmt.h>

Inheritance diagram for tanlang::If:
Collaboration diagram for tanlang::If:

Public Member Functions

str terminal_token () const override
 Which terminal token is expected immediately after this node. More...
 
void add_if_then_branch (Expr *pred, Stmt *branch)
 
void add_else_branch (Stmt *branch)
 
Exprget_predicate (size_t i) const
 
void set_predicate (size_t i, Expr *expr)
 
Stmtget_branch (size_t i) const
 
size_t get_num_branches () const
 
vector< ASTBase * > get_children () const override
 Get a ordered list of child nodes. More...
 
- Public Member Functions inherited from tanlang::Stmt
bool is_stmt () const override
 
bool is_expr () const override
 
- Public Member Functions inherited from tanlang::ASTBase
 ASTBase (ASTNodeType node_type, TokenizedSourceFile *src, int bp)
 
ASTNodeType get_node_type () const
 
void set_node_type (ASTNodeType node_type)
 
int get_bp () const
 
Contextctx ()
 
str repr (const str &prefix="-") const
 AST tree string representation. More...
 
- Public Member Functions inherited from tanlang::SourceTraceable
 SourceTraceable (TokenizedSourceFile *src)
 
uint32_t start () const
 
uint32_t end () const
 
void set_start (uint32_t val)
 
void set_end (uint32_t val)
 
TokenizedSourceFilesrc () const
 

Static Public Member Functions

static IfCreate (TokenizedSourceFile *src)
 

Protected Member Functions

 If (TokenizedSourceFile *src)
 
- Protected Member Functions inherited from tanlang::Stmt
 Stmt (ASTNodeType type, TokenizedSourceFile *src)
 
- Protected Member Functions inherited from tanlang::ASTBase
virtual str to_string (bool include_source_code=false) const
 Different from repr, to_string output doesn't include child nodes. More...
 
virtual ASTBaseget () const
 Get the "actual" this. Used for implementing proxy classes. More...
 

Additional Inherited Members

- Static Public Attributes inherited from tanlang::ASTBase
static umap< ASTNodeType, str > ASTTypeNames
 string representation of ASTNodeType More...
 
static umap< ASTNodeType, int > OpPrecedence
 operator precedence of tokens More...
 

Detailed Description

Represent if-[else] or if-elif-[else] statements.

Definition at line 144 of file stmt.h.

Constructor & Destructor Documentation

◆ If()

If::If ( TokenizedSourceFile src)
explicitprotected

If-else

Definition at line 89 of file stmt.cpp.

Member Function Documentation

◆ get_children()

vector< ASTBase * > If::get_children ( ) const
overridevirtual

Get a ordered list of child nodes.

Reimplemented from tanlang::Stmt.

Definition at line 121 of file stmt.cpp.

◆ get_predicate()

Expr * If::get_predicate ( size_t  i) const
Note
Return value can be a nullptr if the branch is an "else"

Definition at line 104 of file stmt.cpp.

◆ terminal_token()

str tanlang::If::terminal_token ( ) const
inlineoverridevirtual

Which terminal token is expected immediately after this node.

Reimplemented from tanlang::ASTBase.

Definition at line 152 of file stmt.h.


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