// Generated by Lisette bindgen
// Source: regexp/syntax (Go stdlib)
// Go: 1.25.10
// Lisette: 0.2.1

pub enum ErrorCode: string {
  ErrInternalError = "regexp/syntax: internal error",
  ErrInvalidCharClass = "invalid character class",
  ErrInvalidCharRange = "invalid character class range",
  ErrInvalidEscape = "invalid escape sequence",
  ErrInvalidNamedCapture = "invalid named capture",
  ErrInvalidPerlOp = "invalid or unsupported Perl syntax",
  ErrInvalidRepeatOp = "invalid nested repetition operator",
  ErrInvalidRepeatSize = "invalid repeat count",
  ErrInvalidUTF8 = "invalid UTF-8",
  ErrLarge = "expression too large",
  ErrMissingBracket = "missing closing ]",
  ErrMissingParen = "missing closing )",
  ErrMissingRepeatArgument = "missing argument to repetition operator",
  ErrNestingDepth = "expression nests too deeply",
  ErrTrailingBackslash = "trailing backslash at end of expression",
  ErrUnexpectedParen = "unexpected )",
}

pub const ErrInternalError: ErrorCode = "regexp/syntax: internal error"

pub const ErrInvalidCharClass: ErrorCode = "invalid character class"

pub const ErrInvalidCharRange: ErrorCode = "invalid character class range"

pub const ErrInvalidEscape: ErrorCode = "invalid escape sequence"

pub const ErrInvalidNamedCapture: ErrorCode = "invalid named capture"

pub const ErrInvalidPerlOp: ErrorCode = "invalid or unsupported Perl syntax"

pub const ErrInvalidRepeatOp: ErrorCode = "invalid nested repetition operator"

pub const ErrInvalidRepeatSize: ErrorCode = "invalid repeat count"

pub const ErrInvalidUTF8: ErrorCode = "invalid UTF-8"

pub const ErrLarge: ErrorCode = "expression too large"

pub const ErrMissingBracket: ErrorCode = "missing closing ]"

pub const ErrMissingParen: ErrorCode = "missing closing )"

pub const ErrMissingRepeatArgument: ErrorCode = "missing argument to repetition operator"

pub const ErrNestingDepth: ErrorCode = "expression nests too deeply"

pub const ErrTrailingBackslash: ErrorCode = "trailing backslash at end of expression"

pub const ErrUnexpectedParen: ErrorCode = "unexpected )"

pub enum InstOp: uint8 {
  InstAlt = 0,
  InstAltMatch = 1,
  InstCapture = 2,
  InstEmptyWidth = 3,
  InstFail = 5,
  InstMatch = 4,
  InstNop = 6,
  InstRune = 7,
  InstRune1 = 8,
  InstRuneAny = 9,
  InstRuneAnyNotNL = 10,
}

pub const InstAlt: InstOp = 0

pub const InstAltMatch: InstOp = 1

pub const InstCapture: InstOp = 2

pub const InstEmptyWidth: InstOp = 3

pub const InstFail: InstOp = 5

pub const InstMatch: InstOp = 4

pub const InstNop: InstOp = 6

pub const InstRune: InstOp = 7

pub const InstRune1: InstOp = 8

pub const InstRuneAny: InstOp = 9

pub const InstRuneAnyNotNL: InstOp = 10

pub enum Op: uint8 {
  OpAlternate = 19,
  OpAnyChar = 6,
  OpAnyCharNotNL = 5,
  OpBeginLine = 7,
  OpBeginText = 9,
  OpCapture = 13,
  OpCharClass = 4,
  OpConcat = 18,
  OpEmptyMatch = 2,
  OpEndLine = 8,
  OpEndText = 10,
  OpLiteral = 3,
  OpNoMatch = 1,
  OpNoWordBoundary = 12,
  OpPlus = 15,
  OpQuest = 16,
  OpRepeat = 17,
  OpStar = 14,
  OpWordBoundary = 11,
}

pub const OpAlternate: Op = 19

pub const OpAnyChar: Op = 6

pub const OpAnyCharNotNL: Op = 5

pub const OpBeginLine: Op = 7

pub const OpBeginText: Op = 9

pub const OpCapture: Op = 13

pub const OpCharClass: Op = 4

pub const OpConcat: Op = 18

pub const OpEmptyMatch: Op = 2

pub const OpEndLine: Op = 8

pub const OpEndText: Op = 10

pub const OpLiteral: Op = 3

pub const OpNoMatch: Op = 1

pub const OpNoWordBoundary: Op = 12

pub const OpPlus: Op = 15

pub const OpQuest: Op = 16

pub const OpRepeat: Op = 17

pub const OpStar: Op = 14

pub const OpWordBoundary: Op = 11

/// Compile compiles the regexp into a program to be executed.
/// The regexp should have been simplified already (returned from re.Simplify).
pub fn Compile(re: Ref<Regexp>) -> Result<Ref<Prog>, error>

/// EmptyOpContext returns the zero-width assertions
/// satisfied at the position between the runes r1 and r2.
/// Passing r1 == -1 indicates that the position is
/// at the beginning of the text.
/// Passing r2 == -1 indicates that the position is
/// at the end of the text.
pub fn EmptyOpContext(r1: rune, r2: rune) -> EmptyOp

