MXVM 1.8.1
Virtual Machine, Compiler, and Pascal Frontend
Loading...
Searching...
No Matches
pascal::BinaryOpNode Class Reference

AST node for a binary operator expression. More...

#include <ast.hpp>

Inheritance diagram for pascal::BinaryOpNode:

Public Types

enum  OpType {
  PLUS , MINUS , MULTIPLY , DIVIDE ,
  DIV , MOD , EQUAL , NOT_EQUAL ,
  LESS , LESS_EQUAL , GREATER , GREATER_EQUAL ,
  AND , OR , IN
}
 Binary operator kinds. More...

Public Member Functions

 BinaryOpNode (std::unique_ptr< ASTNode > l, OpType op, std::unique_ptr< ASTNode > r)
 BinaryOpNode (OpType op, std::unique_ptr< ASTNode > l, std::unique_ptr< ASTNode > r)
void accept (ASTVisitor &visitor) override
 Accept an ASTVisitor (double-dispatch).
std::string toString () const override
 Return a human-readable description of this node.
Public Member Functions inherited from pascal::ASTNode
virtual ~ASTNode ()=default
virtual void print (std::ostream &out, int indent=0) const
 Pretty-print this node to a stream with indentation.
void setLineNumber (int line)
 Set the originating source line number.
int getLineNumber () const
 Get the originating source line number.

Static Public Member Functions

static std::string opToString (OpType op)
 Convert an OpType to its string representation.

Public Attributes

std::unique_ptr< ASTNodeleft
 left operand
OpType operator_
 operator kind
std::unique_ptr< ASTNoderight
 right operand

Detailed Description

AST node for a binary operator expression.

Definition at line 438 of file ast.hpp.

Member Enumeration Documentation

◆ OpType

Binary operator kinds.

Enumerator
PLUS 
MINUS 
MULTIPLY 
DIVIDE 
DIV 
MOD 
EQUAL 
NOT_EQUAL 
LESS 
LESS_EQUAL 
GREATER 
GREATER_EQUAL 
AND 
OR 
IN 

Definition at line 441 of file ast.hpp.

Constructor & Destructor Documentation

◆ BinaryOpNode() [1/2]

pascal::BinaryOpNode::BinaryOpNode ( std::unique_ptr< ASTNode > l,
OpType op,
std::unique_ptr< ASTNode > r )
inline

Definition at line 463 of file ast.hpp.

References left, operator_, and right.

◆ BinaryOpNode() [2/2]

pascal::BinaryOpNode::BinaryOpNode ( OpType op,
std::unique_ptr< ASTNode > l,
std::unique_ptr< ASTNode > r )
inline

Definition at line 466 of file ast.hpp.

References left, operator_, and right.

Member Function Documentation

◆ accept()

void pascal::BinaryOpNode::accept ( ASTVisitor & visitor)
overridevirtual

Accept an ASTVisitor (double-dispatch).

Implements pascal::ASTNode.

Definition at line 165 of file ast.cpp.

References pascal::ASTVisitor::visit().

◆ opToString()

std::string pascal::BinaryOpNode::opToString ( OpType op)
static

Convert an OpType to its string representation.

Definition at line 173 of file ast.cpp.

References AND, DIV, DIVIDE, EQUAL, GREATER, GREATER_EQUAL, IN, LESS, LESS_EQUAL, MINUS, MOD, MULTIPLY, NOT_EQUAL, OR, and PLUS.

Referenced by toString().

◆ toString()

std::string pascal::BinaryOpNode::toString ( ) const
overridevirtual

Return a human-readable description of this node.

Implements pascal::ASTNode.

Definition at line 169 of file ast.cpp.

References operator_, and opToString().

Member Data Documentation

◆ left

std::unique_ptr<ASTNode> pascal::BinaryOpNode::left

left operand

Definition at line 459 of file ast.hpp.

Referenced by BinaryOpNode(), BinaryOpNode(), and pascal::CodeGenVisitor::visit().

◆ operator_

OpType pascal::BinaryOpNode::operator_

operator kind

Definition at line 460 of file ast.hpp.

Referenced by BinaryOpNode(), BinaryOpNode(), toString(), and pascal::CodeGenVisitor::visit().

◆ right

std::unique_ptr<ASTNode> pascal::BinaryOpNode::right

right operand

Definition at line 461 of file ast.hpp.

Referenced by BinaryOpNode(), BinaryOpNode(), and pascal::CodeGenVisitor::visit().


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