Quora uses cookies to improve your experience. Read more
Robin Dale
Robin Dale, studied at New Mexico State University

Simply using Pythons re module and string replace methods it is extremely easy to write a compiler for any computer language. Python’s exceptional ability is its OS and sub-process modules that can also directly compile C,C++ and Java using single lines of code with their own command compilers as well. And can save or zip them into any extension format.

As in the first point. If you know which keywords and delimiters to substitute and or string replace you can do it in a single Python file using only one imported module the re module. Re is the Regular Expressions and it makes full use of byte code semantics as simple as adding a single “b” into the re.sub and findall methods as:

file=re.sub(b'{', 'x044', file) #convert
file=re.sub(b'printf','fmt:', file)# to assembly etc.
and
file=re.findall(b':', file) # find all in a file

Also you easily find all the C, C++ and Java delimiters listed online to.

P.S. You would need the “b” binary key letter for verifying your converted types/delims after converting them etc.

About the Author

Studied at New Mexico State University
Lives in Texas
278.9k answer views63.5k this month