GenericNumberState

A NumberState object that returns a number from a scanner.

Implements: INumberState

Description

The GenericNumberState class allows you to create a NumberState object that 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.

DOT: int = ‘.'.codeUnitAt(0);

MINUS

Represents a minus (-) character.

MINUS: int = ‘-'.codeUnitAt(0);

Instance methods

nextToken

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

@override

Token? nextToken(IScanner scanner, ITokenizer? tokenizer)

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