diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c52ca03c..ca2e78304 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `add` is no longer colorized as a keyword in the SonarQube web interface. - `remove` is no longer colorized as a keyword in the SonarQube web interface. - `variant` is no longer colorized as a keyword in the SonarQube web interface. +- Parsing errors on unusual whitespace characters. ## [0.40.0] - 2023-01-10 diff --git a/delphi-frontend/src/main/antlr3/au/com/integradev/delphi/antlr/Delphi.g b/delphi-frontend/src/main/antlr3/au/com/integradev/delphi/antlr/Delphi.g index 731cb86f8..0615b8a8d 100644 --- a/delphi-frontend/src/main/antlr3/au/com/integradev/delphi/antlr/Delphi.g +++ b/delphi-frontend/src/main/antlr3/au/com/integradev/delphi/antlr/Delphi.g @@ -1276,7 +1276,7 @@ COMMENT : '//' ~('\n'|'\r')* {$channel } } ; -WHITESPACE : (' '|'\t'|'\r'|'\n'|'\f')+ {$channel=HIDDEN;} +WHITESPACE : ('\u0000'..'\u0020' | '\u3000')+ {$channel=HIDDEN;} ; UnicodeBOM : '\uFEFF' {$channel=HIDDEN;} ; diff --git a/delphi-frontend/src/test/java/au/com/integradev/delphi/antlr/GrammarTest.java b/delphi-frontend/src/test/java/au/com/integradev/delphi/antlr/GrammarTest.java index b263814ac..b984f1927 100644 --- a/delphi-frontend/src/test/java/au/com/integradev/delphi/antlr/GrammarTest.java +++ b/delphi-frontend/src/test/java/au/com/integradev/delphi/antlr/GrammarTest.java @@ -237,4 +237,9 @@ void testEmptyFileShouldThrow() { DelphiFileUtils.mockConfig())) .isInstanceOf(DelphiFileConstructionException.class); } + + @Test + void testUnusualWhitespace() { + parseFile("UnusualWhitespace.pas"); + } } diff --git a/delphi-frontend/src/test/resources/au/com/integradev/delphi/grammar/UnusualWhitespace.pas b/delphi-frontend/src/test/resources/au/com/integradev/delphi/grammar/UnusualWhitespace.pas new file mode 100644 index 000000000..3b4bad238 Binary files /dev/null and b/delphi-frontend/src/test/resources/au/com/integradev/delphi/grammar/UnusualWhitespace.pas differ