On Wednesday, 15 June 2016 at 04:25:15 UTC, deadalnix wrote:
there is nothing in that example that is especially difficult for a machine to muddle through.
Nested comments, have to keep track of nesting depth specifically for those. Single line comments, which give newline two totally different semantics based on context, that the parser has to account for. Comments can go absolutely anywhere, so you can never advance by simply incrementing your character pointer, regardless of the statement you're parsing. You have to do a complex test for the presence of comments and pass over them, and if you want to do any backtracking, you have to be able to skip backwards over them.
Type definitions can have parentheses in them, so the parser can't search for '(' either forwards or backwards in order to find the beginning of a function definition. It has to analyze each parenthetical grouping in its own special context, taking into account all the possible keywords, special phrases like extern, properties, and template arguments, both for parameters and return values.
And that's just to parse function declarations!
