Merge pull request #102 from AndrejMitrovic/TokenAPIChange

Change Lexer API
This commit is contained in:
Hackerpilot 2014-02-11 10:06:22 -08:00
commit aa8a3754de
2 changed files with 6 additions and 5 deletions

View File

@ -399,8 +399,8 @@ public struct DLexer
{ {
import core.vararg; import core.vararg;
mixin Lexer!(IdType, Token, lexIdentifier, isSeparating, operators, mixin Lexer!(Token, lexIdentifier, isSeparating, pseudoTokenHandlers,
dynamicTokens, pseudoTokenHandlers, keywords); operators, dynamicTokens, keywords);
this(ubyte[] range, const LexerConfig config, StringCache* cache) this(ubyte[] range, const LexerConfig config, StringCache* cache)
{ {

View File

@ -368,10 +368,11 @@ public:
* } * }
* --- * ---
*/ */
mixin template Lexer(IDType, Token, alias defaultTokenFunction, mixin template Lexer(Token, alias defaultTokenFunction,
alias tokenSeparatingFunction, alias staticTokens, alias dynamicTokens, alias tokenSeparatingFunction, alias tokenHandlers,
alias tokenHandlers, alias possibleDefaultTokens) alias staticTokens, alias dynamicTokens, alias possibleDefaultTokens)
{ {
alias IDType = typeof(Token.type);
static assert (tokenHandlers.length % 2 == 0, "Each pseudo-token must" static assert (tokenHandlers.length % 2 == 0, "Each pseudo-token must"
~ " have a corresponding handler function name."); ~ " have a corresponding handler function name.");