Open timotheecour opened 7 years ago
Out of curiosity, how complex would that feature be to implement?
Low complexity. I already did something similar but for another application that uses libdparse.
Great; is there any code you could share for starters? or at least insights?
Sure. It's about accepting or not a visitor depending on the token text that's in a version.
I've looked at the file that does the job and it's an AST visitor so this will be similar to my stuff:
There was an unsafe access in the first link...changed now.
eg:
dscanner --declarations --ctfe_config=" -version=linux -version=foo"
obviously making this 100% correct would potentially require full semantic analysis but perhaps some simple cases could be handled?
version(foo){ void fun(){} }
else{
version(linux) void fun(){}
else void fun(){} }
enum foo=false; static if(foo){ void fun(){} }
also related: https://github.com/Hackerpilot/Dscanner/issues/214 (would be nice, as i did above, to allow overriding OS)