Answer the question
In order to leave comments, you need to log in
Tab algorithm from python?
I'm writing my own lexical analyzer and I need a tab detection algorithm like from python.
In python.
I already made 3 prototypes:
Just with tab count:
def GetTabs(code):
index = 0
for char in code:
if char == '\t': index+=1
else: return index
def GetTabs(code):
index = 0
SpaceCount = 1
for char in code:
if not char.isspace(): return index
if char == '\t': index+=1
else:
if SpaceCount == 4:
index+=1
SpaceCount = 1
elif char == " ":
SpaceCount+=1
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question