From ab067e5732c2bb6315dca315e07336e2c26b524c Mon Sep 17 00:00:00 2001 From: Andrej Mitrovic <andrej.mitrovich@gmail.com> Date: Tue, 11 Feb 2014 12:05:10 +0100 Subject: [PATCH] Change Lexer API: Remove IDType parameter, it can be retrieved via the Token parameter. Re-arrange parameters so tokens are in order and can be used as a typetuple through multiple other templated functions. --- stdx/d/lexer.d | 4 ++-- stdx/lexer.d | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/stdx/d/lexer.d b/stdx/d/lexer.d index cbff766..2b355e0 100644 --- a/stdx/d/lexer.d +++ b/stdx/d/lexer.d @@ -399,8 +399,8 @@ public struct DLexer { import core.vararg; - mixin Lexer!(IdType, Token, lexIdentifier, isSeparating, operators, - dynamicTokens, pseudoTokenHandlers, keywords); + mixin Lexer!(Token, lexIdentifier, isSeparating, pseudoTokenHandlers, + operators, dynamicTokens, keywords); this(ubyte[] range, const LexerConfig config, StringCache* cache) { diff --git a/stdx/lexer.d b/stdx/lexer.d index c013d2f..7a48b21 100644 --- a/stdx/lexer.d +++ b/stdx/lexer.d @@ -367,10 +367,11 @@ public: * } * --- */ -mixin template Lexer(IDType, Token, alias defaultTokenFunction, - alias tokenSeparatingFunction, alias staticTokens, alias dynamicTokens, - alias tokenHandlers, alias possibleDefaultTokens) +mixin template Lexer(Token, alias defaultTokenFunction, + alias tokenSeparatingFunction, alias tokenHandlers, + alias staticTokens, alias dynamicTokens, alias possibleDefaultTokens) { + alias IDType = typeof(Token.type); static assert (tokenHandlers.length % 2 == 0, "Each pseudo-token must" ~ " have a corresponding handler function name.");