GenericNumberState

A NumberState object returns a number from a scanner.

Implements: INumberState

Description

The GenericNumberState class allows you to create a NumberState object returns a number from a scanner.

Important points

  • This state’s idea of a number allows an optional, initial minus sign, followed by one or more digits. A decimal point and another string of digits may follow these digits.

Fields

DOT

Represents a dot (.) character.

protected DOT: number = ‘.'.charCodeAt(0);

MINUS

Represents a minus (-) character.

protected MINUS: number = ‘-'.charCodeAt(0);

Instance methods

nextToken

Gets the next token from the stream started from the character linked to this state.

public nextToken(scanner: IScanner, tokenizer: ITokenizer): Token

  • scanner: IScanner - text string to be tokenized.
  • tokenizer: ITokenizer - tokenizer class that controls the process.
  • returns: Token - next token from the top of the stream.