3 ms·
OK, I see what you're saying, and I have to partially agree. You could say there are two parsing challenges: knowing that you are inside a declaration (as oppo
by adrianmonk 8y ago
OK, I see what you're saying, and I have to partially agree.
You could say there are two parsing challenges: knowing that you are inside a declaration (as opposed to an expression, statement, etc.), and parsing the parts of the declaration once you know you are in it.
If you have a (required) keyword like "var", then the first challenge is solved in any case. (And that is the challenge that was actually mentioned in the above comment.)
But yeah, the second challenge exists, and since variable names are exactly one token long (in any language I know of), it's easier for them to come first. Sometimes. It depends on the language, though: if the language has a separator terminal symbol ("var int : x"), then I don't see how the order matters. Some languages do and some don't.