link into the scanner configuration
name of input stream, featured by the default message handler
line number of the last token from g_scanner_get_next_token()
unused
handler function for _warn and _error
line number of the last token from g_scanner_peek_next_token()
char number of the last token from g_scanner_peek_next_token()
token parsed by the last g_scanner_peek_next_token()
value of the last token from g_scanner_peek_next_token()
g_scanner_error() increments this field
char number of the last token from g_scanner_get_next_token()
quarked data
token parsed by the last g_scanner_get_next_token()
unused
value of the last token from g_scanner_get_next_token()
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().
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().
Frees all memory used by the #GScanner.
Returns %TRUE if the scanner has reached the end of the file or text buffer.
Prepares to scan a file.
a file descriptor
Prepares to scan a text buffer.
the text buffer to scan
the length of the text buffer
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.
the symbol to look up
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.
Adds a symbol to the given scope.
the scope id
the symbol to add
the value of the symbol
Looks up a symbol in a scope and return its value. If the symbol is not bound in the scope, %NULL is returned.
the scope id
the symbol to look up
Removes a symbol from a scope.
the scope id
the symbol to remove
Sets the current scope.
the new scope id
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.
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.
the expected token
a string describing how the scanner's user refers to identifiers (%NULL defaults to "identifier"). This is used if expected_token
is %G_TOKEN_IDENTIFIER or %G_TOKEN_IDENTIFIER_NULL.
a string describing how the scanner's user refers to symbols (%NULL defaults to "symbol"). This is used if expected_token
is %G_TOKEN_SYMBOL or any token value greater than %G_TOKEN_LAST.
the name of the symbol, if the scanner's current token is a symbol.
a message string to output at the end of the warning/error, or %NULL.
if %TRUE it is output as an error. If %FALSE it is output as a warning.
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
andmax_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.