Mathematica allows you to pattern match based on type and operate on itself because of it's list nature.
a[b] /. a -> d returns
How would I go about creating a function that compile programming languages(Pyhton in this example) into a format that can be pattern matched by mathematica?
x=CompilePythonToList["def a(b): return c(b);"]
then pattern match against the lists and compile back to Python
x /. c(x_) -> d(x) x=CompileListToPython[x];
x now contains
def a(b): return d(b);
I am have traditionally used regex to search and replace code but I have run into similar issues as described here. I believe it would require implementing a lexer of some kind, but was wondering if there was any advice in terms of implementing a system that works across a entire range of languages.
Maybe I could adapt the code that is used to syntax highlight different programming languages to support multiple programming languages?
I feel certain someone has created something similar before.