"""
Auto-generated Python stub file from re.__init__.py
Module: re.__init__
"""


import t, c
from stdint import *
import mpool
import string

RE_CHAR:    t.CDefine = 0   # 匹配单个字符
RE_DOT:     t.CDefine = 1   # 匹配任意字符（除换行）
RE_CLASS:   t.CDefine = 2   # 匹配字符类 [abc]
RE_NCLASS:  t.CDefine = 3   # 匹配反义字符类 [^abc]
RE_SPLIT:   t.CDefine = 4   # 分裂节点（用于 | ? *）
RE_JUMP:    t.CDefine = 5   # 无条件跳转（用于连接）
RE_MATCH:   t.CDefine = 6   # 匹配成功
RE_BOL:     t.CDefine = 7   # 行首 ^
RE_EOL:     t.CDefine = 8   # 行尾 $
RE_DCLASS:  t.CDefine = 9   # 预定义字符类 \d \w \s
RE_NDCLASS: t.CDefine = 10  # 预定义反义字符类 \D \W \S
DCLASS_DIGIT:    t.CDefine = 0   # \d
DCLASS_WORD:     t.CDefine = 1   # \w
DCLASS_SPACE:    t.CDefine = 2   # \s
RE_MAX_NODES:  t.CDefine = 256
RE_MAX_STATES: t.CDefine = 256

class Renode:
    ntype: t.CInt
    ch: t.CChar
    out1: Renode | t.CPtr
    out2: Renode | t.CPtr
    cls: t.CChar | t.CPtr
    dcls: t.CInt
    def __new__(self: Renode, pool: mpool.MPool | t.CPtr) -> 'Renode' | t.CPtr: pass
class RePtrList:
    node: Renode | t.CPtr
    which: t.CInt
    next: RePtrList | t.CPtr
    def __new__(self: RePtrList, pool: mpool.MPool | t.CPtr) -> 'RePtrList' | t.CPtr: pass
class Refrag:
    start: Renode | t.CPtr
    out: RePtrList | t.CPtr
    def __new__(self: Refrag, pool: mpool.MPool | t.CPtr) -> 'Refrag' | t.CPtr: pass
class Rematch:
    start: t.CSizeT
    end: t.CSizeT
    found: t.CInt
    def __new__(self: Rematch, pool: mpool.MPool | t.CPtr) -> 'Rematch' | t.CPtr: pass

def _is_word_char(ch: t.CChar) -> bool: pass

def _match_dclass(dcls: t.CInt, ch: t.CChar) -> bool: pass

def _list_append(pool: mpool.MPool | t.CPtr, head: RePtrList | t.CPtr, node: Renode | t.CPtr, which: t.CInt) -> RePtrList | t.CPtr: pass

def _list_patch(head: RePtrList | t.CPtr, target: Renode | t.CPtr) -> t.CInt: pass

def _list_concat(a: RePtrList | t.CPtr, b: RePtrList | t.CPtr) -> RePtrList | t.CPtr: pass


class Recompiler:
    pool: mpool.MPool | t.CPtr
    p: t.CChar | t.CPtr
    pend: t.CChar | t.CPtr
    match_node: Renode | t.CPtr
    def __new__(self: Recompiler, pool: mpool.MPool | t.CPtr) -> 'Recompiler' | t.CPtr: pass
    def compile(self: Recompiler, pattern: t.CChar | t.CPtr) -> Renode | t.CPtr: pass
    def _peek(self: Recompiler) -> t.CChar: pass
    def _next(self: Recompiler) -> t.CChar: pass
    def _parse_alt(self: Recompiler) -> Refrag | t.CPtr: pass
    def _parse_concat(self: Recompiler) -> Refrag | t.CPtr: pass
    def _parse_repeat(self: Recompiler) -> Refrag | t.CPtr: pass
    def _parse_atom(self: Recompiler) -> Refrag | t.CPtr: pass
    def _parse_escape(self: Recompiler) -> Refrag | t.CPtr: pass
    def _parse_class(self: Recompiler) -> Refrag | t.CPtr: pass
class Restate:
    node: Renode | t.CPtr
    pos: t.CSizeT
    def __new__(self: Restate, pool: mpool.MPool | t.CPtr) -> 'Restate' | t.CPtr: pass

def _add_state(nlist: t.CVoid | t.CPtr, node: Renode | t.CPtr, pos: t.CSizeT, text: t.CChar | t.CPtr, nstates: t.CInt, max_states: t.CInt) -> t.CInt: pass

def _read_node(slist: t.CVoid | t.CPtr, idx: t.CInt) -> Renode | t.CPtr: pass

def _read_pos(slist: t.CVoid | t.CPtr, idx: t.CInt) -> t.CSizeT: pass

def _step(clist: t.CVoid | t.CPtr, nlist: t.CVoid | t.CPtr, ch: t.CChar, pos: t.CSizeT, text: t.CChar | t.CPtr, cstates: t.CInt, max_states: t.CInt) -> t.CInt: pass

def _check_match(slist: t.CVoid | t.CPtr, nstates: t.CInt) -> t.CSizeT: pass

def compile(pool: mpool.MPool | t.CPtr, pattern: t.CChar | t.CPtr) -> Renode | t.CPtr: pass

def match(pool: mpool.MPool | t.CPtr, pattern: t.CChar | t.CPtr, text: t.CChar | t.CPtr) -> Rematch | t.CPtr: pass

def search(pool: mpool.MPool | t.CPtr, pattern: t.CChar | t.CPtr, text: t.CChar | t.CPtr) -> Rematch | t.CPtr: pass

def findall(pool: mpool.MPool | t.CPtr, pattern: t.CChar | t.CPtr, text: t.CChar | t.CPtr, results: t.CChar | t.CPtr | t.CPtr, max_results: t.CSizeT) -> t.CSizeT: pass

def sub(pool: mpool.MPool | t.CPtr, pattern: t.CChar | t.CPtr, replacement: t.CChar | t.CPtr, text: t.CChar | t.CPtr, outbuf: t.CChar | t.CPtr, outsize: t.CSizeT) -> t.CSizeT: pass

def split(pool: mpool.MPool | t.CPtr, pattern: t.CChar | t.CPtr, text: t.CChar | t.CPtr, results: t.CChar | t.CPtr | t.CPtr, max_results: t.CSizeT) -> t.CSizeT: pass
