#!/usr/bin/env python3 # WARNING: CAVEAT UTILITOR # # This file was automatically generated by TatSu. # # https://pypi.python.org/pypi/tatsu/ # # Any changes you make to it will be overwritten the next time # the file is generated. # ruff: noqa: C405, COM812, I001, F401, PLR1702, PLC2801, SIM117 import sys from pathlib import Path from tatsu.buffering import Buffer from tatsu.parsing import Parser from tatsu.parsing import tatsumasu from tatsu.parsing import leftrec, nomemo, isname from tatsu.infos import ParserConfig from tatsu.util import re, generic_main KEYWORDS: set[str] = set() class EBNFBootstrapBuffer(Buffer): def __init__(self, text, /, config: ParserConfig | None = None, **settings): config = ParserConfig.new( config, owner=self, whitespace='(?m)\\s+', nameguard=None, ignorecase=False, namechars='', parseinfo=True, comments='(?sm)[(][*](?:.|\\n)*?[*][)]', eol_comments='(?sm)*#[^\\n]*$', keywords=KEYWORDS, start='start', ) config = config.replace(**settings) super().__init__(text, config=config) class EBNFBootstrapParser(Parser): def __init__(self, /, config: ParserConfig | None = None, **settings): config = ParserConfig.new( config, owner=self, whitespace='\\s+', nameguard=None, ignorecase=False, namechars='', parseinfo=True, comments='(?sm)[(][*](?:.|\\n)*?[*][)]', eol_comments='(?m)#[^\\n]*$', keywords=KEYWORDS, start='start', ) config = config.replace(**settings) super().__init__(config=config) @tatsumasu() def _start_(self): self._grammar_() @tatsumasu('Grammar') def _grammar_(self): self._constant('TATSU') self.name_last_node('title') def block0(): with self._choice(): with self._option(): self._directive_() self.add_last_node_to_name('directives') with self._option(): self._keyword_() self.add_last_node_to_name('keywords') self._error( 'expecting one of: ' ' ' ) self._closure(block0) self._rule_() self.add_last_node_to_name('rules') def block1(): with self._choice(): with self._option(): self._rule_() self.add_last_node_to_name('rules') with self._option(): self._keyword_() self.add_last_node_to_name('keywords') self._error( 'expecting one of: ' ' ' ) self._closure(block1) self._check_eof() self._define( ['title'], ['directives', 'keywords', 'rules'], ) @tatsumasu() def _directive_(self): self._token('@@') with self._ifnot(): self._token('keyword') self._cut() with self._group(): with self._choice(): with self._option(): with self._group(): with self._choice(): with self._option(): self._token('comments') with self._option(): self._token('eol_comments') self._error( 'expecting one of: ' "'comments' 'eol_comments'" ) self.name_last_node('name') self._cut() self._cut() self._token('::') self._cut() self._regex_() self.name_last_node('value') self._define(['name', 'value'], []) with self._option(): with self._group(): self._token('whitespace') self.name_last_node('name') self._cut() self._cut() self._token('::') self._cut() with self._group(): with self._choice(): with self._option(): self._regex_() with self._option(): self._string_() with self._option(): self._token('None') with self._option(): self._token('False') with self._option(): self._constant('None') self._error( 'expecting one of: ' "'False' 'None' " ) self.name_last_node('value') self._define(['name', 'value'], []) with self._option(): with self._group(): with self._choice(): with self._option(): self._token('nameguard') with self._option(): self._token('ignorecase') with self._option(): self._token('left_recursion') with self._option(): self._token('parseinfo') self._error( 'expecting one of: ' "'ignorecase' 'left_recursion'" "'nameguard' 'parseinfo'" ) self.name_last_node('name') self._cut() with self._group(): with self._choice(): with self._option(): self._token('::') self._cut() self._boolean_() self.name_last_node('value') self._define(['value'], []) with self._option(): self._constant(True) self.name_last_node('value') self._error( 'expecting one of: ' "'::'" ) self._define(['name', 'value'], []) with self._option(): with self._group(): self._token('grammar') self.name_last_node('name') self._cut() self._token('::') self._cut() self._word_() self.name_last_node('value') self._define(['name', 'value'], []) with self._option(): with self._group(): self._token('namechars') self.name_last_node('name') self._cut() self._token('::') self._cut() self._string_() self.name_last_node('value') self._define(['name', 'value'], []) self._error( 'expecting one of: ' "'comments' 'eol_comments' 'grammar'" "'ignorecase' 'left_recursion'" "'namechars' 'nameguard' 'parseinfo'" "'whitespace'" ) self._cut() self._define(['name', 'value'], []) @tatsumasu() def _keywords_(self): def block0(): self._keywords_() self._positive_closure(block0) @tatsumasu() def _keyword_(self): self._token('@@keyword') self._cut() self._token('::') self._cut() def block0(): with self._group(): with self._choice(): with self._option(): self._word_() with self._option(): self._string_() self._error( 'expecting one of: ' ' ' ) self.add_last_node_to_name('@') with self._ifnot(): with self._group(): with self._choice(): with self._option(): self._token(':') with self._option(): self._token('=') self._error( 'expecting one of: ' "':' '='" ) self._closure(block0) @tatsumasu() def _paramdef_(self): with self._choice(): with self._option(): self._token('::') self._cut() self._params_() self.name_last_node('params') self._define(['params'], []) with self._option(): self._token('(') self._cut() with self._group(): with self._choice(): with self._option(): self._kwparams_() self.name_last_node('kwparams') with self._option(): self._params_() self.name_last_node('params') self._token(',') self._cut() self._kwparams_() self.name_last_node('kwparams') self._define(['kwparams', 'params'], []) with self._option(): self._params_() self.name_last_node('params') self._error( 'expecting one of: ' ' ' ) self._token(')') self._define(['kwparams', 'params'], []) self._error( 'expecting one of: ' "'(' '::'" ) @tatsumasu('Rule') def _rule_(self): def block0(): self._decorator_() self._closure(block0) self.name_last_node('decorators') self._name_() self.name_last_node('name') self._cut() with self._optional(): with self._choice(): with self._option(): self._token('::') self._cut() self._params_() self.name_last_node('params') self._define(['params'], []) with self._option(): self._token('(') self._cut() with self._group(): with self._choice(): with self._option(): self._kwparams_() self.name_last_node('kwparams') with self._option(): self._params_() self.name_last_node('params') self._token(',') self._cut() self._kwparams_() self.name_last_node('kwparams') self._define(['kwparams', 'params'], []) with self._option(): self._params_() self.name_last_node('params') self._error( 'expecting one of: ' ' ' ) self._token(')') self._define(['kwparams', 'params'], []) self._error( 'expecting one of: ' "'(' '::'" ) with self._optional(): self._token('<') self._cut() self._known_name_() self.name_last_node('base') self._define(['base'], []) self._token('=') self._cut() self._expre_() self.name_last_node('exp') self._token(';') self._cut() self._define(['base', 'decorators', 'exp', 'kwparams', 'name', 'params'], []) @tatsumasu() def _decorator_(self): self._token('@') with self._ifnot(): self._token('@') self._cut() with self._group(): with self._choice(): with self._option(): self._token('override') with self._option(): self._token('name') with self._option(): self._token('nomemo') self._error( 'expecting one of: ' "'name' 'nomemo' 'override'" ) self.name_last_node('@') @tatsumasu() def _params_(self): self._first_param_() self.add_last_node_to_name('@') def block0(): self._token(',') self._literal_() self.add_last_node_to_name('@') with self._ifnot(): self._token('=') self._cut() self._closure(block0) @tatsumasu() def _first_param_(self): with self._choice(): with self._option(): self._path_() with self._option(): self._literal_() self._error( 'expecting one of: ' '(?!\\d)\\w+(?:::(?!\\d)\\w+)+ ' ' ' ' ' ) @tatsumasu() def _kwparams_(self): def sep0(): self._token(',') def block1(): self._pair_() self._positive_gather(block1, sep0) @tatsumasu() def _pair_(self): self._word_() self.add_last_node_to_name('@') self._token('=') self._cut() self._literal_() self.add_last_node_to_name('@') @tatsumasu() def _expre_(self): with self._choice(): with self._option(): self._choice_() with self._option(): self._sequence_() self._error( 'expecting one of: ' "'|'