ScannerG

Description The GScanner and its associated functions provide a general purpose lexical scanner.

Constructors

this
this(GScanner* gScanner)

Sets our main struct and passes it to the parent class

this
this(GScannerConfig* configTempl)

Creates a new GScanner. The config_templ structure specifies the initial settings of the scanner, which are copied into the GScanner config field. If you pass NULL then the default settings are used.

Members

Functions

curLine
uint curLine()

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().

curPosition
uint curPosition()

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().

curToken
GTokenType curToken()

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

curValue
GTokenValue curValue()

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

destroy
void destroy()

Frees all memory used by the GScanner.

eof
int eof()

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

getNextToken
GTokenType getNextToken()

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.

getScannerGStruct
GScanner* getScannerGStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getStruct
void* getStruct()

the main Gtk struct as a void*

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
GTokenType 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. Note that, while the token is not removed from the input stream (i.e. the next call to g_scanner_get_next_token() will return the same token), it will not be reevaluated. This can lead to surprising results when changing scope or the scanner configuration after peeking the next token. Getting the next token after switching the scope or configuration will return whatever was peeked before, regardless of any symbols that may have been added or removed in the new scope.

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

Adds a symbol to the given scope.

scopeForeachSymbol
void scopeForeachSymbol(uint scopeId, GHFunc func, void* userData)

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(GTokenType 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 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.

Variables

gScanner
GScanner* gScanner;

the main Gtk struct

Meta