// Generated by Lisette bindgen
// Source: go/token (Go stdlib)
// Go: 1.25.5
// Lisette: 0.1.11

pub enum Token: int {
  ADD = 12,
  ADD_ASSIGN = 23,
  AND = 17,
  AND_ASSIGN = 28,
  AND_NOT = 22,
  AND_NOT_ASSIGN = 33,
  ARROW = 36,
  ASSIGN = 42,
  BREAK = 61,
  CASE = 62,
  CHAN = 63,
  CHAR = 8,
  COLON = 58,
  COMMA = 52,
  COMMENT = 2,
  CONST = 64,
  CONTINUE = 65,
  DEC = 38,
  DEFAULT = 66,
  DEFER = 67,
  DEFINE = 47,
  ELLIPSIS = 48,
  ELSE = 68,
  EOF = 1,
  EQL = 39,
  FALLTHROUGH = 69,
  FLOAT = 6,
  FOR = 70,
  FUNC = 71,
  GEQ = 46,
  GO = 72,
  GOTO = 73,
  GTR = 41,
  IDENT = 4,
  IF = 74,
  ILLEGAL = 0,
  IMAG = 7,
  IMPORT = 75,
  INC = 37,
  INT = 5,
  INTERFACE = 76,
  LAND = 34,
  LBRACE = 51,
  LBRACK = 50,
  LEQ = 45,
  LOR = 35,
  LPAREN = 49,
  LSS = 40,
  MAP = 77,
  MUL = 14,
  MUL_ASSIGN = 25,
  NEQ = 44,
  NOT = 43,
  OR = 18,
  OR_ASSIGN = 29,
  PACKAGE = 78,
  PERIOD = 53,
  QUO = 15,
  QUO_ASSIGN = 26,
  RANGE = 79,
  RBRACE = 56,
  RBRACK = 55,
  REM = 16,
  REM_ASSIGN = 27,
  RETURN = 80,
  RPAREN = 54,
  SELECT = 81,
  SEMICOLON = 57,
  SHL = 20,
  SHL_ASSIGN = 31,
  SHR = 21,
  SHR_ASSIGN = 32,
  STRING = 9,
  STRUCT = 82,
  SUB = 13,
  SUB_ASSIGN = 24,
  SWITCH = 83,
  TILDE = 88,
  TYPE = 84,
  VAR = 85,
  XOR = 19,
  XOR_ASSIGN = 30,
}

pub const ADD: Token = 12

pub const ADD_ASSIGN: Token = 23

pub const AND: Token = 17

pub const AND_ASSIGN: Token = 28

pub const AND_NOT: Token = 22

pub const AND_NOT_ASSIGN: Token = 33

pub const ARROW: Token = 36

pub const ASSIGN: Token = 42

pub const BREAK: Token = 61

pub const CASE: Token = 62

pub const CHAN: Token = 63

pub const CHAR: Token = 8

pub const COLON: Token = 58

pub const COMMA: Token = 52

pub const COMMENT: Token = 2

pub const CONST: Token = 64

pub const CONTINUE: Token = 65

pub const DEC: Token = 38

pub const DEFAULT: Token = 66

pub const DEFER: Token = 67

pub const DEFINE: Token = 47

pub const ELLIPSIS: Token = 48

pub const ELSE: Token = 68

pub const EOF: Token = 1

pub const EQL: Token = 39

pub const FALLTHROUGH: Token = 69

pub const FLOAT: Token = 6

pub const FOR: Token = 70

pub const FUNC: Token = 71

pub const GEQ: Token = 46

pub const GO: Token = 72

pub const GOTO: Token = 73

pub const GTR: Token = 41

pub const IDENT: Token = 4

pub const IF: Token = 74

pub const ILLEGAL: Token = 0

pub const IMAG: Token = 7

pub const IMPORT: Token = 75

pub const INC: Token = 37

pub const INT: Token = 5

pub const INTERFACE: Token = 76

pub const LAND: Token = 34

pub const LBRACE: Token = 51

pub const LBRACK: Token = 50

pub const LEQ: Token = 45

pub const LOR: Token = 35

pub const LPAREN: Token = 49

pub const LSS: Token = 40

pub const MAP: Token = 77

pub const MUL: Token = 14

pub const MUL_ASSIGN: Token = 25

pub const NEQ: Token = 44

pub const NOT: Token = 43

pub const OR: Token = 18

pub const OR_ASSIGN: Token = 29

pub const PACKAGE: Token = 78

pub const PERIOD: Token = 53

pub const QUO: Token = 15

pub const QUO_ASSIGN: Token = 26

pub const RANGE: Token = 79

pub const RBRACE: Token = 56

pub const RBRACK: Token = 55

