Lexer
The lexer is responsible to convert the given string into a stream of Tokens. The lexer take in multiple settings that configure how it behaves. It will perform lexical analysis on a line-by-line basis and return the next unconsumed token. A newline character is always separates a token.
Author
Nishant Aanjaney Jalan
Since
0.1.0
Parameters
characters that satisfy this regex would be skipped. (Default: "\s+")
The regex that defines how a single-line comment starts. Once identified, the lexer will skip the remaining line. (Default: null)
A pair of regexes, the starting pattern and the ending pattern for a multiline comment block. (Default: null)
A regex string that defines the rules for defining a name. (Default: "a-zA-Z_\w*")
A set of strings that are considered hard keywords. Hard keywords are a characters and symbols that give a particular meaning to a program. They may not be used as identifiers. (Default: [])
A set of strings that are considered as operators. Operators are characters and symbols that may perform arithmetic or logical operations. (Default: [])
A set of strings that are considered as separators. Separators are characters and symbols that act like delimiters to separate other meaningful elements. (Default: [])
The configuration of literals. Literals denote constant values such as numbers, strings, and characters. (Default: see Literals)
Constructors
Creates a lexer with the provided properties.