Fork me on GitHub

Lexer

core/lexer# Lexer

new Lexer(s: string)private

Given a LaTeX expression represented as a character string, the Lexer class will scan and return Tokens for the lexical units in the string.

s : string

A string of LaTeX

Methods

end(): booleanprivate

: boolean   

True if we reached the end of the stream

get(): string

Return the next char and advance

: string   

isWhiteSpace()private

Return true if next char is white space. Does not advance. Note that browsers are inconsistent in their definitions of the \s metacharacter, so use an explicit string match instead.

  • Chrome: [ \t\n\v\f\r\u00A0]
  • Firefox: [ \t\n\v\f\r\u00A0\u2028\u2029]
  • IE: [ \t\n\v\f\r]

See Stackoverflow

makeToken(): Tokenprivate

Return a single token, or null, created from the lexer.

: Token   

peek(): stringprivate

Return the next char, but do not advance

: string   

scan(regEx: RegEx): nullable stringprivate

Return the next substring matching regEx and advance.

regEx : RegEx
: string