pub const REM: Token = 16

pub const REM_ASSIGN: Token = 27

pub const RETURN: Token = 80

pub const RPAREN: Token = 54

pub const SELECT: Token = 81

pub const SEMICOLON: Token = 57

pub const SHL: Token = 20

pub const SHL_ASSIGN: Token = 31

pub const SHR: Token = 21

pub const SHR_ASSIGN: Token = 32

pub const STRING: Token = 9

pub const STRUCT: Token = 82

pub const SUB: Token = 13

pub const SUB_ASSIGN: Token = 24

pub const SWITCH: Token = 83

pub const TILDE: Token = 88

pub const TYPE: Token = 84

pub const VAR: Token = 85

pub const XOR: Token = 19

pub const XOR_ASSIGN: Token = 30

/// IsExported reports whether name starts with an upper-case letter.
pub fn IsExported(name: string) -> bool

/// IsIdentifier reports whether name is a Go identifier, that is, a non-empty
/// string made up of letters, digits, and underscores, where the first character
/// is not a digit. Keywords are not identifiers.
pub fn IsIdentifier(name: string) -> bool

/// IsKeyword reports whether name is a Go keyword, such as "func" or "return".
pub fn IsKeyword(name: string) -> bool

pub fn Lookup(ident: string) -> Token

pub fn NewFileSet() -> Ref<FileSet>

/// A File is a handle for a file belonging to a [FileSet].
/// A File has a name, size, and line offset table.
/// 
/// Use [FileSet.AddFile] to create a File.
/// A File may belong to more than one FileSet; see [FileSet.AddExistingFiles].
pub type File

/// A FileSet represents a set of source files.
/// Methods of file sets are synchronized; multiple goroutines
/// may invoke them concurrently.
/// 
/// The byte offsets for each file in a file set are mapped into
/// distinct (integer) intervals, one interval [base, base+size]
/// per file. [FileSet.Base] represents the first byte in the file, and size
/// is the corresponding file size. A [Pos] value is a value in such
/// an interval. By determining the interval a [Pos] value belongs
/// to, the file, its file base, and thus the byte offset (position)
/// the [Pos] value is representing can be computed.
/// 
/// When adding a new file, a file base must be provided. That can
/// be any integer value that is past the end of any interval of any
/// file already in the file set. For convenience, [FileSet.Base] provides
/// such a value, which is simply the end of the Pos interval of the most
/// recently added file, plus one. Unless there is a need to extend an
/// interval later, using the [FileSet.Base] should be used as argument
/// for [FileSet.AddFile].
/// 
/// A [File] may be removed from a FileSet when it is no longer needed.
/// This may reduce memory usage in a long-running application.
pub type FileSet

/// Pos is a compact encoding of a source position within a file set.
/// It can be converted into a [Position] for a more convenient, but much
/// larger, representation.
/// 
/// The Pos value for a given file is a number in the range [base, base+size],
/// where base and size are specified when a file is added to the file set.
/// The difference between a Pos value and the corresponding file base
/// corresponds to the byte offset of that position (represented by the Pos value)
/// from the beginning of the file. Thus, the file base offset is the Pos value
/// representing the first byte in the file.
/// 
/// To create the Pos value for a specific source offset (measured in bytes),
/// first add the respective file to the current file set using [FileSet.AddFile]
/// and then call [File.Pos](offset) for that file. Given a Pos value p
/// for a specific file set fset, the corresponding [Position] value is
/// obtained by calling fset.Position(p).
/// 
/// Pos values can be compared directly with the usual comparison operators:
/// If two Pos values p and q are in the same file, comparing p and q is
/// equivalent to comparing the respective source file offsets. If p and q
/// are in different files, p < q is true if the file implied by p was added
/// to the respective file set before the file implied by q.
pub struct Pos(int)

/// Position describes an arbitrary source position
/// including the file, line, and column location.
/// A Position is valid if the line number is > 0.
pub struct Position {
  pub Filename: string,
  pub Offset: int,
  pub Line: int,
  pub Column: int,
}

/// A set of constants for precedence-based expression parsing.
/// Non-operators have lowest precedence, followed by operators
/// starting with precedence 1 up to unary operators. The highest
/// precedence serves as "catch-all" precedence for selector,
/// indexing, and other operator and delimiter tokens.
const HighestPrec = 7

/// A set of constants for precedence-based expression parsing.
/// Non-operators have lowest precedence, followed by operators
/// starting with precedence 1 up to unary operators. The highest
/// precedence serves as "catch-all" precedence for selector,
/// indexing, and other operator and delimiter tokens.
const LowestPrec = 0

const NoPos: Pos = 0

