Created
January 17, 2022 21:28
-
-
Save Vurv78/556d5e739299f8798ae48c8c550eb106 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const rgx = /virtual\s+(\w+)\s*\*?\s+\*?(\w+)\(([^)]+)\)/g; | |
const foo = document.getElementById("area"); | |
const textarea = document.getElementById("code"); | |
const btn = document.getElementById("btn"); | |
btn.onclick = function() { | |
const code = textarea.value; | |
let submissions = code.matchAll(rgx); | |
const outputs = []; | |
let ind = 0; | |
for(const [full, ret, name, params] of submissions) { | |
outputs.push(`#[virtual_index(${ind})] pub fn ${name}(${params}) -> ${ret} {}`); | |
ind++; | |
} | |
foo.value = outputs.join("\n"); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment