glib.scanner

Module for [Scanner] class

class Scanner

Types 1

classScanner

[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.

Fields
GScanner _cInstance
Methods
void * _cPtr()
uint maxParseErrors() @propertyGet `maxParseErrors` field. Returns: unused
void maxParseErrors(uint propval) @propertySet `maxParseErrors` field. Params: propval = unused
uint parseErrors() @propertyGet `parseErrors` field. Returns: [glib.scanner.Scanner.error] increments this field
void parseErrors(uint propval) @propertySet `parseErrors` field. Params: propval = [glib.scanner.Scanner.error] increments this field
string inputName() @propertyGet `inputName` field. Returns: name of input stream, featured by the default message handler
void inputName(string propval) @propertySet `inputName` field. Params: propval = name of input stream, featured by the default message handler
glib.types.Data qdata() @propertyGet `qdata` field. Returns: quarked data
glib.scanner_config.ScannerConfig config() @propertyGet `config` field. Returns: link into the scanner configuration
glib.types.TokenType token() @propertyGet `token` field. Returns: token parsed by the last [glib.scanner.Scanner.getNextToken]
void token(glib.types.TokenType propval) @propertySet `token` field. Params: propval = token parsed by the last [glib.scanner.Scanner.getNextToken]
glib.token_value.TokenValue value() @propertyGet `value` field. Returns: value of the last token from [glib.scanner.Scanner.getNextToken]
uint line() @propertyGet `line` field. Returns: line number of the last token from [glib.scanner.Scanner.getNextToken]
void line(uint propval) @propertySet `line` field. Params: propval = line number of the last token from [glib.scanner.Scanner.getNextToken]
uint position() @propertyGet `position` field. Returns: char number of the last token from [glib.scanner.Scanner.getNextToken]
void position(uint propval) @propertySet `position` field. Params: propval = char number of the last token from [glib.scanner.Scanner.getNextToken]
glib.types.TokenType nextToken() @propertyGet `nextToken` field. Returns: token parsed by the last [glib.scanner.Scanner.peekNextToken]
void nextToken(glib.types.TokenType propval) @propertySet `nextToken` field. Params: propval = token parsed by the last [glib.scanner.Scanner.peekNextToken]
glib.token_value.TokenValue nextValue() @propertyGet `nextValue` field. Returns: value of the last token from [glib.scanner.Scanner.peekNextToken]
uint nextLine() @propertyGet `nextLine` field. Returns: line number of the last token from [glib.scanner.Scanner.peekNextToken]
void nextLine(uint propval) @propertySet `nextLine` field. Params: propval = line number of the last token from [glib.scanner.Scanner.peekNextToken]
uint nextPosition() @propertyGet `nextPosition` field. Returns: char number of the last token from [glib.scanner.Scanner.peekNextToken]
void nextPosition(uint propval) @propertySet `nextPosition` field. Params: propval = char number of the last token from [glib.scanner.Scanner.peekNextToken]
GScannerMsgFunc msgHandler() @propertyGet `msgHandler` field. Returns: handler function for warn and error
void msgHandler(GScannerMsgFunc propval) @propertySet `msgHandler` field. Params: propval = handler function for warn and error
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]. Returns: the current line
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]. Returns: the current position on the line
glib.types.TokenType curToken()Gets the current token type. This is simply the token field in the #GScanner structure. Returns: the current token type
void destroy()Frees all memory used by the #GScanner.
bool eof()Returns true if the scanner has reached the end of the file or text buffer. Returns: true if the scanner has reached the end of the file or text buffer
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 #GScan...
void inputFile(int inputFd)Prepares to scan a file.
void inputText(string text)Prepares to scan a text buffer.
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.
glib.types.TokenType peekNextToken()Parses the next token, without removing it from the input stream. The token data is placed in the nexttoken, nextvalue, nextline, and nextposition fields of the #GScanner structure.
void scopeAddSymbol(uint scopeId, string symbol, void * value = null)Adds a symbol to the given scope.
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.
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.
void scopeRemoveSymbol(uint scopeId, string symbol)Removes a symbol from a scope.
uint setScope(uint scopeId)Sets the current scope.
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 scan...
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.sca...
Constructors
this(void * ptr, Flag!"Take" take)
Destructors