/// A set of constants for precedence-based expression parsing.
/// Non-operators have lowest precedence, followed by operators
/// starting with precedence 1 up to unary operators. The highest
/// precedence serves as "catch-all" precedence for selector,
/// indexing, and other operator and delimiter tokens.
const UnaryPrec = 6

impl File {
  /// AddLine adds the line offset for a new line.
  /// The line offset must be larger than the offset for the previous line
  /// and smaller than the file size; otherwise the line offset is ignored.
  fn AddLine(self: Ref<File>, offset: int)

  /// AddLineColumnInfo adds alternative file, line, and column number
  /// information for a given file offset. The offset must be larger
  /// than the offset for the previously added alternative line info
  /// and smaller than the file size; otherwise the information is
  /// ignored.
  /// 
  /// AddLineColumnInfo is typically used to register alternative position
  /// information for line directives such as //line filename:line:column.
  fn AddLineColumnInfo(
    self: Ref<File>,
    offset: int,
    filename: string,
    line: int,
    column: int,
  )

  /// AddLineInfo is like [File.AddLineColumnInfo] with a column = 1 argument.
  /// It is here for backward-compatibility for code prior to Go 1.11.
  fn AddLineInfo(self: Ref<File>, offset: int, filename: string, line: int)

  /// Base returns the base offset of file f as registered with AddFile.
  fn Base(self: Ref<File>) -> int

  /// Line returns the line number for the given file position p;
  /// p must be a [Pos] value in that file or [NoPos].
  fn Line(self: Ref<File>, p: Pos) -> int

  /// LineCount returns the number of lines in file f.
  fn LineCount(self: Ref<File>) -> int

  /// LineStart returns the [Pos] value of the start of the specified line.
  /// It ignores any alternative positions set using [File.AddLineColumnInfo].
  /// LineStart panics if the 1-based line number is invalid.
  fn LineStart(self: Ref<File>, line: int) -> Pos

  /// Lines returns the effective line offset table of the form described by [File.SetLines].
  /// Callers must not mutate the result.
  fn Lines(self: Ref<File>) -> Slice<int>

  /// MergeLine merges a line with the following line. It is akin to replacing
  /// the newline character at the end of the line with a space (to not change the
  /// remaining offsets). To obtain the line number, consult e.g. [Position.Line].
  /// MergeLine will panic if given an invalid line number.
  fn MergeLine(self: Ref<File>, line: int)

  /// Name returns the file name of file f as registered with AddFile.
  fn Name(self: Ref<File>) -> string

  /// Offset returns the offset for the given file position p.
  /// 
  /// If p is before the file's start position (or if p is NoPos),
  /// the result is 0; if p is past the file's end position,
  /// the result is the file size (see also go.dev/issue/57490).
  /// 
  /// The following invariant, though not true for offset values
  /// in general, holds for the result offset:
  /// f.Offset(f.Pos(offset)) == offset
  fn Offset(self: Ref<File>, p: Pos) -> int

  /// Pos returns the Pos value for the given file offset.
  /// 
  /// If offset is negative, the result is the file's start
  /// position; if the offset is too large, the result is
  /// the file's end position (see also go.dev/issue/57490).
  /// 
  /// The following invariant, though not true for Pos values
  /// in general, holds for the result p:
  /// f.Pos(f.Offset(p)) == p.
  fn Pos(self: Ref<File>, offset: int) -> Pos

  /// Position returns the Position value for the given file position p.
  /// If p is out of bounds, it is adjusted to match the File.Offset behavior.
  /// Calling f.Position(p) is equivalent to calling f.PositionFor(p, true).
  fn Position(self: Ref<File>, p: Pos) -> Position

  /// PositionFor returns the Position value for the given file position p.
  /// If p is out of bounds, it is adjusted to match the File.Offset behavior.
  /// If adjusted is set, the position may be adjusted by position-altering
  /// //line comments; otherwise those comments are ignored.
  /// p must be a Pos value in f or NoPos.
  fn PositionFor(self: Ref<File>, p: Pos, adjusted: bool) -> Position

  /// SetLines sets the line offsets for a file and reports whether it succeeded.
  /// The line offsets are the offsets of the first character of each line;
  /// for instance for the content "ab\nc\n" the line offsets are {0, 3}.
  /// An empty file has an empty line offset table.
  /// Each line offset must be larger than the offset for the previous line
  /// and smaller than the file size; otherwise SetLines fails and returns
  /// false.
  /// Callers must not mutate the provided slice after SetLines returns.
  fn SetLines(self: Ref<File>, lines: Slice<int>) -> bool

  /// SetLinesForContent sets the line offsets for the given file content.
  /// It ignores position-altering //line comments.
  fn SetLinesForContent(self: Ref<File>, content: Slice<uint8>)

