Gjsify LogoGjsify Logo

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

record

Hierarchy

  • Scanner

Index

Constructors

Properties

link into the scanner configuration

field
inputName: string

name of input stream, featured by the default message handler

field
line: number

line number of the last token from g_scanner_get_next_token()

field
maxParseErrors: number

unused

field
msgHandler: ScannerMsgFunc

handler function for _warn and _error

field
nextLine: number

line number of the last token from g_scanner_peek_next_token()

field
nextPosition: number

char number of the last token from g_scanner_peek_next_token()

field
nextToken: GLib.TokenType

token parsed by the last g_scanner_peek_next_token()

field
nextValue: TokenValue

value of the last token from g_scanner_peek_next_token()

field
parseErrors: number

g_scanner_error() increments this field

field
position: number

char number of the last token from g_scanner_get_next_token()

field
qdata: GLib.Data

quarked data

field

token parsed by the last g_scanner_get_next_token()

field
userData: object

unused

field
value: TokenValue

value of the last token from g_scanner_get_next_token()

field
name: string

Methods

  • curLine(): number
  • 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 number

  • curPosition(): number
  • 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().

    Returns number

  • destroy(): void
  • eof(): boolean
  • Returns %TRUE if the scanner has reached the end of the file or text buffer.

    Returns boolean

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

    Returns GLib.TokenType

  • inputFile(inputFd: number): void
  • Prepares to scan a file.

    Parameters

    • inputFd: number

      a file descriptor

    Returns void

  • inputText(text: string, textLen: number): void
  • Prepares to scan a text buffer.

    Parameters

    • text: string

      the text buffer to scan

    • textLen: number

      the length of the text buffer

    Returns void

  • lookupSymbol(symbol: string): object
  • 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.

    Parameters

    • symbol: string

      the symbol to look up

    Returns object

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

    Returns GLib.TokenType

  • scopeAddSymbol(scopeId: number, symbol: string, value: object): void
  • Adds a symbol to the given scope.

    Parameters

    • scopeId: number

      the scope id

    • symbol: string

      the symbol to add

    • value: object

      the value of the symbol

    Returns void

  • scopeLookupSymbol(scopeId: number, symbol: string): object
  • Looks up a symbol in a scope and return its value. If the symbol is not bound in the scope, %NULL is returned.

    Parameters

    • scopeId: number

      the scope id

    • symbol: string

      the symbol to look up

    Returns object

  • scopeRemoveSymbol(scopeId: number, symbol: string): void
  • Removes a symbol from a scope.

    Parameters

    • scopeId: number

      the scope id

    • symbol: string

      the symbol to remove

    Returns void

  • setScope(scopeId: number): number
  • Sets the current scope.

    Parameters

    • scopeId: number

      the new scope id

    Returns number

  • syncFileOffset(): void
  • 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.

    Returns void

  • unexpToken(expectedToken: GLib.TokenType, identifierSpec: string, symbolSpec: string, symbolName: string, message: string, isError: number): void
  • 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.

    Parameters

    • expectedToken: GLib.TokenType

      the expected token

    • identifierSpec: string

      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.

    • symbolSpec: string

      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.

    • symbolName: string

      the name of the symbol, if the scanner's current token is a symbol.

    • message: string

      a message string to output at the end of the warning/error, or %NULL.

    • isError: number

      if %TRUE it is output as an error. If %FALSE it is output as a warning.

    Returns void

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method