Module

tuck/parser

src/tuck/parser.pooka

Reading the tags in order, and remembering which ones are still open.

A recursive-descent parser: each kind of tag has a function that reads it and everything up to its end tag, and expressions are read from the loosest operator (or) down to single values. Any mistake becomes a TuckError pointing at the token that did not fit.

API reference

function

parse

src/tuck/parser.pooka:56
parse(template: String, lexemes: List(Lexeme)) -> Result(Document, TuckError)
INFERREDfn(String, List(tuck/lexer.Lexeme)) -> Result(tuck/ast.Document, tuck/error.TuckError)

Read a template's lexemes into a document.

Pooka
import tuck/lexer
import tuck/parser

let assert Ok(lexemes) = lexer.lex("page", "{% if ok %}yes{% endif %}")
let assert Ok(document) = parser.parse("page", lexemes)
assert document.extends == None