ebnf

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(grammar string, options ...Option) (lexer.Definition, error)

New creates a Lexer from an EBNF grammar.

The EBNF grammar syntax is as defined by "golang.org/x/exp/ebnf" with one extension: ranges also support exclusions, eg. "a"…"z"-"f" and "a"…"z"-"f"…"g". Exclusions can be chained.

Upper-case productions are exported as terminals. Lower-case productions are non-terminals. All productions are lexical.

Here's an example grammar for parsing whitespace and identifiers:

Identifier = alpha { alpha | number } .
Whitespace = "\n" | "\r" | "\t" | " " .
alpha = "a"…"z" | "A"…"Z" | "_" .
number = "0"…"9" .

Types

type Option

type Option func(*ebnfLexerDefinition)

Option for configuring the EBNF lexer.

Directories

Path Synopsis
Package internal is a library for EBNF grammars.
Package internal is a library for EBNF grammars.

Jump to

Keyboard shortcuts

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