Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Syntax.Parse

The public Prism-owned parser.

The compiler remains the bootstrap oracle, but this module is a complete value-passing entry seam: source text is lexed and laid out by the Prism frontend, then declarations and expressions consume that exact post-layout token stream without calling back into Rust.

Types

ParseFailure

type ParseFailure = ParseLex(LexError) | ParseSyntax(Diagnostic)

A source-level parse failure, preserving whether lexing or parsing refused the input.

Functions and Values

parse_program_tokens

parse_program_tokens : (List(Syntax.Token.Token), Int) -> Result(List(Syntax.Ast.Item), Syntax.Diagnostic.Diagnostic)

Parse an already-laid-out whole-program token stream.

parse_source

parse_source : (String) -> Result(List(Syntax.Ast.Item), Syntax.Parse.ParseFailure)

Lex, lay out, and parse one complete Prism source file.

parse_expr_tokens

parse_expr_tokens : (List(Syntax.Token.Token), Int) -> Result(Syntax.Ast.Sp(Syntax.Ast.Expr), Syntax.Diagnostic.Diagnostic)

Parse one expression from a token cursor and require complete consumption.

parse_expr_source

parse_expr_source : (String) -> Result(Syntax.Ast.Sp(Syntax.Ast.Expr), Syntax.Parse.ParseFailure)

Lex, lay out, and parse a standalone expression. Layout wraps a complete input in its top-level virtual block, so the expression entry removes that envelope before requiring the stream end.