Scanner

class Scanner(pointer: <Error class: unknown class><<Error class: unknown class>>) : Record

The data structure representing a lexical scanner.

You should set @input_name after creating the scanner, since it is used by the default message handler when displaying warnings and errors. If you are scanning a file, the filename would be a good choice.

The @user_data and @max_parse_errors fields are not used. If you need to associate extra data with the scanner you can place them here.

If you want to use your own message handler you can set the

Constructors

Link copied to clipboard
constructor(pointer: <Error class: unknown class><<Error class: unknown class>>)

Types

Link copied to clipboard
object Companion : RecordCompanion<Scanner, <Error class: unknown class>>

Properties

Link copied to clipboard

link into the scanner configuration

Link copied to clipboard
val glibScannerPointer: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard

name of input stream, featured by the default message handler

Link copied to clipboard
var line: <Error class: unknown class>

line number of the last token from g_scanner_get_next_token()

Link copied to clipboard
var maxParseErrors: <Error class: unknown class>

unused

Link copied to clipboard
var nextLine: <Error class: unknown class>

line number of the last token from g_scanner_peek_next_token()

Link copied to clipboard
var nextPosition: <Error class: unknown class>

char number of the last token from g_scanner_peek_next_token()

Link copied to clipboard

token parsed by the last g_scanner_peek_next_token()

Link copied to clipboard
var parseErrors: <Error class: unknown class>

g_scanner_error() increments this field

Link copied to clipboard
var position: <Error class: unknown class>

char number of the last token from g_scanner_get_next_token()

Link copied to clipboard

token parsed by the last g_scanner_get_next_token()

Functions

Link copied to clipboard
fun curLine(): <Error class: unknown class>

Returns the current line in the input stream (counting from 1). This is the line of the last token parsed via g_scanner_get_next_token().

Link copied to clipboard
fun curPosition(): <Error class: unknown class>

Returns the current position in the current line (counting from 0). This is the position of the last token parsed via g_scanner_get_next_token().

Link copied to clipboard

Gets the current token type. This is simply the @token field in the #GScanner structure.

Link copied to clipboard
fun destroy()

Frees all memory used by the #GScanner.

Link copied to clipboard
fun eof(): Boolean

Returns true if the scanner has reached the end of the file or text buffer.

Link copied to clipboard

Parses the next token just like g_scanner_peek_next_token() and also removes it from the input stream. The token data is placed in the @token, @value, @line, and @position fields of the #GScanner structure.

Link copied to clipboard
fun inputFile(inputFd: Int)

Prepares to scan a file.

Link copied to clipboard
fun inputText(text: String, textLen: <Error class: unknown class>)

Prepares to scan a text buffer.

Link copied to clipboard

Parses the next token, without removing it from the input stream. The token data is placed in the @next_token, @next_value, @next_line, and @next_position fields of the #GScanner structure.

Link copied to clipboard
fun scopeRemoveSymbol(scopeId: <Error class: unknown class>, symbol: String)

Removes a symbol from a scope.

Link copied to clipboard
fun setScope(scopeId: <Error class: unknown class>): <Error class: unknown class>

Sets the current scope.

Link copied to clipboard

Rewinds the filedescriptor to the current buffer position and blows the file read ahead buffer. This is useful for third party uses of the scanners filedescriptor, which hooks onto the current scanning position.

Link copied to clipboard
fun unexpToken(expectedToken: TokenType, identifierSpec: String, symbolSpec: String, symbolName: String, message: String, isError: Int)

Outputs a message through the scanner's msg_handler, resulting from an unexpected token in the input stream. Note that you should not call g_scanner_peek_next_token() followed by g_scanner_unexp_token() without an intermediate call to g_scanner_get_next_token(), as g_scanner_unexp_token() evaluates the scanner's current token (not the peeked token) to construct part of the message.