On Monday, 14 July 2014 at 11:43:01 UTC, Philippe Sigaud via Digitalmars-d-learn wrote:

You can try Pegged, a parser generator that works at compile-time
(both the generator and the generated parser).

I did, and I got it to work. Unfortunately, the code used to in the CTFE is left in the final executable even though it is not used at runtime. So now the question is, is there away to get rid of the excess baggage?

BTW Here is the code I am playing with.

import std.stdio;

string get_match()
{
  import pegged.grammar;
  mixin(grammar(`
    MyRegex:
        foo <- "abc"* "def"?
    `));

auto result = MyRegex(import("config-file.txt")); // compile-time parsing
  return "writeln(\""~result.matches[0]~"\");";
}

void main()
{
  mixin(get_match());
}

Reply via email to