Scanner

class Scanner(pointer: <Error class: unknown class><<Error class: unknown class>>, cleaner: <Error class: unknown class>? = null) : ProxyInstance

GScanner provides a general-purpose 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()

Allocate a new Scanner.

constructor(scope: <Error class: unknown class>)

Allocate a new Scanner using the provided AutofreeScope.

constructor(userData: <Error class: unknown class>, maxParseErrors: <Error class: unknown class>, parseErrors: <Error class: unknown class>, inputName: String?, config: ScannerConfig?, token: TokenType, line: <Error class: unknown class>, position: <Error class: unknown class>, nextToken: TokenType, nextLine: <Error class: unknown class>, nextPosition: <Error class: unknown class>)

Allocate a new Scanner.

constructor(userData: <Error class: unknown class>, maxParseErrors: <Error class: unknown class>, parseErrors: <Error class: unknown class>, inputName: String?, config: ScannerConfig?, token: TokenType, line: <Error class: unknown class>, position: <Error class: unknown class>, nextToken: TokenType, nextLine: <Error class: unknown class>, nextPosition: <Error class: unknown class>, scope: <Error class: unknown class>)

Allocate a new Scanner using the provided AutofreeScope.

constructor(pointer: <Error class: unknown class><<Error class: unknown class>>, cleaner: <Error class: unknown class>? = null)

Types

Link copied to clipboard
object Companion

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
open override val handle: <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()

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

unused

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
open operator override fun equals(other: Any?): Boolean

Compare two proxy instances for equality. This will compare both the type of the instances, and their memory addresses.

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
open override fun hashCode(): Int
Link copied to clipboard
fun inputFile(inputFd: <Error class: unknown class>)

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
fun lookupSymbol(symbol: String): <Error class: unknown class>?

Looks up a symbol in the current scope and return its value. If the symbol is not bound in the current scope, null is returned.

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 scopeAddSymbol(scopeId: <Error class: unknown class>, symbol: String, value: <Error class: unknown class>? = null)

Adds a symbol to the given scope.

Link copied to clipboard
fun scopeForeachSymbol(scopeId: <Error class: unknown class>, func: HFunc)

Calls the given function for each of the symbol/value pairs in the given scope of the #GScanner. The function is passed the symbol and value of each pair, and the given @user_data parameter.

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

Looks up a symbol in a scope and return its value. If the symbol is not bound in the scope, null is returned.

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
open override fun toString(): String
Link copied to clipboard
fun unexpToken(expectedToken: TokenType, identifierSpec: String, symbolSpec: String, symbolName: String, message: String, isError: <Error class: unknown class>)

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.