XU XUv0.8.8
中文

API

#text/scanner

import: #text/scanner

counts: 1 fns, 7 methods, 1 types, 8 consts, 0 ifaces

Token scan: Ident/Int/Float/Char/String; source is an owning string.

const eof

XuAPI
pub const eof = -1

Purpose

Tokenizer aligned with `text/scanner` default GoTokens skip whitespace and comments; recognize Ident / Int / Float Char / String / RawString; other bytes are single-char tokens. Source is an owning string (no io.Reader). ASCII column = byte count. Value `-1`.

Parameters

none

const ident

XuAPI
pub const ident = -2

Purpose

Public constant `ident`. Value `-2`.

Parameters

none

const scan_int

XuAPI
pub const scan_int = -3

Purpose

Public constant `scan_int`. Value `-3`.

Parameters

none

const float

XuAPI
pub const float = -4

Purpose

Public constant `float`. Value `-4`.

Parameters

none

const char

XuAPI
pub const char = -5

Purpose

Public constant `char`. Value `-5`.

Parameters

none

const scan_string

XuAPI
pub const scan_string = -6

Purpose

Public constant `scan_string`. Value `-6`.

Parameters

none

const raw_string

XuAPI
pub const raw_string = -7

Purpose

Public constant `raw_string`. Value `-7`.

Parameters

none

const comment

XuAPI
pub const comment = -8

Purpose

Public constant `comment`. Value `-8`.

Parameters

none

struct Scanner

XuAPI
pub struct Scanner {
    pub src string
    pub pos int
    pub line int
    pub col int
    pub tok int
    pub text string
    pub tok_line int
    pub tok_col int
}

Purpose

Public struct `Scanner`.

Parameters

src string
source
pos int
field (int)
line int
field (int)
col int
field (int)
tok int
field (int)
text string
text
tok_line int
field (int)
tok_col int
field (int)

new

XuAPI
pub fn new(src &string) Scanner

Purpose

Construct a new value of this type.

Parameters

src &string
source (borrowed; caller keeps it; type &string)

Returns

Scanner — a value of this type

(&mut Scanner) peek

XuAPI
pub fn (s &mut Scanner) peek() int

Purpose

Call `peek` on `&mut Scanner`.

Parameters

s &mut Scanner
receiver &mut Scanner (exclusive borrow)

Returns

int — a value of this type

(&mut Scanner) next

XuAPI
pub fn (s &mut Scanner) next() int

Purpose

Method on `&mut Scanner`: take the next item, or end according to this type.

Parameters

s &mut Scanner
receiver &mut Scanner (exclusive borrow)

Returns

int — a value of this type

(&mut Scanner) scan

XuAPI
pub fn (s &mut Scanner) scan() int

Purpose

Call `scan` on `&mut Scanner`.

Parameters

s &mut Scanner
receiver &mut Scanner (exclusive borrow)

Returns

int — a value of this type

(Scanner) token_text

XuAPI
pub fn (s Scanner) token_text() string

Purpose

Method on `Scanner`: token text.

Parameters

s Scanner
receiver Scanner (value receiver)

Returns

string — result string

(Scanner) line

XuAPI
pub fn (s Scanner) line() int

Purpose

Call `line` on `Scanner`.

Parameters

s Scanner
receiver Scanner (value receiver)

Returns

int — a value of this type

(Scanner) column

XuAPI
pub fn (s Scanner) column() int

Purpose

Call `column` on `Scanner`.

Parameters

s Scanner
receiver Scanner (value receiver)

Returns

int — a value of this type

(Scanner) token

XuAPI
pub fn (s Scanner) token() int

Purpose

Call `token` on `Scanner`.

Parameters

s Scanner
receiver Scanner (value receiver)

Returns

int — a value of this type