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

Abstract base class for all AST nodes. More...

#include <ast.hpp>

Inheritance diagram for pascal::ASTNode:

Public Member Functions

virtual ~ASTNode ()=default
virtual void accept (ASTVisitor &visitor)=0
 Accept an ASTVisitor (double-dispatch).
virtual std::string toString () const =0
 Return a human-readable description of this node.
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.

Private Attributes

int line_number = 0
 source line number where this node originated

Detailed Description

Abstract base class for all AST nodes.

Every concrete AST node inherits from this class, implementing the visitor pattern via accept() and providing a debug string via toString().

Definition at line 26 of file ast.hpp.

Constructor & Destructor Documentation

◆ ~ASTNode()

virtual pascal::ASTNode::~ASTNode ( )
virtualdefault

Member Function Documentation

◆ accept()

◆ getLineNumber()

int pascal::ASTNode::getLineNumber ( ) const
inline

Get the originating source line number.

Definition at line 40 of file ast.hpp.

References line_number.

◆ print()

void pascal::ASTNode::print ( std::ostream & out,
int indent = 0 ) const
virtual

Pretty-print this node to a stream with indentation.

Definition at line 17 of file ast.cpp.

References toString().

◆ setLineNumber()

void pascal::ASTNode::setLineNumber ( int line)
inline

Set the originating source line number.

Definition at line 38 of file ast.hpp.

References line_number.

◆ toString()

Member Data Documentation

◆ line_number

int pascal::ASTNode::line_number = 0
private

source line number where this node originated

Definition at line 27 of file ast.hpp.

Referenced by getLineNumber(), and setLineNumber().


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