ebnf

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: MIT Imports: 6 Imported by: 0

README

ebnf

Go module that parses EBNF grammars.

Go Reference

Documentation

Overview

Package ebnf parses extended Backus-Naur Form (EBNF) grammars.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Expr

type Expr struct {
	Terms []*Term
}

Expr is the right side of a production.

type Factor

type Factor struct {
	Ident   string
	Literal string
	Paren   *Expr
	Brak    *Expr
	Brace   *Expr
}

Factor is a concrete form that can be sequenced.

type Grammar

type Grammar struct {
	Prods []*Prod
}

Grammar is an abstract syntax tree for a grammar.

func Parse

func Parse(s string) (*Grammar, error)

Parse returns a Grammar for a valid grammar, or an error otherwise.

type ParserError

type ParserError struct {
	Errs []error
}

ParserError has all the parse errors.

func (ParserError) Error

func (e ParserError) Error() string

Error returns all the error strings joined by a newline.

type Prod

type Prod struct {
	Ident string
	Expr  *Expr
}

Prod is a production.

type Term

type Term struct {
	Factors []*Factor
}

Term is an alternative.

Jump to

Keyboard shortcuts

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