Kaydet (Commit) 5e469dc5 authored tarafından SiegeLord's avatar SiegeLord

Rust: Update comment parsing.

Rust now allows CRLF line endings in source files, which doesn't actually
change any lexing here but the comment was wrong.

Also, the hashbang initial comment has a special case where #![ doesn't count
as a comment (but instead an inner attribute that just happens to be on the
first line).
üst cf9385c6
......@@ -188,19 +188,30 @@ static void scanWhitespace (lexerState *lexer)
}
/* Normal line comments start with two /'s and continue until the next \n
* (NOT any other newline character!). Additionally, a shebang in the beginning
* of the file also counts as a line comment.
* (potentially after a \r). Additionally, a shebang in the beginning of the
* file also counts as a line comment as long as it is not this sequence: #![ .
* Block comments start with / followed by a * and end with a * followed by a /.
* Unlike in C/C++ they nest. */
static void scanComments (lexerState *lexer)
{
/* // or #! */
if (lexer->next_c == '/' || lexer->next_c == '!')
/* // */
if (lexer->next_c == '/')
{
advanceNChar(lexer, 2);
while (lexer->cur_c != EOF && lexer->cur_c != '\n')
advanceChar(lexer);
}
/* #! */
else if (lexer->next_c == '!')
{
advanceNChar(lexer, 2);
/* If it is exactly #![ then it is not a comment, but an attribute */
if (lexer->cur_c == '[')
return;
while (lexer->cur_c != EOF && lexer->cur_c != '\n')
advanceChar(lexer);
}
/* block comment */
else if (lexer->next_c == '*')
{
int level = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment