Scanner

glib.scanner.Scanner 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 @msg_handler field. The type of the message handler function is declared by #GScannerMsgFunc.

class Scanner {
GScanner cInstance;
}

Constructors

this
this(void* ptr, Flag!"Take" take)

Destructor

A destructor is present on this object, but not explicitly documented in the source.

Members

Functions

cPtr
void* cPtr()
curLine
uint curLine()

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

curPosition
uint curPosition()

Returns the current position in the current line (counting from 0). This is the position of the last token parsed via glib.scanner.Scanner.getNextToken.

curToken
glib.types.TokenType curToken()

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

destroy
void destroy()

Frees all memory used by the #GScanner.

eof
bool eof()

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

getNextToken
glib.types.TokenType getNextToken()

Parses the next token just like glib.scanner.Scanner.peekNextToken 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.

inputFile
void inputFile(int inputFd)

Prepares to scan a file.

inputText
void inputText(string text, uint textLen)

Prepares to scan a text buffer.

lookupSymbol
void* lookupSymbol(string symbol)

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.

peekNextToken
glib.types.TokenType peekNextToken()

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.

scopeAddSymbol
void scopeAddSymbol(uint scopeId, string symbol, void* value)

Adds a symbol to the given scope.

scopeForeachSymbol
void scopeForeachSymbol(uint scopeId, glib.types.HFunc func)

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.

scopeLookupSymbol
void* scopeLookupSymbol(uint scopeId, string symbol)

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

scopeRemoveSymbol
void scopeRemoveSymbol(uint scopeId, string symbol)

Removes a symbol from a scope.

setScope
uint setScope(uint scopeId)

Sets the current scope.

syncFileOffset
void syncFileOffset()

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.

unexpToken
void unexpToken(glib.types.TokenType expectedToken, string identifierSpec, string symbolSpec, string symbolName, string message, int isError)

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

Properties

config
glib.scanner_config.ScannerConfig config [@property getter]

Get config field.

inputName
string inputName [@property getter]

Get inputName field.

inputName
string inputName [@property setter]

Set inputName field.

line
uint line [@property getter]

Get line field.

line
uint line [@property setter]

Set line field.

maxParseErrors
uint maxParseErrors [@property getter]

Get maxParseErrors field.

maxParseErrors
uint maxParseErrors [@property setter]

Set maxParseErrors field.

msgHandler
GScannerMsgFunc msgHandler [@property getter]

Get msgHandler field.

msgHandler
GScannerMsgFunc msgHandler [@property setter]

Set msgHandler field.

nextLine
uint nextLine [@property getter]

Get nextLine field.

nextLine
uint nextLine [@property setter]

Set nextLine field.

nextPosition
uint nextPosition [@property getter]

Get nextPosition field.

nextPosition
uint nextPosition [@property setter]

Set nextPosition field.

nextToken
glib.types.TokenType nextToken [@property getter]

Get nextToken field.

nextToken
glib.types.TokenType nextToken [@property setter]

Set nextToken field.

nextValue
glib.token_value.TokenValue nextValue [@property getter]

Get nextValue field.

parseErrors
uint parseErrors [@property getter]

Get parseErrors field.

parseErrors
uint parseErrors [@property setter]

Set parseErrors field.

position
uint position [@property getter]

Get position field.

position
uint position [@property setter]

Set position field.

qdata
glib.types.Data qdata [@property getter]

Get qdata field.

qdata
glib.types.Data qdata [@property setter]

Set qdata field.

token
glib.types.TokenType token [@property getter]

Get token field.

token
glib.types.TokenType token [@property setter]

Set token field.

value
glib.token_value.TokenValue value [@property getter]

Get value field.