picceler
Loading...
Searching...
No Matches
picceler::Parser Class Reference

The Parser class that converts tokens into an AST. More...

#include <parser.h>

Public Member Functions

 Parser ()
 Constructs a Parser without tokens.
 Parser (std::vector< Token > tokens)
 Constructs a Parser with a given vector of tokens.
void setTokens (std::vector< Token > tokens)
Result< std::unique_ptr< ModuleNode > > parse ()
 Parses the tokens into an AST.
void printAST (const std::unique_ptr< ModuleNode > &node, int indent=0)
 Prints the AST in a human-readable format.

Detailed Description

The Parser class that converts tokens into an AST.

Constructor & Destructor Documentation

◆ Parser() [1/2]

Parser::Parser ( )

Constructs a Parser without tokens.

◆ Parser() [2/2]

Parser::Parser ( std::vector< Token > tokens)
explicit

Constructs a Parser with a given vector of tokens.

Member Function Documentation

◆ parse()

Result< std::unique_ptr< ModuleNode > > Parser::parse ( )

Parses the tokens into an AST.

Returns
The root of the AST.

◆ printAST()

void Parser::printAST ( const std::unique_ptr< ModuleNode > & node,
int indent = 0 )

Prints the AST in a human-readable format.

Parameters
nodeThe root of the AST.
indentThe current indentation level (used for formatting) (not working currently).

◆ setTokens()

void picceler::Parser::setTokens ( std::vector< Token > tokens)
inline

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