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

Indentation is handled by the lexer, not the parser.

The parser is context free-- LL(1), actually.

The lexer maintains one extra stack to track indentations, meaning it's more of a PDA than a DFA, but the actual complication is mild.




The language is not context free, although I agree there is a parsing solution which is not terribly complex.


It is context free. INDENT and OUTDENT are directly equivalent to { and } in other grammars.


The difference is that INDENT and OUTDENT have to be defined by context-sensitive productions. Even if this occurs in what would otherwise be the "lexing" stage of the parser.




Consider applying for YC's Summer 2025 batch! Applications are open till May 13

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

Search: