CT regex in AA at compile time
Taylor Hillegeist
taylorh140 at gmail.com
Tue Jan 7 15:40:58 UTC 2020
I'm trying to trick the following code snippet into compilation.
enum TokenType{
//Terminal
Plus,
Minus,
LPer,
RPer,
Number,
}
static auto Regexes =[
TokenType.Plus: ctRegex!(`^ *\+`),
TokenType.Minus: ctRegex!(`^ *\-`),
TokenType.LPer: ctRegex!(`^ *\(`),
TokenType.RPer: ctRegex!(`^ *\)`),
TokenType.Number: ctRegex!(`^ *[0-9]+(.[0-9]+)?`)
];
but I can't get it to work. it says its an Error: non-constant
expression.
I imagine this has to do with the ctRegex template or something.
maybe there is a better way? Does anyone know?
More information about the Digitalmars-d-learn
mailing list