#!/usr/bin/env python3
#
#  CAVEAT UTILITOR
#
#  This file was automatically generated by 竜TatSu v5.23.1b1
#
#     https://pypi.python.org/pypi/tatsu/
#
#  Any changes you make to it will be overwritten the next time
#  the file is generated.
#
# noqa # type: ignore # ruff: noqa
# copyright: ignore
# fmt: off

from __future__ import annotations
from typing import Any

from tatsu.config import ParserConfig
from tatsu.contexts import CanParse
from tatsu.input import Text
from tatsu.input.buffer import Buffer
from tatsu.input.textlines import TextLines
from tatsu.peg import *


class TatSuBootstrapParser(CanParse):
    def __init__(self, config: Any = None, **settings: Any):
        self.config = ParserConfig.new(config, **settings)
        self.model = GRAMMAR_MODEL

    def parse(
        self,
        text: str | Text,
        /,
        *,
        start: str | None = None,
        asmodel: bool = True,
        config: Any = None,
        **settings: Any,
    ) -> Any:
        # NOTE
        #   Copy the grammar so the configuration is unique to this parse
        #   and one parse doesn't leak settings to another.
        #   There may be also configurations that are unique to this parse.
        model = Grammar(
            name=self.model.name,
            rules=self.model.rules,
            directives=self.model.directives,
            keywords=self.model.keywords,
            config=self.config,
        )
        config = ParserConfig.new(config, **settings)
        return model.parse(text, asmodel=asmodel, config=config)


