I'm exploring language interpreters and compilers to build a small international compiler that compiles JavaScript with little modifications (to the English reserved words), to vanilla JS.
Modified JS Example:
notfor(notlet i=0; i<5; i++) {
...
}
*obviously "notfor" and "notlet" will not be the real keywords
Vanilla JS Compilation:
for(let i=0; i<5; i++) {
...
}
I've tried the RegEx approach, but I keep finding edge cases where the RegExes fail.
Ex. /notfor(.*)/, this fails when notfor(..){..} is put inside of a string or there is a closing parentheses in any part of the initialization, condition or final-expression of the for statement.
What is another simple approach to this problem?