Help us shape the future of Go! Take the 2026 Go Developer Survey

parser

package
v0.31.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 13, 2026 License: Apache-2.0, Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package parser turns writ policy source into the AST. The grammar is LL(1) at statement start (SPEC §4); this is a hand-written lexer and recursive-descent parser because the statement terminator is lexical state and the forbidden forms (a negated allow, a headless rule, an allow-only clause on a deny, `!` on a list atom) deserve pointed diagnostics rather than a generic expectation list.

A statement with errors is reported and dropped; parsing resumes at the next statement.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(src string) (*ast.File, []diag.Diagnostic)

Parse parses policy source. The returned file holds every statement that parsed cleanly; statements with errors are dropped and reported.

func ParseDuration

func ParseDuration(s string) (uint64, error)

ParseDuration parses a writ duration — integer plus s/m/h parts, composable: 2m, 90s, 1h30m — returning whole seconds. Zero is rejected: the IL uses zero as its "no ttl set" sentinel, and a zero-lifetime certificate is never what an author meant.

func ValidateTimestamp

func ValidateTimestamp(s string) error

ValidateTimestamp shape-checks an RFC 3339 timestamp with a mandatory offset. Seconds may be omitted (the spec writes "2026-08-31T22:00Z"). Calendar validity beyond cheap range checks is apply-time work.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL