// Generated by Lisette bindgen
// Source: text/scanner (Go stdlib)
// Go: 1.25.10
// Lisette: 0.2.1
import "go:io"
/// TokenString returns a printable string for a token or Unicode character.
pub fn TokenString(tok: rune) -> string
/// Position is a value that represents a source position.
/// A position is valid if Line > 0.
pub struct Position {
pub Filename: string,
pub Offset: int,
pub Line: int,
pub Column: int,
}
/// A Scanner implements reading of Unicode characters and tokens from an [io.Reader].
pub struct Scanner {
pub Error: Option<fn(Ref<Scanner>, string) -> ()>,
pub ErrorCount: int,
pub Mode: uint,
pub Whitespace: uint64,
pub IsIdentRune: Option<fn(rune, int) -> bool>,
pub Position: Position,
}
/// The result of Scan is one of these tokens or a Unicode character.
pub const Char = -5
/// The result of Scan is one of these tokens or a Unicode character.
pub const Comment = -8
/// The result of Scan is one of these tokens or a Unicode character.
pub const EOF = -1
/// The result of Scan is one of these tokens or a Unicode character.
pub const Float = -4
/// Predefined mode bits to control recognition of tokens. For instance,
/// to configure a [Scanner] such that it only recognizes (Go) identifiers,
/// integers, and skips comments, set the Scanner's Mode field to:
///
/// ScanIdents | ScanInts | ScanComments | SkipComments
///
/// With the exceptions of comments, which are skipped if SkipComments is
/// set, unrecognized tokens are not ignored. Instead, the scanner simply
/// returns the respective individual characters (or possibly sub-tokens).
/// For instance, if the mode is ScanIdents (not ScanStrings), the string
/// "foo" is scanned as the token sequence '"' [Ident] '"'.
///
/// Use GoTokens to configure the Scanner such that it accepts all Go
/// literal tokens including Go identifiers. Comments will be skipped.
pub const GoTokens = 1012
/// GoWhitespace is the default value for the [Scanner]'s Whitespace field.
/// Its value selects Go's white space characters.
pub const GoWhitespace = 4294977024
/// The result of Scan is one of these tokens or a Unicode character.
pub const Ident = -2
/// The result of Scan is one of these tokens or a Unicode character.
pub const Int = -3
/// The result of Scan is one of these tokens or a Unicode character.
pub const RawString = -7
/// Predefined mode bits to control recognition of tokens. For instance,
/// to configure a [Scanner] such that it only recognizes (Go) identifiers,
/// integers, and skips comments, set the Scanner's Mode field to:
///
/// ScanIdents | ScanInts | ScanComments | SkipComments
///
/// With the exceptions of comments, which are skipped if SkipComments is
/// set, unrecognized tokens are not ignored. Instead, the scanner simply
/// returns the respective individual characters (or possibly sub-tokens).
/// For instance, if the mode is ScanIdents (not ScanStrings), the string
/// "foo" is scanned as the token sequence '"' [Ident] '"'.
///
/// Use GoTokens to configure the Scanner such that it accepts all Go
/// literal tokens including Go identifiers. Comments will be skipped.
pub const ScanChars = 32
/// Predefined mode bits to control recognition of tokens. For instance,
/// to configure a [Scanner] such that it only recognizes (Go) identifiers,
/// integers, and skips comments, set the Scanner's Mode field to:
///
/// ScanIdents | ScanInts | ScanComments | SkipComments
///
/// With the exceptions of comments, which are skipped if SkipComments is
/// set, unrecognized tokens are not ignored. Instead, the scanner simply
/// returns the respective individual characters (or possibly sub-tokens).
/// For instance, if the mode is ScanIdents (not ScanStrings), the string
/// "foo" is scanned as the token sequence '"' [Ident] '"'.
///
/// Use GoTokens to configure the Scanner such that it accepts all Go
/// literal tokens including Go identifiers. Comments will be skipped.
pub const ScanComments = 256
/// Predefined mode bits to control recognition of tokens. For instance,
/// to configure a [Scanner] such that it only recognizes (Go) identifiers,
/// integers, and skips comments, set the Scanner's Mode field to:
///
/// ScanIdents | ScanInts | ScanComments | SkipComments
///
/// With the exceptions of comments, which are skipped if SkipComments is
/// set, unrecognized tokens are not ignored. Instead, the scanner simply
/// returns the respective individual characters (or possibly sub-tokens).
/// For instance, if the mode is ScanIdents (not ScanStrings), the string
/// "foo" is scanned as the token sequence '"' [Ident] '"'.
///
/// Use GoTokens to configure the Scanner such that it accepts all Go
/// literal tokens including Go identifiers. Comments will be skipped.
pub const ScanFloats = 16
/// Predefined mode bits to control recognition of tokens. For instance,
/// to configure a [Scanner] such that it only recognizes (Go) identifiers,
/// integers, and skips comments, set the Scanner's Mode field to:
///
/// ScanIdents | ScanInts | ScanComments | SkipComments
///
/// With the exceptions of comments, which are skipped if SkipComments is
/// set, unrecognized tokens are not ignored. Instead, the scanner simply
/// returns the respective individual characters (or possibly sub-tokens).
/// For instance, if the mode is ScanIdents (not ScanStrings), the string
/// "foo" is scanned as the token sequence '"' [Ident] '"'.
///
/// Use GoTokens to configure the Scanner such that it accepts all Go
/// literal tokens including Go identifiers. Comments will be skipped.
pub const ScanIdents = 4
/// Predefined mode bits to control recognition of tokens. For instance,
/// to configure a [Scanner] such that it only recognizes (Go) identifiers,
/// integers, and skips comments, set the Scanner's Mode field to:
///
/// ScanIdents | ScanInts | ScanComments | SkipComments
///
/// With the exceptions of comments, which are skipped if SkipComments is
/// set, unrecognized tokens are not ignored. Instead, the scanner simply
/// returns the respective individual characters (or possibly sub-tokens).
/// For instance, if the mode is ScanIdents (not ScanStrings), the string
/// "foo" is scanned as the token sequence '"' [Ident] '"'.
///
/// Use GoTokens to configure the Scanner such that it accepts all Go
/// literal tokens including Go identifiers. Comments will be skipped.
pub const ScanInts = 8
/// Predefined mode bits to control recognition of tokens. For instance,
/// to configure a [Scanner] such that it only recognizes (Go) identifiers,
/// integers, and skips comments, set the Scanner's Mode field to:
///
/// ScanIdents | ScanInts | ScanComments | SkipComments
///
/// With the exceptions of comments, which are skipped if SkipComments is
/// set, unrecognized tokens are not ignored. Instead, the scanner simply
/// returns the respective individual characters (or possibly sub-tokens).
/// For instance, if the mode is ScanIdents (not ScanStrings), the string
/// "foo" is scanned as the token sequence '"' [Ident] '"'.
///
/// Use GoTokens to configure the Scanner such that it accepts all Go
/// literal tokens including Go identifiers. Comments will be skipped.
pub const ScanRawStrings = 128
/// Predefined mode bits to control recognition of tokens. For instance,
/// to configure a [Scanner] such that it only recognizes (Go) identifiers,
/// integers, and skips comments, set the Scanner's Mode field to:
///
/// ScanIdents | ScanInts | ScanComments | SkipComments
///
/// With the exceptions of comments, which are skipped if SkipComments is
/// set, unrecognized tokens are not ignored. Instead, the scanner simply
/// returns the respective individual characters (or possibly sub-tokens).
/// For instance, if the mode is ScanIdents (not ScanStrings), the string
/// "foo" is scanned as the token sequence '"' [Ident] '"'.
///
/// Use GoTokens to configure the Scanner such that it accepts all Go
/// literal tokens including Go identifiers. Comments will be skipped.
pub const ScanStrings = 64
/// Predefined mode bits to control recognition of tokens. For instance,
/// to configure a [Scanner] such that it only recognizes (Go) identifiers,
/// integers, and skips comments, set the Scanner's Mode field to:
///
/// ScanIdents | ScanInts | ScanComments | SkipComments
///
/// With the exceptions of comments, which are skipped if SkipComments is
/// set, unrecognized tokens are not ignored. Instead, the scanner simply
/// returns the respective individual characters (or possibly sub-tokens).
/// For instance, if the mode is ScanIdents (not ScanStrings), the string
/// "foo" is scanned as the token sequence '"' [Ident] '"'.
///
/// Use GoTokens to configure the Scanner such that it accepts all Go
/// literal tokens including Go identifiers. Comments will be skipped.
pub const SkipComments = 512
/// The result of Scan is one of these tokens or a Unicode character.
pub const String = -6
impl Position {
/// IsValid reports whether the position is valid.
fn IsValid(self: Ref<Position>) -> bool
fn String(self) -> string
}
impl Scanner {
/// Init initializes a [Scanner] with a new source and returns s.
/// [Scanner.Error] is set to nil, [Scanner.ErrorCount] is set to 0, [Scanner.Mode] is set to [GoTokens],
/// and [Scanner.Whitespace] is set to [GoWhitespace].
#[allow(unused_value)]
fn Init(self: Ref<Scanner>, src: io.Reader) -> Ref<Scanner>
/// IsValid reports whether the position is valid.
fn IsValid(self: Ref<Scanner>) -> bool
/// Next reads and returns the next Unicode character.
/// It returns [EOF] at the end of the source. It reports
/// a read error by calling s.Error, if not nil; otherwise
/// it prints an error message to [os.Stderr]. Next does not
/// update the [Scanner.Position] field; use [Scanner.Pos]() to
/// get the current position.
fn Next(self: Ref<Scanner>) -> rune
/// Peek returns the next Unicode character in the source without advancing
/// the scanner. It returns [EOF] if the scanner's position is at the last
/// character of the source.
fn Peek(self: Ref<Scanner>) -> rune
/// Pos returns the position of the character immediately after
/// the character or token returned by the last call to [Scanner.Next] or [Scanner.Scan].
/// Use the [Scanner.Position] field for the start position of the most
/// recently scanned token.
fn Pos(self: Ref<Scanner>) -> Position
/// Scan reads the next token or Unicode character from source and returns it.
/// It only recognizes tokens t for which the respective [Scanner.Mode] bit (1<<-t) is set.
/// It returns [EOF] at the end of the source. It reports scanner errors (read and
/// token errors) by calling s.Error, if not nil; otherwise it prints an error
/// message to [os.Stderr].
fn Scan(self: Ref<Scanner>) -> rune
fn String(self) -> string
/// TokenText returns the string corresponding to the most recently scanned token.
/// Valid after calling [Scanner.Scan] and in calls of [Scanner.Error].
fn TokenText(self: Ref<Scanner>) -> string
}