/// IsWordChar reports whether r is considered a “word character”
/// during the evaluation of the \b and \B zero-width assertions.
/// These assertions are ASCII-only: the word characters are [A-Za-z0-9_].
pub fn IsWordChar(r: rune) -> bool

/// Parse parses a regular expression string s, controlled by the specified
/// Flags, and returns a regular expression parse tree. The syntax is
/// described in the top-level comment.
pub fn Parse(s: string, flags: Flags) -> Result<Ref<Regexp>, error>

/// An EmptyOp specifies a kind or mixture of zero-width assertions.
#[go(bit_flag_set)]
pub struct EmptyOp(uint8)

/// An Error describes a failure to parse a regular expression
/// and gives the offending expression.
pub struct Error {
  pub Code: ErrorCode,
  pub Expr: string,
}

/// Flags control the behavior of the parser and record information about regexp context.
#[go(bit_flag_set)]
pub struct Flags(uint16)

/// An Inst is a single instruction in a regular expression program.
pub struct Inst {
  pub Op: InstOp,
  pub Out: uint32,
  pub Arg: uint32,
  pub Rune: Slice<rune>,
}

/// A Prog is a compiled regular expression program.
pub struct Prog {
  pub Inst: Slice<Inst>,
  pub Start: int,
  pub NumCap: int,
}

/// A Regexp is a node in a regular expression syntax tree.
pub struct Regexp {
  pub Op: Op,
  pub Flags: Flags,
  pub Sub: Slice<Option<Ref<Regexp>>>,
  // SKIPPED field "Sub0": array-currently-not-representable — fixed-size array cannot currently be represented in Lisette
  pub Rune: Slice<rune>,
  // SKIPPED field "Rune0": array-currently-not-representable — fixed-size array cannot currently be represented in Lisette
  pub Min: int,
  pub Max: int,
  pub Cap: int,
  pub Name: string,
}

pub const ClassNL: Flags = 4

pub const DotNL: Flags = 8

pub const EmptyBeginLine: EmptyOp = 1

pub const EmptyBeginText: EmptyOp = 4

pub const EmptyEndLine: EmptyOp = 2

pub const EmptyEndText: EmptyOp = 8

pub const EmptyNoWordBoundary: EmptyOp = 32

pub const EmptyWordBoundary: EmptyOp = 16

pub const FoldCase: Flags = 1

pub const Literal: Flags = 2

pub const MatchNL: Flags = 12

pub const NonGreedy: Flags = 32

pub const OneLine: Flags = 16

pub const POSIX: Flags = 0

pub const Perl: Flags = 212

pub const PerlX: Flags = 64

pub const Simple: Flags = 512

pub const UnicodeGroups: Flags = 128

pub const WasDollar: Flags = 256

impl Error {
  fn Error(self: Ref<Error>) -> string
}

impl ErrorCode {
  fn String(self) -> string
}

impl Inst {
  /// MatchEmptyWidth reports whether the instruction matches
  /// an empty string between the runes before and after.
  /// It should only be called when i.Op == [InstEmptyWidth].
  fn MatchEmptyWidth(self: Ref<Inst>, before: rune, after: rune) -> bool

  /// MatchRune reports whether the instruction matches (and consumes) r.
  /// It should only be called when i.Op == [InstRune].
  fn MatchRune(self: Ref<Inst>, r: rune) -> bool

  /// MatchRunePos checks whether the instruction matches (and consumes) r.
  /// If so, MatchRunePos returns the index of the matching rune pair
  /// (or, when len(i.Rune) == 1, rune singleton).
  /// If not, MatchRunePos returns -1.
  /// MatchRunePos should only be called when i.Op == [InstRune].
  fn MatchRunePos(self: Ref<Inst>, r: rune) -> int

  fn String(self: Ref<Inst>) -> string
}

impl InstOp {
  fn String(self) -> string
}

impl Op {
  fn String(self) -> string
}

impl Prog {
  /// Prefix returns a literal string that all matches for the
  /// regexp must start with. Complete is true if the prefix
  /// is the entire match.
  fn Prefix(self: Ref<Prog>) -> (string, bool)

  /// StartCond returns the leading empty-width conditions that must
  /// be true in any match. It returns ^EmptyOp(0) if no matches are possible.
  fn StartCond(self: Ref<Prog>) -> EmptyOp

  fn String(self: Ref<Prog>) -> string
}

impl Regexp {
  /// CapNames walks the regexp to find the names of capturing groups.
  fn CapNames(self: Ref<Regexp>) -> Slice<string>

  /// Equal reports whether x and y have identical structure.
  fn Equal(self: Ref<Regexp>, y: Ref<Regexp>) -> bool

  /// MaxCap walks the regexp to find the maximum capture index.
  fn MaxCap(self: Ref<Regexp>) -> int

  /// Simplify returns a regexp equivalent to re but without counted repetitions
  /// and with various other simplifications, such as rewriting /(?:a+)+/ to /a+/.
  /// The resulting regexp will execute correctly but its string representation
  /// will not produce the same parse tree, because capturing parentheses
  /// may have been duplicated or removed. For example, the simplified form
  /// for /(x){1,2}/ is /(x)(x)?/ but both parentheses capture as $1.
  /// The returned regexp may share structure with or be the original.
  fn Simplify(self: Ref<Regexp>) -> Ref<Regexp>

  fn String(self: Ref<Regexp>) -> string
}
