D_Parser
D_Parser copied to clipboard
Bad Parsing Error Recovery in Enums
trafficstars
Within an enum, if you attempt to start a member with a number, rather than a letter, producing a <Literal> token, the error recovery is not exactly pretty, especially if done within a method body.
Rather than whatever is currently done, we should be discarding all following tokens until we hit either an =, <Identifier>, ,, or }, and continue parsing as normal depending on which token is found. An <Identifier> immediately following an unexpected <Literal> token should produce an error for both tokens saying that an enum's member is not allowed to start with a number, and then parsing should continue as if only the <Identifier> token was found.