sammine-lang
Loading...
Searching...
No Matches
sammine_lang::Parser Class Reference
Inheritance diagram for sammine_lang::Parser:
Collaboration diagram for sammine_lang::Parser:

Public Types

template<class T>
using p = std::pair<std::unique_ptr<T>, ParserError>
 
template<class T>
using u = std::unique_ptr<T>
 
- Public Types inherited from sammine_util::Reportee
enum  ReportKind { error , warn , diag }
 
using Report = std::tuple<Location, std::string, ReportKind>
 
using iterator = std::vector<Report>::iterator
 
using const_iterator = std::vector<Report>::const_iterator
 

Public Member Functions

auto ParseProgram () -> u< ProgramAST >
 
auto ParseDefinition () -> p< DefinitionAST >
 
auto ParsePrototype () -> p< PrototypeAST >
 
auto ParseFuncDef () -> p< DefinitionAST >
 
auto ParseVarDef () -> p< ExprAST >
 Parsing implementation for a variable decl/def.
 
auto ParseRecordDef () -> p< DefinitionAST >
 
auto ParseTypedVar () -> p< TypedVarAST >
 
auto ParseExpr () -> p< ExprAST >
 
auto ParsePrimaryExpr () -> p< ExprAST >
 
auto ParseBinaryExpr (int prededence, u< ExprAST > LHS) -> p< ExprAST >
 
auto ParseBoolExpr () -> p< ExprAST >
 
auto ParseCallExpr () -> p< ExprAST >
 
auto ParseReturnExpr () -> p< ExprAST >
 
auto ParseArguments () -> std::pair< std::vector< u< ExprAST > >, ParserError >
 
auto ParseParenExpr () -> p< ExprAST >
 
auto ParseIfExpr () -> p< ExprAST >
 
auto ParseNumberExpr () -> p< ExprAST >
 
auto ParseStringExpr () -> p< ExprAST >
 
auto ParseVariableExpr () -> p< ExprAST >
 
auto ParseBlock () -> p< BlockAST >
 
auto ParseParams () -> std::pair< std::vector< u< TypedVarAST > >, ParserError >
 
auto expect (TokenType tokType, bool exhausts=false, TokenType until=TokenType::TokEOF, const std::string &message="") -> std::shared_ptr< Token >
 
 Parser (std::optional< std::reference_wrapper< Reporter > > reporter=std::nullopt)
 
 Parser (std::shared_ptr< TokenStream > tokStream, std::optional< std::reference_wrapper< Reporter > > reporter=std::nullopt)
 
auto Parse () -> u< ProgramAST >
 
- Public Member Functions inherited from sammine_util::Reportee
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 
virtual void abort (const std::string &msg="<NO MESSAGE>")
 
template<explicitly_bool_like T>
void abort_on (const T &condition, const std::string &message="<NO MESSAGE>")
 
template<explicitly_bool_like T>
void abort_if_not (const T &condition, const std::string &message="<NO MESSAGE>")
 
void add_error (Location loc, std::string msg)
 
void add_warn (Location loc, std::string msg)
 
void add_diagnostics (Location loc, std::string msg)
 
virtual bool has_errors () const
 
bool has_warn () const
 
bool has_message () const
 
bool has_diagnostics () const
 
int64_t get_error_count () const
 
int64_t get_warn_count () const
 
int64_t get_diagnostic_count () const
 

Public Attributes

std::optional< std::reference_wrapper< Reporter > > reporter
 
std::shared_ptr< TokenStreamtokStream
 

Additional Inherited Members

- Protected Attributes inherited from sammine_util::Reportee
std::vector< Report > reports
 
int64_t error_count = 0
 
int64_t warn_count = 0
 
int64_t diag_count = 0
 

Member Function Documentation

◆ ParseVarDef()

auto sammine_lang::Parser::ParseVarDef ( ) -> p<ExprAST>
nodiscard

Parsing implementation for a variable decl/def.

Accepts a let, continue parsing inside and (enable error reporting if possible). If a let is not found then return a nullptr.


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