On Thu, Nov 14, 2019, at 16:23, MRAB wrote:
On 2019-11-14 19:51, Andrew Barnert via Python-ideas wrote:
And that raises a point: the if keyword can appear in other places besides the start of a compound statement. Does tokenize.py have enough info to handle that properly? I don’t know, and the answer to that might be a good proxy to the question of whether it can be done in the real compiler without making parsing complicated, even if it won’t prove the answer either way.
Well, in principle, you could also allow NL within inline conditionals [i.e. in the part bracketed by if and else] as well. This probably isn't very desirable though, I was kind of assuming that the parser knew when it was at the start of a line.
Keywords (reserved words) are special everywhere except in strings and comments.
I don't think that's directly relevant to Andrew's question, it's could still be the "same kind of special", whereas the tokenizer needs to treat it differently in each context and therefore differentiate between the contexts.