-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not output invalid UTF-8 for some lexer errors
- Loading branch information
Showing
1 changed file
with
11 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -393,9 +393,19 @@ SESCAPE : esc='\\' ('\\' | '"' | '\'' | '?' | 'a' | 'b' | 'f' | 'n' | 'r' | 't' | |
char chars[2] = {LA(1),'\0'}; | ||
const char *str = chars; | ||
int len = strlen((char*)$text->chars); | ||
c_add_source_message(NULL,2, ErrorType_syntax, ErrorLevel_warning, "Lexer treating \\ as \\\\, since \\\%s is not a valid Modelica escape sequence.", | ||
if ((chars[0] & 0xE0) == 0xD0) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
hkiel
Member
|
||
c_add_source_message(NULL,2, ErrorType_syntax, ErrorLevel_warning, "Lexer treating \\ as \\\\, since the next byte is the start of a UTF-8 character and thus not a valid Modelica escape sequence.", | ||
&str, 0, $line, $pos+1, $line, $pos+len+1, | ||
ModelicaParser_readonly, ModelicaParser_filename_C_testsuiteFriendly); | ||
} else if ((chars[0] & 0x80)) { | ||
c_add_source_message(NULL,2, ErrorType_syntax, ErrorLevel_warning, "Lexer treating \\ as \\\\, since the next byte is an invalid UTF-8 character and thus not a valid Modelica escape sequence.", | ||
&str, 0, $line, $pos+1, $line, $pos+len+1, | ||
ModelicaParser_readonly, ModelicaParser_filename_C_testsuiteFriendly); | ||
} else { | ||
c_add_source_message(NULL,2, ErrorType_syntax, ErrorLevel_warning, "Lexer treating \\ as \\\\, since \\\%s is not a valid Modelica escape sequence.", | ||
&str, 1, $line, $pos+1, $line, $pos+len+1, | ||
ModelicaParser_readonly, ModelicaParser_filename_C_testsuiteFriendly); | ||
} | ||
}); | ||
|
||
fragment | ||
|
@sjoelund This bitwise arithmetic always evaluates to false. Can you fix that please?