hare::parse +linux +x86_64

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:


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



type error;


fn _type(*lex::lexer) (ast::_type | error);
fn decl(*lex::lexer) (ast::decl | error);
fn decls(*lex::lexer) ([]ast::decl | error);
fn expr(*lex::lexer) (ast::expr | error);
fn ident(*lex::lexer) (ast::ident | error);
fn identstr(str) (ast::ident | error);
fn imports(*lex::lexer) ([]ast::import | error);
fn strerror(error) const str;
fn subunit(*lex::lexer) (ast::subunit | error);


type error[link]

type error = !lex::error;

All possible error types.


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

fn subunit[link]

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

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