www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Can you parse the d source file during compile time with std.regex?

reply 12345swordy <alexanderheistermann gmail.com> writes:
I don't see this anywhere in the documentation. I am asking this 
as I want to know that it's possible to create a attribute to 
prevent certain functions being called in the body of a function. 
To enforce a certain code standard upon myself.
Aug 01 2017
parent reply Stefan Koch <uplink.coder googlemail.com> writes:
On Tuesday, 1 August 2017 at 16:16:46 UTC, 12345swordy wrote:
 I don't see this anywhere in the documentation. I am asking 
 this as I want to know that it's possible to create a attribute 
 to prevent certain functions being called in the body of a 
 function. To enforce a certain code standard upon myself.
UDA's are your friend here. There is no need to use parser, and in any case std.regex cannot match the regex at ct.
Aug 01 2017
parent 12345swordy <alexanderheistermann gmail.com> writes:
On Tuesday, 1 August 2017 at 16:20:07 UTC, Stefan Koch wrote:
 On Tuesday, 1 August 2017 at 16:16:46 UTC, 12345swordy wrote:
 I don't see this anywhere in the documentation. I am asking 
 this as I want to know that it's possible to create a 
 attribute to prevent certain functions being called in the 
 body of a function. To enforce a certain code standard upon 
 myself.
UDA's are your friend here. There is no need to use parser, and in any case std.regex cannot match the regex at ct.
I know that UDA exist, what I want to know if it is possible to create one that prevent certain things like calling certain functions in a function body Ie custom main() { //function body example()//throw error by custom } There is no getRawFunctionBody for traits either, so I was thinking about using std.regex to get the string of the function body and and then parse that string during compile time. Alex
Aug 01 2017