[geany/geany] 5e469d: Rust: Update comment parsing.

SiegeLord git-noreply at xxxxx
Tue Jul 29 15:10:14 UTC 2014


Branch:      refs/heads/master
Author:      SiegeLord <slabode at aim.com>
Committer:   SiegeLord <slabode at aim.com>
Date:        Tue, 29 Jul 2014 15:10:14 UTC
Commit:      5e469dc5aeb1982a046703b95893dfd52e5a1174
             https://github.com/geany/geany/commit/5e469dc5aeb1982a046703b95893dfd52e5a1174

Log Message:
-----------
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).


Modified Paths:
--------------
    tagmanager/ctags/rust.c

Modified: tagmanager/ctags/rust.c
19 lines changed, 15 insertions(+), 4 deletions(-)
===================================================================
@@ -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;



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list