Hacker News new | past | comments | ask | show | jobs | submit login

I don't think that's true - \t happens at the beginning of every line in a block, often more than once, whereas BLOCK_STARTS and BLOCK_ENDS tokens are pretty easy to track with a stack or whathaveyou.



Of course you'll check the context too. But the same is also true for "{" occurs in many places with different meaning -- in struts, inside text strings, in interfaces (in Go), etc.

Besides it's not the \t that you need to find as a marker for e.g. scope start. Python has "def xxx():" for example, so you see that and you know you're in a function declaration scope, same way function (xxx) { in C works.

After you see that you only need to keep track of \t or " " in the beginning of lines (before any other character) to know whether you're still in the same scope or not. That's why you can't just have arbitrary whitespace count in Python lines, but you need to maintain the same "indent" in the same scope.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: