Last active
March 24, 2021 23:56
-
-
Save JavascriptLearner815/55a63545b94085673c73871e96f4a2ea to your computer and use it in GitHub Desktop.
Custom Programming Language Snippet
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
// src: https://github.com/JavascriptLearner815/custom-programming-language/blob/main/script.js | |
btn.addEventListener("click", () => { // line 36 | |
const { value } = code; // line 37 | |
let stopped = false; // line 38 | |
// line 39 | |
[...value.matchAll(consoleRegExp)].forEach(m => { // line 40 | |
if (!stopped) console.log(m[1]); // line 41 | |
}); // line 42 | |
[...value.matchAll(globalVarRegExp)].forEach(m => { // line 43 | |
if (!stopped) globalVariables[m[1]] = m[2]; // line 44 | |
}); // line 45 | |
[...value.matchAll(globalVarNoValRegExp)].forEach(m => { // line 46 | |
if (!stopped) globalVariables[m[1]] = null; // line 47 | |
}); // line 48 | |
[...value.matchAll(getVarAndConsoleRegExp)].forEach(m => { // line 49 | |
if (!stopped) console.log(globalVariables[m[1]] ?? "Unspecified"); // line 50 | |
}); // line 51 | |
[...value.matchAll(commentRegExp)].forEach(m => { // line 52 | |
; // line 53 | |
}); // line 54 | |
[...value.matchAll(stopRegExp)].forEach(m => { // line 55 | |
stopped = true; // (line 56) The problem is that the code is not ensured to be run with the stop in the desired order. Please go tell me in Discussions if you know a fix. | |
}); // line 57 | |
// line 58 | |
setTimeout(() => { // line 59 | |
alert("Code executed; remember to check your console (Ctrl+Shift+I or Command+Shift+I, then press \"Console\")!"); // line 60 | |
}); // line 61 | |
}); // line 62 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment