Currently when a keyword like interface are misspelled, the error is difficult to connect to a typo:
Error: A type name was expected, but this looks a variable or function name (as it doesn't start with an uppercase letter).
This error message can be replaced by contextually checking if the token is close (see edit distance) to a keyword.
in the case of keywords used for top level statement, since IDENT tokens cannot be used in global variable declarations, (as builtin types like int are keywords and custom types are IDENT_TYPE) when encountering an IDENT token in parse_top_level_statement, before calling parse_global_declaration, we can first go through the keywords we could expect and calculating the edit distance to the value and showing a message which explicitly suggests a typo.
Currently when a keyword like
interfaceare misspelled, the error is difficult to connect to a typo:This error message can be replaced by contextually checking if the token is close (see edit distance) to a keyword.
in the case of keywords used for top level statement, since
IDENTtokens cannot be used in global variable declarations, (as builtin types likeintare keywords and custom types areIDENT_TYPE) when encountering anIDENTtoken inparse_top_level_statement, before callingparse_global_declaration, we can first go through the keywords we could expect and calculating the edit distance to the value and showing a message which explicitly suggests a typo.