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.
Result< void > setSource (const std::string &source)
 Sets the source file for the parser.
Result< std::vector< Token > > getTokens ()
 Retrieves all tokens from the lexer.
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()

Parser::Parser ( )

Constructs a Parser.

Member Function Documentation

◆ getTokens()

Result< std::vector< Token > > Parser::getTokens ( )

Retrieves all tokens from the lexer.

Returns
A vector of all tokens.

◆ 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).

◆ setSource()

Result< void > Parser::setSource ( const std::string & source)

Sets the source file for the parser.

Parameters
sourceThe source file to read from.

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