I am writing a compiler (for a practice language) in python and I want to split my text to tokens by spaces or comments. I tried /\*.*?\*/|/{2}.*?\n|\s : the fisr regex pattern is supposed to fine comments in the form of /** text */ or /* text */, possibly multyline. The second regex is supposed to fine comments in the form of // text that ends with the new line character. The last one finds white spaces.
My question:
I checked my regex here and it seemes to be great, but when I call
temp = file.read()
temp = temp.split('/\*.*?\*/|\/{2}.*?\n|\s',flags=DOTALL)
print temp
it returns a list with only one elements which is the entire text I'm parsing.
Any ideas about where am I going wrong? Thanks!
Thanks!
\/{2}.*\ninstead of/\{2}.*\n?/?