Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improvement]: Combine redundant compiler diagnostic error codes #42202

Open
RadCod3 opened this issue Feb 21, 2024 · 0 comments
Open

[Improvement]: Combine redundant compiler diagnostic error codes #42202

RadCod3 opened this issue Feb 21, 2024 · 0 comments
Labels
Area/Diagnostics Issues related Diagnostics reported by the Compiler. #Compiler Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Improvement

Comments

@RadCod3
Copy link

RadCod3 commented Feb 21, 2024

Description

Currently error codes that represent missing tokens and keywords have separate error codes for every single token and keyword. All of these follow a simple pattern that can be represented by a few generic messages instead.
Eg. missing $MISSING_TOKEN token or missing $MISSING_KEYWORD keyword.

Describe your problem(s)

No response

Describe your solution(s)

Current approach is as below,

DiagnosticErrorCode.java

ERROR_MISSING_SEMICOLON_TOKEN("BCE0002", "error.missing.semicolon.token"),
ERROR_MISSING_COLON_TOKEN("BCE0003", "error.missing.colon.token"),
ERROR_MISSING_OPEN_PAREN_TOKEN("BCE0004", "error.missing.open.paren.token"),
...
ERROR_MISSING_PARAMETER_KEYWORD("BCE0210", "error.missing.parameter.keyword"),
ERROR_MISSING_RETURNS_KEYWORD("BCE0211", "error.missing.returns.keyword"),
ERROR_MISSING_RETURN_KEYWORD("BCE0212", "error.missing.return.keyword"),

syntax_diagnostic_message.properties

error.missing.semicolon.token=missing semicolon token
error.missing.colon.token=missing colon token
error.missing.open.paren.token=missing open parenthesis token
...
error.missing.parameter.keyword=missing parameter keyword
error.missing.returns.keyword=missing returns keyword
error.missing.return.keyword=missing return keyword

These can instead be replaced with something like,

ERROR_MISSING_TOKEN("BCE0001", "error.missing.token"),
ERROR_MISSING_KEYWORD("BCE0200", "error.missing.keyword"),

and

error.missing.token=missing ''{0}'' token
error.missing.keyword=missing ''{0}'' keyword

This is the approach used for invalid tokens where BCE0600 represents all invalid tokens and uses the generic message invalid token ''{0}'' for representing the error message.

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@RadCod3 RadCod3 added Type/Improvement Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Area/Diagnostics Issues related Diagnostics reported by the Compiler. #Compiler labels Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/Diagnostics Issues related Diagnostics reported by the Compiler. #Compiler Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Improvement
Projects
None yet
Development

No branches or pull requests

1 participant