Literals

constructor(integerLiteral: Regex? = Regex("""[-+]?[0-9_]+"""), floatingLiteral: Regex? = Regex("""[-+]?[0-9_]*\.[0-9_]+(?:[eE][-+]?[0-9_]+)?"""), singleLineString: Set<String> = setOf("\"", "\'"), escapeSequences: List<Pair<Regex, (String) -> Char>> = emptyList())(source)

creates a configuration of literals for the lexer.

Parameters

integerLiteral

a regex that detects an integer literal.

floatingLiteral

a regex that detects a floating point number literal.

singleLineString

a set of strings that denote the start and end enclosing strings. The lexer will throw a LexicalException when a string literal is not terminated in the same line.

escapeSequences

a list of regex that matches an escape sequence. On match, it will return a Char based on the string matched.