Cache Building of Pegged-Generated Parsers in a DUB Project

"Nordlöw" via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Nov 26 05:30:57 PST 2014


On Wednesday, 26 November 2014 at 12:09:34 UTC, Stefan Koch wrote:
> On Wednesday, 26 November 2014 at 10:26:05 UTC, Nordlöw wrote:
>> I want to cache parsers generated by Pegged grammars in a DUB 
>> project by writing the generated parser strings to files.
>>
>> Is it possible to add this build logic somewhere in DUB or do 
>> I have to resort to SCons for this?
>
> preBuildCommand in check if the files are there
> if not generate them if yes do nothing

I guess I could right a separate d program that generates the 
files called by preBuildCommand. But it would be even greater if 
we could do CTFE-file-io to check whether the evaluation needs to 
be called at all. As we can import files  (generated parser 
module) into strings and write the generated parser strings at 
run-time the only thing need is to add some logic that generates 
a digest every time a parser is generated write that digest to a 
file and then import that digest at compile time at compare it to 
the digest of the parser string read at compile time. If they 
differ (at compile time) using static if the parser enum string 
is updated. Does my vision hold water? Destroy.


More information about the Digitalmars-d-learn mailing list