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 ¶
Click to show internal directories.
Click to hide internal directories.