Advances the lexer to the next token and stores the new current token in the _front variable.
Implements the range primitive empty.
Implements the range primitive front.
The token that is currently at the front of the range.
The lexer input.
struct CalculatorLexer { mixin Lexer!(IdType, Token, defaultTokenFunction, isSeparating, staticTokens, dynamicTokens, possibleDefaultTokens, tokenHandlers); this (ubyte[] bytes) { this.range = LexerRange(bytes); popFront(); } void popFront() pure { _popFront(); } Token lexNumber() pure nothrow @safe { // implementation goes here } Token lexWhitespace() pure nothrow @safe { // implementation goes here } Token defaultTokenFunction() pure nothrow @safe { // There is no default token in the example calculator language, so // this is always an error. range.popFront(); return Token(tok!""); } bool isSeparating(size_t offset) pure nothrow @safe { // For this example language, always return true. return true; } }
The implementation of the _lexer is contained within this mixin template.
To use it, this template should be mixed in to a struct that represents the _lexer for your language. This struct should implement the following methods: