by p4bl0 · 5y ago · 0 comments
This is my effort - trying to show genuine data structures and processes.
But the project is unfinished I’m afraid - you will find dead-ends.
while expression is not a numeral
replace all "\((NUMERAL)\)" with first group
if find first "(NUMERAL)([*/])(NUMERAL)"
replace with result
else if find first "(NUMERAL)([+-])(NUMERAL)"
replace with resultBut nonetheless even if regexps would not be able to validate syntax, it does not mean that the source-to-source transformation could not be (mostly) achieved using them, because the source and target language are quite similar.
Imagine a new language exactly like C but every semicolon is replaced by a duck "\_o<". You could not parse it using regexps, but regexp could mostly "compile" it to C as it only requires to look for all "\_o<" to replace them with ";".
*A real Regular Expression. The extended versions with e.g backrefs can. But they're also Turing complete anyway