www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Cache Building of Pegged-Generated Parsers in a DUB Project

reply =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
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?
Nov 26 2014
parent reply "Stefan Koch" <uplink.coder googlemail.com> writes:
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
Nov 26 2014
next sibling parent =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
On Wednesday, 26 November 2014 at 12:09:34 UTC, Stefan Koch wrote:
 preBuildCommand in check if the files are there
 if not generate them if yes do nothing
Thanks! Documented here http://code.dlang.org/package-format by searching for preBuildCommands
Nov 26 2014
prev sibling parent =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
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.
Nov 26 2014