  /// Size returns the size of file f as registered with AddFile.
  fn Size(self: Ref<File>) -> int
}

impl FileSet {
  /// AddExistingFiles adds the specified files to the
  /// FileSet if they are not already present.
  /// The caller must ensure that no pair of Files that
  /// would appear in the resulting FileSet overlap.
  fn AddExistingFiles(self: Ref<FileSet>, files: VarArgs<Ref<File>>)

  /// AddFile adds a new file with a given filename, base offset, and file size
  /// to the file set s and returns the file. Multiple files may have the same
  /// name. The base offset must not be smaller than the [FileSet.Base], and
  /// size must not be negative. As a special case, if a negative base is provided,
  /// the current value of the [FileSet.Base] is used instead.
  /// 
  /// Adding the file will set the file set's [FileSet.Base] value to base + size + 1
  /// as the minimum base value for the next file. The following relationship
  /// exists between a [Pos] value p for a given file offset offs:
  /// 
  /// 	int(p) = base + offs
  /// 
  /// with offs in the range [0, size] and thus p in the range [base, base+size].
  /// For convenience, [File.Pos] may be used to create file-specific position
  /// values from a file offset.
  fn AddFile(self: Ref<FileSet>, filename: string, base: int, size: int) -> Ref<File>

  /// Base returns the minimum base offset that must be provided to
  /// [FileSet.AddFile] when adding the next file.
  fn Base(self: Ref<FileSet>) -> int

  /// File returns the file that contains the position p.
  /// If no such file is found (for instance for p == [NoPos]),
  /// the result is nil.
  fn File(self: Ref<FileSet>, p: Pos) -> Option<Ref<File>>

  /// Iterate calls yield for the files in the file set in ascending Base
  /// order until yield returns false.
  fn Iterate(self: Ref<FileSet>, yield: fn(Ref<File>) -> bool)

  /// Position converts a [Pos] p in the fileset into a Position value.
  /// Calling s.Position(p) is equivalent to calling s.PositionFor(p, true).
  fn Position(self: Ref<FileSet>, p: Pos) -> Position

  /// PositionFor converts a [Pos] p in the fileset into a [Position] value.
  /// If adjusted is set, the position may be adjusted by position-altering
  /// //line comments; otherwise those comments are ignored.
  /// p must be a [Pos] value in s or [NoPos].
  fn PositionFor(self: Ref<FileSet>, p: Pos, adjusted: bool) -> Position

  /// Read calls decode to deserialize a file set into s; s must not be nil.
  fn Read(self: Ref<FileSet>, decode: fn(Unknown) -> Result<(), error>) -> Result<(), error>

  /// RemoveFile removes a file from the [FileSet] so that subsequent
  /// queries for its [Pos] interval yield a negative result.
  /// This reduces the memory usage of a long-lived [FileSet] that
  /// encounters an unbounded stream of files.
  /// 
  /// Removing a file that does not belong to the set has no effect.
  fn RemoveFile(self: Ref<FileSet>, file: Ref<File>)

  /// Write calls encode to serialize the file set s.
  fn Write(self: Ref<FileSet>, encode: fn(Unknown) -> Result<(), error>) -> Result<(), error>
}

impl Pos {
  /// IsValid reports whether the position is valid.
  fn IsValid(self) -> bool
}

impl Position {
  /// IsValid reports whether the position is valid.
  fn IsValid(self: Ref<Position>) -> bool

  /// String returns a string in one of several forms:
  /// 
  /// 	file:line:column    valid position with file name
  /// 	file:line           valid position with file name but no column (column == 0)
  /// 	line:column         valid position without file name
  /// 	line                valid position without file name and no column (column == 0)
  /// 	file                invalid position with file name
  /// 	-                   invalid position without file name
  fn String(self) -> string
}

impl Token {
  /// IsKeyword returns true for tokens corresponding to keywords;
  /// it returns false otherwise.
  fn IsKeyword(self) -> bool

  /// IsLiteral returns true for tokens corresponding to identifiers
  /// and basic type literals; it returns false otherwise.
  fn IsLiteral(self) -> bool

  /// IsOperator returns true for tokens corresponding to operators and
  /// delimiters; it returns false otherwise.
  fn IsOperator(self) -> bool

  /// Precedence returns the operator precedence of the binary
  /// operator op. If op is not a binary operator, the result
  /// is LowestPrecedence.
  fn Precedence(self) -> int

  /// String returns the string corresponding to the token tok.
  /// For operators, delimiters, and keywords the string is the actual
  /// token character sequence (e.g., for the token [ADD], the string is
  /// "+"). For all other tokens the string corresponds to the token
  /// constant name (e.g. for the token [IDENT], the string is "IDENT").
  fn String(self) -> string
}
