ebnf

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package ebnf lints the grammar files under docs/.

They are Wirth syntax notation rather than ISO 14977, so no ISO tool reads them. golang.org/x/exp/ebnf does: it documents this exact dialect, including the convention that an upper-case name is a nonterminal and a lower-case one is lexical. Parsing and reachability come from there.

What is here is the check no library makes. A quoted terminal has to be text lex turns into exactly one token, so a spelling the grammar invents is an error rather than a rule that could never match.

Index

Constants

This section is empty.

Variables

View Source
var GrammarOptions = Options{Start: "File", LexSpellings: true}

GrammarOptions reads docs/grammar.ebnf.

View Source
var NotationOptions = Options{Start: "Grammar"}

NotationOptions reads docs/notation.ebnf, which describes the notation rather than TDL, so its quoted terminals are not TDL tokens.

Functions

func Lint

func Lint(filename, src string, opts Options) []error

Lint reports every problem it finds.

A parse error is returned alone: a file that did not parse produces nothing worth saying about its contents.

Types

type Options

type Options struct {
	// Start is the production everything must be reachable from.
	Start string

	// LexSpellings requires every quoted terminal to be text lex turns
	// into exactly one token. It holds for a grammar of TDL and not for a
	// grammar of anything else.
	LexSpellings bool
}

Options say how to read one grammar file.

Jump to

Keyboard shortcuts

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