https://github.com/willfaught/ebnf
Parse and inspect EBNF grammars
https://github.com/willfaught/ebnf
ebnf go golang
Last synced: 5 months ago
JSON representation
Parse and inspect EBNF grammars
- Host: GitHub
- URL: https://github.com/willfaught/ebnf
- Owner: willfaught
- License: mit
- Created: 2022-05-13T19:15:17.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-03-25T02:24:36.000Z (over 1 year ago)
- Last Synced: 2025-04-26T03:09:35.318Z (5 months ago)
- Topics: ebnf, go, golang
- Language: Go
- Homepage: https://go.dev/pkg/github.com/willfaught/ebnf
- Size: 55.7 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ebnf
[](https://pkg.go.dev/github.com/willfaught/ebnf)
Package ebnf represents and parses a variant of [Extended Backus-Naur Form] called
[Wirth Syntax Notation]. Terminal identifiers must begin with a lowercase letter.
Non-terminal identifiers must begin with an uppercase letter. The first
production defines the start non-terminal identifier. Terminal identifiers are
assumed to be defined elsewhere. Epsilon is represented by an empty literal.Grammars are written like so:
Expression = Term { ( "+" | "-" ) Term } .
Term = Factor { ( "*" | "/" ) Factor } .
Factor = Number | "(" Expression ")" .
Number = Digit { Digit } .
Digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" .They can be parsed by Parse into a Grammar. Grammar.Validate determines whether
a grammar is valid. Grammar.First and Grammar.Follow compute the first and
follow sets for non-terminal identifiers. Grammar.Conflict determines whether a
valid grammar can be parsed by an LL(1) parser.[Extended Backus-Naur Form]: https://en.wikipedia.org/wiki/Extended_Backus–Naur_form
[Wirth Syntax Notation]: https://en.wikipedia.org/wiki/Wirth_syntax_notation