The lexer is responsible for turning a string of characters into a stream of tokens. The tokens are then used by the parser to build an abstract syntax tree.

The lexer handles parsing of string literals, digraphs (e.g. <=), and numbers. It also handles detecting keywords and identifiers.

Constructors

Properties

_currLocCache: null | CodeLocation = null
charOffset: number = 0
codeFile: CodeFile
colOffset: number = 0
currentExtraTokens: ExtraToken[] = []
errorCollector: ErrorCollector
lineOffset: number = 0
startWithWhitespace: CodeLocation
tokens: Token[] = []

Methods

  • Adds a token to the token list. If a value is provieded a LiteralToken is pushed.

    Additionally it handles clearing and attaching the extra tokens.

    Type Parameters

    • TValue = any

    Parameters

    Returns void

  • Returns void

  • Parameters

    • expected: string

    Returns boolean

  • Parameters

    • regex: RegExp

    Returns string

  • Scans the whole CodeFile and splits it into tokens.

    Returns Token[]

    LexingError