Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macro preproc #12

Open
andrieshiemstra opened this issue Apr 14, 2021 · 0 comments
Open

macro preproc #12

andrieshiemstra opened this issue Apr 14, 2021 · 0 comments

Comments

@andrieshiemstra
Copy link
Member

andrieshiemstra commented Apr 14, 2021

something like this

//# // define console_debug macro
//#function console_debug(line){
//#    if ($GRECO_DEBUG) {
//#        // write actually writes to js/ts code
//#        write("console.debug('"+line+"')");
//#    }
//#}
function do_stuff(){
    //#console_debug('doing stuff');
    console.log("do stuff");
}

all files are evaluated in the same context so you can define and redifine functions and variables

The code above will expand to the following if $GRECO_DEBUG = true; (running in debug mode)



function do_stuff(){
    console.debug('doing stuff');
    console.log("do stuff");
}

comments are removed, lines are preserved so line numbers still make sense

a rust util will extract all code prepended by //# and replace all others with write(line)

the whole file is then evaluated with a new write method/buffer and the output is actually used/stored/cached etc

andrieshiemstra added a commit that referenced this issue Apr 14, 2021
andrieshiemstra added a commit that referenced this issue Apr 15, 2021
andrieshiemstra added a commit that referenced this issue Apr 15, 2021
andrieshiemstra added a commit that referenced this issue Apr 16, 2021
andrieshiemstra added a commit that referenced this issue Apr 16, 2021
andrieshiemstra added a commit that referenced this issue Apr 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant