GenericQuoteState

A quoteState returns a quoted string token from a scanner.

Implements: IQuoteState

Description

The GenericQuoteState allows you to create a quoteState that returns a quoted string token from a scanner.

Important points

  • This state will collect characters until it sees a match to the character that the tokenizer used to switch to this state.
  • For example, if a tokenizer uses a double-quote character to enter this state, then nextToken() will search for another double-quote until it finds one or finds the end of the scanner.

Fields

DOT

Represents a dot (.) character.

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

MINUS

Represents a minus (-) character.

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

Instance methods

decodeString

Decodes a string value.

public decodeString(value: string, quoteSymbol: number): string

  • value: string - string value to be decoded.
  • quoteSymbol: number - string quote character.
  • returns: string - decoded string.

encodeString

Encodes a string value.

public encodeString(value: string, quoteSymbol: number): string

  • value: string - string value to be encoded.
  • quoteSymbol: number - string quote character.
  • returns: string - encoded string.

nextToken

Returns a quoted string token from a scanner. This method will collect characters until it sees a match to the character that the tokenizer used to switch 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.