GRAMMAR_MODEL: Grammar = (
    Grammar(
      name='TatSuBootstrap',
      directives={
        'grammar': 'TatSu',
        'comments': '(?ms)[(][*]\\s*(.*?)\\s*[*][)]|/[*]\\s*(.*?)\\s*[*]/',
        'eol_comments': '(?ms)(?:#|//)(.*?)$',
        'parseinfo': True,
        'left_recursion': False
      },
      keywords=(),
      rules=(
        Rule(
          name='start',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Call('grammar')
        ),
        Rule(
          name='grammar',
          params=['Grammar'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence(
            [
              Named(name='title', exp=Constant('TATSU')),
              Closure(
                Choice(
                  [
                    NamedList(name='directives', exp=Call('directive')),
                    NamedList(name='keywords', exp=Call('keyword'))
                  ]
                )
              ),
              NamedList(name='rules', exp=Call('rule')),
              Closure(
                Choice(
                  [
                    NamedList(name='rules', exp=Call('rule')),
                    NamedList(name='keywords', exp=Call('keyword'))
                  ]
                )
              ),
              EOF()
            ]
          )
        ),
        Rule(
          name='directive',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence(
            [
              Token('@@'),
              NegativeLookahead(Token('keyword')),
              Cut(),
              Group(
                Choice(
                  [
                    Sequence(
                      [
                        Named(name='name', exp=Group(Choice([Token('comments'), Token('eol_comments')]))),
                        Cut(),
                        Token('::'),
                        Cut(),
                        Named(name='value', exp=Call('regex'))
                      ]
                    ),
                    Sequence(
                      [
                        Named(name='name', exp=Token('whitespace')),
                        Cut(),
                        Token('::'),
                        Cut(),
                        Named(
                          name='value',
                          exp=Group(
                            Choice([Call('regex'), Call('string'), Token('None'), Token('False'), Constant()])
                          )
                        )
                      ]
                    ),
                    Sequence(
                      [
                        Named(
                          name='name',
                          exp=Group(
                            Choice(
                              [
                                Token('nameguard'),
                                Token('ignorecase'),
                                Token('left_recursion'),
                                Token('parseinfo'),
                                Token('memoization')
                              ]
                            )
                          )
                        ),
                        Cut(),
                        Group(
                          Choice(
                            [
                              Sequence([Token('::'), Cut(), Named(name='value', exp=Call('boolean'))]),
                              Named(name='value', exp=Constant(True))
                            ]
                          )
                        )
                      ]
                    ),
                    Sequence(
                      [
                        Named(name='name', exp=Token('grammar')),
                        Cut(),
                        Token('::'),
                        Cut(),
                        Named(name='value', exp=Call('word'))
                      ]
                    ),
                    Sequence(
                      [
                        Named(name='name', exp=Token('namechars')),
                        Cut(),
                        Token('::'),
                        Cut(),
                        Named(name='value', exp=Call('string'))
                      ]
                    )
                  ]
                )
              ),
              Cut()
            ]
          )
        ),
        Rule(
          name='keywords',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=PositiveClosure(Call('keyword'))
        ),
        Rule(
          name='keyword',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence(
            [
              Token('@@keyword'),
              Cut(),
              Token('::'),
              Group(
                Choice(
                  [
                    Sequence(
                      [
                        Token('('),
                        Cut(),
                        Override(PositiveClosure(Choice([Call('word'), Call('string')]))),
                        Token(')')
                      ]
                    ),
                    PositiveClosure(
                      Sequence(
                        [
                          OverrideList(Group(Choice([Call('word'), Call('string')]))),
                          NegativeLookahead(Group(Choice([Token(':'), Token('=')])))
                        ]
                      )
                    )
                  ]
                )
              )
            ]
          )
        ),
        Rule(
          name='params',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence(
            [
              OverrideList(Call('first_param')),
              Closure(
                Sequence(
                  [
                    Token(','),
                    OverrideList(Call('literal')),
                    NegativeLookahead(Token('=')),
                    Cut()
                  ]
                )
              )
            ]
          )
        ),
        Rule(
          name='first_param',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Choice([Call('path'), Call('literal')])
        ),
        Rule(
          name='kwparams',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=PositiveGather(exp=Call('pair'), sep=Token(','))
        ),
        Rule(
          name='the_params_at_last',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Choice(
            [
              Named(name='kwparams', exp=Call('kwparams')),
              Sequence(
                [
                  Named(name='params', exp=Call('params')),
                  Token(','),
                  Cut(),
                  Named(name='kwparams', exp=Call('kwparams'))
                ]
              ),
              Named(name='params', exp=Call('params'))
            ]
          )
        ),
        Rule(
          name='paramdef',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Choice(
            [
              Sequence([Token('['), Cut(), RuleInclude('the_params_at_last'), Token(']')]),
              Sequence([Token('('), Cut(), RuleInclude('the_params_at_last'), Token(')')]),
              Sequence([Token('::'), Cut(), Named(name='params', exp=Call('params'))])
            ]
          )
        ),
        Rule(
          name='rule',
          params=['Rule'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence(
            [
              Named(name='decorators', exp=Closure(Call('decorator'))),
              Named(name='name', exp=NameMeta()),
              Cut(),
              Optional(RuleInclude('paramdef')),
              Optional(Sequence([Token('<'), Cut(), Named(name='base', exp=Call('known_name'))])),
              Void(),
              Pattern('=|::=|:=?'),
              Cut(),
              Named(name='exp', exp=Call('expre')),
              Call('ENDRULE'),
              Cut()
            ]
          )
        ),
        Rule(
          name='ENDRULE',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=True,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Choice([Call('DEDENT'), Call('BLANK'), Token(';'), EOF()])
        ),
        Rule(
          name='DEDENT',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=True,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence([Call('EOL'), Lookahead(Pattern('^\\S'))])
        ),
        Rule(
          name='BLANK',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=True,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence([Call('EOL'), Call('EOL')])
        ),
        Rule(
          name='EOL',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=True,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence([Pattern('(?m)[ \\t]*$'), Pattern('(?m)(?:\\r?\\n|\\r)')])
        ),
        Rule(
          name='decorator',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence(
            [
              Token('@'),
              NegativeLookahead(Token('@')),
              Cut(),
              Override(Pattern('(override|name|isname|nomemo|nostak)\\b'))
            ]
          )
        ),
        Rule(
          name='pair',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence(
            [OverrideList(Call('word')), Token('='), Cut(), OverrideList(Call('literal'))]
          )
        ),
        Rule(
          name='expre',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Choice([Call('choice'), Call('sequence')])
        ),
        Rule(
          name='choice',
          params=['Choice'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence(
            [
              Optional(Sequence([Token('|'), Cut()])),
              OverrideList(Call('option')),
              PositiveClosure(Sequence([Token('|'), Cut(), OverrideList(Call('option'))]))
            ]
          )
        ),
        Rule(
          name='option',
          params=['Option'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Call('sequence')
        ),
        Rule(
          name='sequence',
          params=['Sequence'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Choice(
            [
              Sequence(
                [
                  Lookahead(Group(Sequence([Call('element'), Token(',')]))),
                  PositiveGather(exp=Call('element'), sep=Token(','))
                ]
              ),
              PositiveClosure(Sequence([NegativeLookahead(Call('ENDRULE')), Call('element')]))
            ]
          )
        ),
        Rule(
          name='element',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Choice(
            [
              Call('override'),
              Call('meta'),
              Call('named'),
              Call('term'),
              Call('rule_include')
            ]
          )
        ),
        Rule(
          name='rule_include',
          params=['RuleInclude'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence([Token('>'), Cut(), Override(Call('known_name'))])
        ),
        Rule(
          name='named',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Choice([Call('named_list'), Call('named_single')])
        ),
        Rule(
          name='named_list',
          params=['NamedList'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence(
            [
              Named(name='name', exp=NameMeta()),
              Pattern('\\+[:=]'),
              Cut(),
              Named(name='exp', exp=Call('term'))
            ]
          )
        ),
        Rule(
          name='named_single',
          params=['Named'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence(
            [
              Named(name='name', exp=NameMeta()),
              Pattern('[:=]'),
              Cut(),
              Named(name='exp', exp=Call('term'))
            ]
          )
        ),
        Rule(
          name='override',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Choice([Call('override_list'), Call('override_single')])
        ),
        Rule(
          name='override_list',
          params=['OverrideList'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence([Pattern('\\+=|@\\+:'), Cut(), Override(Call('term'))])
        ),
        Rule(
          name='override_single',
          params=['Override'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence([Pattern('=|@:'), Cut(), Override(Call('term'))])
        ),
        Rule(
          name='term',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Choice(
            [
              Call('gather'),
              Call('join'),
              Call('left_join'),
              Call('right_join'),
              Call('empty_closure'),
              Call('positive_closure'),
              Call('closure'),
              Call('optional'),
              Call('atom'),
              Call('void'),
              Call('skip_to'),
              Call('lookahead'),
              Call('negative_lookahead'),
              Call('cut'),
              Call('cut_deprecated')
            ]
          )
        ),
        Rule(
          name='group',
          params=['Group'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence(
            [
              NegativeLookahead(Token('(?:')),
              Token('('),
              Cut(),
              Override(Call('expre')),
              Token(')'),
              Cut()
            ]
          )
        ),
        Rule(
          name='skip',
          params=['SkipGroup'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence([Token('(?:'), Cut(), Override(Call('expre')), Token(')'), Cut()])
        ),
        Rule(
          name='gather',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence(
            [
              Lookahead(Group(Sequence([Call('atom'), Token('.{')]))),
              Cut(),
              Group(Choice([Call('positive_gather'), Call('normal_gather')]))
            ]
          )
        ),
        Rule(
          name='positive_gather',
          params=['PositiveGather'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence(
            [
              Named(name='sep', exp=Call('atom')),
              Token('.{'),
              Named(name='exp', exp=Call('expre')),
              Token('}'),
              NegativeLookahead(Pattern('\\+=')),
              Pattern('[+-]'),
              Cut()
            ]
          )
        ),
        Rule(
          name='normal_gather',
          params=['Gather'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence(
            [
              Named(name='sep', exp=Call('atom')),
              Token('.{'),
              Cut(),
              Named(name='exp', exp=Call('expre')),
              Token('}'),
              Optional(Sequence([Token('*'), Cut()])),
              Cut()
            ]
          )
        ),
        Rule(
          name='join',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence(
            [
              Lookahead(Group(Sequence([Call('atom'), Token('%{')]))),
              Cut(),
              Group(Choice([Call('positive_join'), Call('normal_join')]))
            ]
          )
        ),
        Rule(
          name='positive_join',
          params=['PositiveJoin'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence(
            [
              Named(name='sep', exp=Call('atom')),
              Token('%{'),
              Named(name='exp', exp=Call('expre')),
              Token('}'),
              NegativeLookahead(Pattern('\\+=')),
              Pattern('[+-]'),
              Cut()
            ]
          )
        ),
        Rule(
          name='normal_join',
          params=['Join'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence(
            [
              Named(name='sep', exp=Call('atom')),
              Token('%{'),
              Cut(),
              Named(name='exp', exp=Call('expre')),
              Token('}'),
              Optional(Sequence([Token('*'), Cut()])),
              Cut()
            ]
          )
        ),
        Rule(
          name='left_join',
          params=['LeftJoin'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence(
            [
              Named(name='sep', exp=Call('atom')),
              Token('<{'),
              Cut(),
              Named(name='exp', exp=Call('expre')),
              Token('}'),
              NegativeLookahead(Pattern('\\+=')),
              Pattern('[+-]'),
              Cut()
            ]
          )
        ),
        Rule(
          name='right_join',
          params=['RightJoin'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence(
            [
              Named(name='sep', exp=Call('atom')),
              Token('>{'),
              Cut(),
              Named(name='exp', exp=Call('expre')),
              Token('}'),
              NegativeLookahead(Pattern('\\+=')),
              Pattern('[+-]'),
              Cut()
            ]
          )
        ),
        Rule(
          name='positive_closure',
          params=['PositiveClosure'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Choice(
            [
              Sequence(
                [
                  Token('{'),
                  Override(Call('expre')),
                  Token('}'),
                  NegativeLookahead(Pattern('\\+=')),
                  Pattern('[+-]'),
                  Cut()
                ]
              ),
              Sequence(
                [
                  Override(Call('atom')),
                  NegativeLookahead(Pattern('\\+=')),
                  Pattern('[+]'),
                  Cut()
                ]
              )
            ]
          )
        ),
        Rule(
          name='closure',
          params=['Closure'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Choice(
            [
              Sequence(
                [Token('{'), Override(Call('expre')), Token('}'), Optional(Token('*')), Cut()]
              ),
              Sequence([Override(Call('atom')), Token('*'), Cut()])
            ]
          )
        ),
        Rule(
          name='empty_closure',
          params=['EmptyClosure'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence([Token('{}'), Cut(), Override(Void())])
        ),
        Rule(
          name='optional',
          params=['Optional'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Choice(
            [
              Sequence([Token('['), Cut(), Override(Call('expre')), Token(']'), Cut()]),
              Sequence(
                [
                  Override(Call('atom')),
                  NegativeLookahead(Group(Choice([Token('?"'), Token("?'"), Token('?/')]))),
                  Token('?'),
                  Cut()
                ]
              )
            ]
          )
        ),
        Rule(
          name='lookahead',
          params=['Lookahead'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence([Token('&'), Cut(), Override(Call('term'))])
        ),
        Rule(
          name='negative_lookahead',
          params=['NegativeLookahead'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence([Token('!'), Cut(), Override(Call('term'))])
        ),
        Rule(
          name='skip_to',
          params=['SkipTo'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence([Token('->'), Cut(), Override(Call('term'))])
        ),
        Rule(
          name='atom',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Choice(
            [
              Call('meta'),
              Call('token'),
              Call('call'),
              Call('dot'),
              Call('pattern'),
              Call('skip'),
              Call('group'),
              Call('eol'),
              Call('eof'),
              Call('alert'),
              Call('constant')
            ]
          )
        ),
        Rule(
          name='meta',
          params=['Meta'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Pattern('@(name|int|uint|float|bool)\\b')
        ),
        Rule(
          name='call',
          params=['Call'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=NameMeta()
        ),
        Rule(
          name='void',
          params=['Void'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence([Token('()'), Cut()])
        ),
        Rule(
          name='fail',
          params=['Fail'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence([Token('!()'), Cut()])
        ),
        Rule(
          name='cut',
          params=['Cut'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence([Token('~'), Cut()])
        ),
        Rule(
          name='cut_deprecated',
          params=['Cut'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence([Token('>>'), Cut()])
        ),
        Rule(
          name='known_name',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence([NameMeta(), Cut()])
        ),
        Rule(
          name='name',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Call('word')
        ),
        Rule(
          name='constant',
          params=['Constant'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence(
            [
              Lookahead(Token('`')),
              Group(
                Choice(
                  [
                    Pattern('(?ms)```((?:.|\\n)*?)```'),
                    Sequence([Token('`'), Override(Call('literal')), Token('`')]),
                    Pattern('`(.*?)`')
                  ]
                )
              )
            ]
          )
        ),
        Rule(
          name='alert',
          params=['Alert'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence(
            [
              Named(name='level', exp=Pattern('\\^+')),
              Named(name='message', exp=Call('constant'))
            ]
          )
        ),
        Rule(
          name='token',
          params=['Token'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Choice([Call('string'), Call('raw_string')])
        ),
        Rule(
          name='literal',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Choice(
            [
              Call('raw_string'),
              Call('value'),
              Call('boolean'),
              Call('none'),
              Call('word'),
              Call('hex'),
              Call('float'),
              Call('int')
            ]
          )
        ),
        Rule(
          name='string',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence(
            [
              Lookahead(Group(Choice([Token('"'), Token("'")]))),
              Group(
                Choice([Call('multiline_string'), Call('singlequoted'), Call('doublequoted')])
              )
            ]
          )
        ),
        Rule(
          name='singlequoted',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Call('SINGLEQUOTED')
        ),
        Rule(
          name='doublequoted',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Call('DOUBLEQUOTED')
        ),
        Rule(
          name='raw_string',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence([Lookahead(Pattern('r["\']')), Pattern('r'), Override(Call('STRING'))])
        ),
        Rule(
          name='STRING',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=True,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Choice([Call('SINGLEQUOTED'), Call('DOUBLEQUOTED')])
        ),
        Rule(
          name='SINGLEQUOTED',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=True,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence([Pattern("'((?:[^'\\n]|\\\\'|\\\\\\\\)*?)'"), Cut()])
        ),
        Rule(
          name='DOUBLEQUOTED',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=True,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence([Pattern('"((?:[^"\\n]|\\\\"|\\\\\\\\)*?)"'), Cut()])
        ),
        Rule(
          name='multiline_string',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Choice(
            [
              Sequence([Pattern("(?ms)'''((?:\\\\\\\\|\\\\.|.)*?)'''"), Cut()]),
              Sequence([Pattern('(?ms)"""((?:\\\\\\\\|\\\\.|.)*?)"""'), Cut()])
            ]
          )
        ),
        Rule(
          name='hex',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Pattern('0[xX](?:\\d|[a-fA-F])+')
        ),
        Rule(
          name='float',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Pattern('[-+]?(?:\\d+\\.\\d*|\\d*\\.\\d+)(?:[Ee][-+]?\\d+)?')
        ),
        Rule(
          name='int',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Pattern('[-+]?\\d+')
        ),
        Rule(
          name='path',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Pattern('[_\\w][_\\w\\d]*(?:::[_\\w][_\\w\\d]*)+')
        ),
        Rule(
          name='word',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Pattern('(?ms)\\s*([_\\w][_\\w\\d]*)\\b')
        ),
        Rule(
          name='dot',
          params=['Dot'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Token('/./')
        ),
        Rule(
          name='pattern',
          params=['Pattern'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Call('regex')
        ),
        Rule(
          name='regex',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Choice(
            [
              Call('deprecated_regex'),
              Sequence(
                [
                  NegativeLookahead(Token('?/')),
                  Group(Choice([Call('REGEX'), Sequence([Token('?'), Override(Call('STRING'))])]))
                ]
              )
            ]
          )
        ),
        Rule(
          name='REGEX',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=True,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence(
            [Lookahead(Token('/')), Pattern('(?ms)/((?:[^/\\\\]|\\\\/|\\\\.)*)/'), Cut()]
          )
        ),
        Rule(
          name='deprecated_regex',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence(
            [
              Token('?/'),
              Cut(),
              Override(Pattern('(?ms)((?:[^/\\\\]|\\\\/|\\\\.)*)')),
              Cut(),
              Token('/?')
            ]
          )
        ),
        Rule(
          name='boolean',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Choice([Token('True'), Token('False')])
        ),
        Rule(
          name='none',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Token('None')
        ),
        Rule(
          name='eof',
          params=['EOF'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Sequence([Token('$'), Cut()])
        ),
        Rule(
          name='eol',
          params=['EOL'],
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Token('$->')
        ),
        Rule(
          name='value',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Choice([Call('string'), Call('number'), Call('true'), Call('false'), Call('null')])
        ),
        Rule(
          name='number',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Pattern('-?(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?')
        ),
        Rule(
          name='true',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Token('true')
        ),
        Rule(
          name='false',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Token('false')
        ),
        Rule(
          name='null',
          params=(),
          kwparams={},
          decorators=[],
          is_name=False,
          is_tokn=False,
          no_memo=False,
          no_stak=False,
          is_memo=True,
          is_lrec=False,
          exp=Token('null')
        )
      )
    )
)


class TatSuBootstrapText(TextLines):
    def __init__(
        self,
        text,
        /,
        config: ParserConfig | None = None,
        **settings,
    ) -> None:
        config = ParserConfig.new(
            config=config,
            name='TatSu',
            whitespace=None,
            nameguard=None,
            ignorecase=False,
            namechars='',
            parseinfo=True,
            comments=r'(?ms)[(][*]\s*(.*?)\s*[*][)]|/[*]\s*(.*?)\s*[*]/',
            eol_comments=r'(?ms)(?:#|//)(.*?)$',
            keywords=KEYWORDS,
            start='start',
        )
        assert isinstance(config, ParserConfig)
        config = config.override(**settings)

        super().__init__(text, config=config)

TatSuBootstrapTokenizer = TatSuBootstrapText


class TatSuBootstrapBuffer(Buffer):  # NOTE: backwards compatibility
    def __init__(
        self,
        text,
        /,
        config: ParserConfig | None = None,
        **settings,
    ) -> None:
        config = ParserConfig.new(
            config=config,
            name='TatSu',
            whitespace=None,
            nameguard=None,
            ignorecase=False,
            namechars='',
            parseinfo=True,
            comments=r'(?ms)[(][*]\s*(.*?)\s*[*][)]|/[*]\s*(.*?)\s*[*]/',
            eol_comments=r'(?ms)(?:#|//)(.*?)$',
            keywords=KEYWORDS,
            start='start',
        )
        assert isinstance(config, ParserConfig)
        config = config.override(**settings)

        super().__init__(text, config=config)


KEYWORDS = ()


def main(filename, **kwargs):
    if not filename or filename == '-':
        import sys

        text = sys.stdin.read()
    else:
        import pathlib

        text = pathlib.Path(filename).read_text()

    parser = TatSuBootstrapParser()
    return parser.parse(text, filename=filename, **kwargs)


if __name__ == '__main__':
    import json
    from tatsu.parsing import generic_main
    from tatsu.util import asjson

    ast = generic_main(main, TatSuBootstrapParser, name='TatSuBootstrap')
    data = asjson(ast)
    print(json.dumps(data, indent=2))
