Branch: refs/heads/master Author: SiegeLord slabode@aim.com Committer: SiegeLord slabode@aim.com Date: Tue, 29 Jul 2014 14:51:36 UTC Commit: 756344d901afba9e5a51ae099aa7c1fe9ecef019 https://github.com/geany/geany/commit/756344d901afba9e5a51ae099aa7c1fe9ecef0...
Log Message: ----------- Rust: Parse character literals.
These were omitted by mistake. Caused bugs like '"' being interpreted as a start/end of a string, '}' as the end of a block etc.
Modified Paths: -------------- tagmanager/ctags/rust.c
Modified: tagmanager/ctags/rust.c 40 lines changed, 40 insertions(+), 0 deletions(-) =================================================================== @@ -292,6 +292,41 @@ static void scanRawString (lexerState *lexer) } }
+/* This deals with character literals: 'n', '\n', '\uFFFF'; and lifetimes: + * 'lifetime. We'll use this approximate regexp for the literals: + * ' \ [^']+ ' or ' [^'] ' or ' \ ' '. Either way, we'll treat this + * token as a string, so it gets preserved as is for function signatures with + * lifetimes. */ +static void scanCharacterOrLifetime (lexerState *lexer) +{ + vStringClear(lexer->token_str); + advanceAndStoreChar(lexer); + + if (lexer->cur_c == '\') + { + advanceAndStoreChar(lexer); + /* The ' \ ' ' (literally ''') case */ + if (lexer->cur_c == ''' && lexer->next_c == ''') + { + advanceAndStoreChar(lexer); + advanceAndStoreChar(lexer); + } + /* The ' \ [^']+ ' case */ + else + { + while (lexer->cur_c != EOF && lexer->cur_c != ''') + advanceAndStoreChar(lexer); + } + } + /* The ' [^'] ' case */ + else if (lexer->cur_c != ''' && lexer->next_c == ''') + { + advanceAndStoreChar(lexer); + advanceAndStoreChar(lexer); + } + /* Otherwise it is malformed, or a lifetime */ +} + /* Advances the parser one token, optionally skipping whitespace * (otherwise it is concatenated and returned as a single whitespace token). * Whitespace is needed to properly render function signatures. Unrecognized @@ -334,6 +369,11 @@ static int advanceToken (lexerState *lexer, boolean skip_whitspace) scanRawString(lexer); return lexer->cur_token = TOKEN_STRING; } + else if (lexer->cur_c == ''') + { + scanCharacterOrLifetime(lexer); + return lexer->cur_token = TOKEN_STRING; + } else if (isIdentifierStart(lexer->cur_c)) { scanIdentifier(lexer);
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).