Parser.Lexer
is a submodule of common-token parsers: whitespace handling, integers, identifiers, and literal symbols.
alpha-num
(Fn [] (Parser Char))
(alpha-num)
matches one ASCII letter or digit. Returns the byte.
binary-int
(Fn [] (Parser Int))
(binary-int)
parses a binary integer literal: 0b or 0B
prefix followed by one or more binary digits (0 or 1). Returns an
Int. Fails on overflow.
block-comment
(Fn [String, String] (Parser ()))
(block-comment open close)
skips a block comment delimited by open and
close, with nesting support. An open inside the comment
increments the depth, and each close decrements it. The comment
ends when depth reaches zero. Fails (consumed) if EOF is reached
before the comment closes. Returns unit.
float
(Fn [] (Parser Double))
(float)
parses a floating-point number and returns a Double.
Handles optional leading -, integer part, decimal point with
fractional digits, and optional exponent (e/E with optional
sign). At least one digit must appear in the integer or fractional
part. Uses slice-of and Double.from-string for conversion.
hex-int
(Fn [] (Parser Int))
(hex-int)
parses a hexadecimal integer literal: 0x or 0X
prefix followed by one or more hex digits (0-9, a-f,
A-F). Returns an Int. Fails on overflow.
identifier
(Fn [] (Parser String))
(identifier)
parses a C-style identifier: a letter or
underscore, followed by zero or more letters, digits, or underscores.
Returns the matched text as a String.
integer
(Fn [] (Parser Int))
(integer)
parses an optional - sign followed by decimal
digits as an Int. Fused into a single closure.
lexeme
(Fn [(Parser a)] (Parser a))
(lexeme p)
runs p, then skips trailing whitespace. Returns p's value.
line-comment
(Fn [String] (Parser ()))
(line-comment prefix)
skips a line comment: matches the literal prefix
prefix, then consumes all bytes until end of line or end of input.
The newline itself is not consumed. Returns unit.
lower
(Fn [] (Parser Char))
(lower)
matches one ASCII lowercase letter (a-z). Returns
the byte.
octal-int
(Fn [] (Parser Int))
(octal-int)
parses an octal integer literal: 0o or 0O
prefix followed by one or more octal digits (0-7). Returns an
Int. Fails on overflow.
space
(Fn [] (Parser Char))
(space)
matches one ASCII whitespace byte (space, tab, CR, LF). Returns the byte.
symbol
(Fn [String] (Parser String))
(symbol s)
matches the literal string s, then skips trailing whitespace.
unsigned-int
(Fn [] (Parser Int))
(unsigned-int)
parses one or more decimal digits as an
Int. Fused into a single closure for performance — does not go
through bind/map.
upper
(Fn [] (Parser Char))
(upper)
matches one ASCII uppercase letter (A-Z). Returns
the byte.
whitespace
(Fn [] (Parser ()))
(whitespace)
consumes zero or more ASCII whitespace bytes (space, tab, CR, LF). Always succeeds; the result is unit.