EBNF Compiler

A tool for parsing and compiling Extended Backus-Naur Form (EBNF) grammars.

📚 Module Documentation

Explore the API documentation and module reference.

Modules
🔍 API Reference

Complete index of all classes, functions, and variables.

genindex

Modules

EBNF Compiler

class ebnf_compiler.Compiler(scanner: ebnf_compiler.scanner.Scanner, parser: ebnf_compiler.parser.Parser)[source]

Bases: object

ast() Syntax | None[source]
parser: Parser
scanner: Scanner
ebnf_compiler.main(source: ~typing.Annotated[~pathlib.Path, <typer.models.ArgumentInfo object at 0x7f60ca3042f0>], debug: bool = False, show_tree: bool = True, analyze: bool = True)[source]

EBNF Scanner

class ebnf_compiler.scanner.Scanner(eof: bool = False, sym: ebnf_compiler.tokens.Token | None = None, value: str = '', _ch: str = '', _file_name: pathlib._local.Path | None = None, _text: TextIO | None = None, _text_line: str = '', _line_no: int = 0, _col_no: int = 0)[source]

Bases: object

eof: bool = False
get_next_char() None[source]
get_next_symbol()[source]
init(f: TextIO) None[source]
open(file_name: Path) None[source]
print_error(msg: str)[source]
skip_space() None[source]
sym: Token | None = None
token_map: ClassVar[dict[str, Token]] = {'(': Token.LPAREN, ')': Token.RPAREN, '.': Token.PERIOD, '=': Token.EQL, '[': Token.LBRAK, ']': Token.RBRAK, '{': Token.LBRACE, '|': Token.BAR, '}': Token.RBRACE}
value: str = ''

EBNF Parser

class ebnf_compiler.parser.Parser(scanner: ebnf_compiler.scanner.Scanner, has_error: bool = False)[source]

Bases: object

expression() Expression[source]
factor() Factor[source]
has_error: bool = False
parse() Syntax[source]
production() Production[source]
raise_error(msg: str) None[source]
raise_expected_error(expected: Token)[source]
scanner: Scanner
syntax() Syntax[source]
term() Term[source]

EBNF Tokens

class ebnf_compiler.tokens.Token(*values)[source]

Bases: Enum

BAR = 6
EOF = 13
EQL = 7
IDENT = 1
LBRACE = 5
LBRAK = 4
LITERAL = 2
LPAREN = 3
OTHER = 12
PERIOD = 11
RBRACE = 10
RBRAK = 9
RPAREN = 8

Indices and tables