dex.cf.lexer

CF Lexer - Tokenizer for CF Configuration Files

This module provides a lexer that converts CF source text into a stream of tokens. It implements the input range interface for convenient iteration and preserves comments as tokens for roundtrip-preserving document model support.

The lexer handles:

  • Whitespace (space, tab, CR, LF) - LF emits NEWLINE tokens for separator detection
  • Line comments (hash and double-slash) - preserved as COMMENT tokens
  • Block comments (slash-star) - preserved as BLOCK_COMMENT tokens
  • Punctuation: braces, brackets, equals, colon, comma, semicolon
  • String literals (double, single, triple, raw quoted)
  • Numbers (integers and floats)
  • Identifiers and keywords
  • Temporal literals (date, time, datetime)

Types 1

structLexer

Lexer for CF source text.

Converts CF source into a stream of tokens, implementing the input range interface. Comments are preserved as tokens to support the roundtrip-preserving document model.

Example:

auto lexer = Lexer(`{ key = "value" }`);
foreach (token; lexer) {
    writeln(token);
}

Methods
Token front() @safe pureReturns the current token.
void popFront() @safe pureAdvances to the next token.
bool empty() @safe pureChecks if the token stream is exhausted.
void lexIdentifierOrKeyword() @safe pure
Constructors
this(string input, string sourceFilename = "")Constructs a lexer for the given CF source text.

Functions 2

fnLexer tokenize(string input, string filename = "") @safe pureCreates a lexer for the given CF source text.
fnToken[] tokenizeAll(string input, string filename = "") @safe pureTokenizes the input and eagerly collects all tokens into an array.