Thread overview | ||||||
---|---|---|---|---|---|---|
|
October 16, 2018 Is there a way to use std.regex at compile-time? | ||||
---|---|---|---|---|
| ||||
Is there a way to use std.regex at compile-time? |
October 16, 2018 Re: Is there a way to use std.regex at compile-time? | ||||
---|---|---|---|---|
| ||||
Posted in reply to cosinus | On Tuesday, 16 October 2018 at 14:42:32 UTC, cosinus wrote: > Is there a way to use std.regex at compile-time? I would like to `mixin()` the result of this function: ```D string generateVertexStruct() { auto reVertex = ctRegex!(`in\s+(?P<type>\w+)\s+(?P<name>\w+)\s*;`); const vertexStruct = format!q{ struct Vertex { %s } }(matchAll(vertexShader, reVertex).map!(res => format!q{ %1$s %2$s; }(res["type"], res["name"])).fold!((a, b) => a ~ "\n" ~ b) ); return vertexStruct; } ``` |
October 16, 2018 Re: Is there a way to use std.regex at compile-time? | ||||
---|---|---|---|---|
| ||||
Posted in reply to cosinus | On Tuesday, 16 October 2018 at 14:47:19 UTC, cosinus wrote:
> On Tuesday, 16 October 2018 at 14:42:32 UTC, cosinus wrote:
>> Is there a way to use std.regex at compile-time?
>
> I would like to `mixin()` the result of this function:
>
> ```D
> string generateVertexStruct()
> {
> auto reVertex = ctRegex!(`in\s+(?P<type>\w+)\s+(?P<name>\w+)\s*;`);
> const vertexStruct = format!q{
> struct Vertex {
> %s
> }
> }(matchAll(vertexShader, reVertex).map!(res => format!q{
> %1$s %2$s;
> }(res["type"], res["name"])).fold!((a, b) => a ~ "\n" ~ b)
> );
> return vertexStruct;
> }
>
> ```
nope
|
October 16, 2018 Re: Is there a way to use std.regex at compile-time? | ||||
---|---|---|---|---|
| ||||
Posted in reply to cosinus | 16.10.2018 17:47, cosinus пишет: > On Tuesday, 16 October 2018 at 14:42:32 UTC, cosinus wrote: >> Is there a way to use std.regex at compile-time? > > I would like to `mixin()` the result of this function: > > ```D > string generateVertexStruct() > { > auto reVertex = ctRegex!(`in\s+(?P<type>\w+)\s+(?P<name>\w+)\s*;`); > const vertexStruct = format!q{ > struct Vertex { > %s > } > }(matchAll(vertexShader, reVertex).map!(res => format!q{ > %1$s %2$s; > }(res["type"], res["name"])).fold!((a, b) => a ~ "\n" ~ b) > ); > return vertexStruct; > } > > ``` offtopic but look at https://github.com/d-gamedev-team/gfm/blob/master/opengl/gfm/opengl/vertex.d#L42 |
Copyright © 1999-2021 by the D Language Foundation