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 = ParseResult<T>
template<class T>
using u = std::unique_ptr<T>
template<class T>
using ListResult = std::pair<std::vector<u<T>>, ParserError>
Public Types inherited from sammine_util::Reportee
enum  ReportKind { error , warn , diag }
using Report
using iterator = std::vector<Report>::iterator
using const_iterator = std::vector<Report>::const_iterator

Public Member Functions

auto ParseImport () -> std::optional< AST::ImportDecl >
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 ParseStructDef () -> p< DefinitionAST >
auto ParseEnumDef () -> p< DefinitionAST >
auto ParseTypeClassDecl () -> p< DefinitionAST >
auto ParseTypeClassInstance () -> p< DefinitionAST >
auto ParseTypeExprTopLevel () -> std::unique_ptr< TypeExprAST >
auto ParseTypeExpr () -> std::unique_ptr< TypeExprAST >
auto ParseTypedVar () -> p< TypedVarAST >
auto ParseExpr () -> p< ExprAST >
auto ParsePrimaryExpr () -> p< ExprAST >
auto parsePostfixOps (u< ExprAST > expr) -> p< ExprAST >
auto ParseBinaryExpr (int prededence, u< ExprAST > LHS) -> p< ExprAST >
auto ParseBoolExpr () -> p< ExprAST >
auto ParseCharExpr () -> p< ExprAST >
auto ParseUnaryNegExpr () -> p< ExprAST >
auto ParseDerefExpr () -> p< ExprAST >
auto ParseAddrOfExpr () -> p< ExprAST >
auto ParseAllocExpr () -> p< ExprAST >
auto ParseFreeExpr () -> p< ExprAST >
auto ParseLenExpr () -> p< ExprAST >
auto ParseArrayLiteralExpr () -> p< ExprAST >
auto ParseCallExpr () -> p< ExprAST >
auto ParseStructLiteralExpr (sammine_util::QualifiedName qn, Location qn_loc) -> p< ExprAST >
auto ParseReturnExpr () -> p< ExprAST >
auto ParseArguments () -> ListResult< ExprAST >
auto ParseParenExpr () -> p< ExprAST >
auto ParseIfExpr () -> p< ExprAST >
auto ParseCaseExpr () -> p< ExprAST >
auto ParseWhileExpr () -> p< ExprAST >
auto ParseNumberExpr () -> p< ExprAST >
auto ParseStringExpr () -> p< ExprAST >
auto ParseVariableExpr () -> p< ExprAST >
auto ParseBlock () -> p< BlockAST >
auto ParseParams () -> ListResult< TypedVarAST >
auto expect (TokenType tokType, bool exhausts=false, TokenType until=TokenType::TokEOF, const std::string &message="") -> std::shared_ptr< Token >
auto parseQualifiedNameTail (std::shared_ptr< Token > first_tok, bool resolve_alias=true) -> ParsedQualifiedName
auto parseExplicitTypeArgsTail (sammine_util::QualifiedName &qn, sammine_util::Location &qn_loc) -> std::vector< std::unique_ptr< TypeExprAST > >
auto consumeClosingAngleBracket () -> bool
 Parser (std::optional< std::reference_wrapper< Reporter > > reporter=std::nullopt, const std::string &default_namespace="")
 Parser (std::shared_ptr< TokenStream > tokStream, std::optional< std::reference_wrapper< Reporter > > reporter=std::nullopt, const std::string &default_namespace="")
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, std::source_location src=std::source_location::current())
void add_error (Location loc, std::vector< std::string > msgs, std::source_location src=std::source_location::current())
void add_warn (Location loc, std::string msg, std::source_location src=std::source_location::current())
void add_diagnostics (Location loc, std::string msg, std::source_location src=std::source_location::current())
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
std::map< std::string, std::string > alias_to_module
bool parsed_var_arg = false
int pending_deref = 0
std::shared_ptr< Tokenpending_deref_tok

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

◆ parseExplicitTypeArgsTail()

auto sammine_lang::Parser::parseExplicitTypeArgsTail ( sammine_util::QualifiedName & qn,
sammine_util::Location & qn_loc ) -> std::vector< std::unique_ptr< TypeExprAST > >
nodiscard

Speculatively parse <TypeExpr, ...> after a qualified name. On success, populates type_args and may update qn/qn_loc if ::member follows. On failure, rolls back the token stream and returns empty.

◆ parseQualifiedNameTail()

auto sammine_lang::Parser::parseQualifiedNameTail ( std::shared_ptr< Token > first_tok,
bool resolve_alias = true ) -> ParsedQualifiedName
nodiscard

Greedily consume ::ID pairs after an already-consumed first TokID.

Parameters
first_tokThe already-consumed TokID token
resolve_aliasIf true, resolve first segment through alias_to_module

◆ 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: