hare::parse+x86_64 +linux

hare::parse provides a parser for Hare source code. The subunit function will parse a single Hare source file and return a hare::ast::subunit. Other functions provide parsers for various important Hare sub-terminals, such as decls and imports. See the Hare specification for more details:

https://harelang.org/specification

Most of these functions require the caller to provide a Hare lexer, see hare::lex:: for details.

Submodules

Index

Errors

type error = !lex::error;

Functions

fn _type(lexer: *lex::lexer) (ast::_type | error);
fn decl(lexer: *lex::lexer) (ast::decl | error);
fn decls(lexer: *lex::lexer) ([]ast::decl | error);
fn define(lexer: *lex::lexer) (ast::decl_const | error);
fn expr(lexer: *lex::lexer) (ast::expr | error);
fn ident(lexer: *lex::lexer) (ast::ident | error);
fn ident_trailing(lexer: *lex::lexer) ((ast::ident, bool) | error);
fn identstr(in: str) (ast::ident | error);
fn imports(lexer: *lex::lexer) ([]ast::import | error);
fn strerror(err: error) const str;
fn subunit(lexer: *lex::lexer) (ast::subunit | error);

Errors

type error[link]

type error = !lex::error;

All possible error types.

Functions

fn _type[link]

fn _type(lexer: *lex::lexer) (ast::_type | error);

Parses a type, e.g. '[]int'.

fn decl[link]

fn decl(lexer: *lex::lexer) (ast::decl | error);

Parses a declaration.

fn decls[link]

fn decls(lexer: *lex::lexer) ([]ast::decl | error);

Parses the declarations for a sub-unit.

fn define[link]

fn define(lexer: *lex::lexer) (ast::decl_const | error);

Parses a command-line definition

fn expr[link]

fn expr(lexer: *lex::lexer) (ast::expr | error);

Parses an expression.

fn ident[link]

fn ident(lexer: *lex::lexer) (ast::ident | error);

Parses a single identifier, i.e. 'foo::bar::baz'.

fn ident_trailing[link]

fn ident_trailing(lexer: *lex::lexer) ((ast::ident, bool) | error);

Parses a single identifier, possibly with a trailing ::, i.e. 'foo::bar::'. Returns the identifier and whether there's a trailing ::.

fn identstr[link]

fn identstr(in: str) (ast::ident | error);

A convenience function which parses an identifier from a string, so the caller needn't provide a lexer instance.

fn imports[link]

fn imports(lexer: *lex::lexer) ([]ast::import | error);

Parses the import list for a sub-unit

fn strerror[link]

fn strerror(err: error) const str;

Convert an error into a human-friendly string. The result may be statically allocated.

fn subunit[link]

fn subunit(lexer: *lex::lexer) (ast::subunit | error);

Parses an entire subunit (i.e. one Hare source file).