Fork me on GitHub

Lexer

Lexer

new Lexer(s: string)private

s string
Source

Methods

end() → booleanprivate

boolean   

True if we reached the end of the stream

Source

get() → string

Return the next char and advance

string   
Source

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

Source

makeToken()Tokenprivate

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

Token   
Source

peek() → stringprivate

Return the next char, but do not advance

string   
Source

scan(regEx: RegEx)nullable stringprivate

Return the next substring matching regEx and advance.

regEx RegEx
string   
Source