Branch: refs/heads/document-messages Author: Nick Treleaven nick.treleaven@btinternet.com Committer: Nick Treleaven nick.treleaven@btinternet.com Date: Fri, 08 Jun 2012 15:40:30 Commit: e44198abb2080904576f3d7a52814d3d6c737339 https://github.com/geany/geany/commit/e44198abb2080904576f3d7a52814d3d6c7373...
Log Message: ----------- Parse D functions with various attributes/storage classes
Parse @attributes, pure, nothrow. Parse return types immutable(T), shared(T), inout(T).
Modified Paths: -------------- NEWS tagmanager/c.c
Modified: NEWS 5 files changed, 3 insertions(+), 2 deletions(-) =================================================================== @@ -73,8 +73,9 @@ Geany 1.22 (unreleased) * Parse PHP functions with multiline argument list (#3037797). * Handle ``/bin/dash`` shebang (#3470986). * Update JavaScript parser from CTags. - * Parse D class, struct, interface template bodies and template - blocks; ignore 'static if' expressions. + * Parse D class/struct/interface template bodies and template + blocks; ignore 'static if' expressions; parse function + @attributes, pure/nothrow and immutable/inout/shared return types. * Fix broken tag/word autocompletion in HTML/PHP documents. * Enable &entity; completion for all XML-based filetypes.
Modified: tagmanager/c.c 58 files changed, 42 insertions(+), 16 deletions(-) =================================================================== @@ -436,7 +436,8 @@ { "import", KEYWORD_IMPORT, { 0, 0, 0, 1, 0, 0, 1 } }, { "inline", KEYWORD_INLINE, { 0, 1, 0, 0, 0, 1, 0 } }, { "in", KEYWORD_IN, { 0, 0, 0, 0, 0, 0, 1 } }, - { "inout", KEYWORD_INOUT, { 0, 0, 0, 0, 1, 0, 1 } }, + { "inout", KEYWORD_INOUT, { 0, 0, 0, 0, 1, 0, 0 } }, + { "inout", KEYWORD_CONST, { 0, 0, 0, 0, 0, 0, 1 } }, /* treat like const */ { "input", KEYWORD_INPUT, { 0, 0, 0, 0, 1, 0, 0 } }, { "int", KEYWORD_INT, { 1, 1, 1, 1, 0, 1, 1 } }, { "integer", KEYWORD_INTEGER, { 0, 0, 0, 0, 1, 0, 0 } }, @@ -1675,6 +1676,10 @@ static void skipBraces (void) static keywordId analyzeKeyword (const char *const name) { const keywordId id = (keywordId) lookupKeyword (name, getSourceLanguage ()); + + /* ignore D @attributes, but show them in function signatures */ + if (isLanguage(Lang_d) && id == KEYWORD_NONE && name[0] == '@') + return KEYWORD_CONST; return id; }
@@ -2116,6 +2121,29 @@ static void skipMacro (statementInfo *const st) skipToMatch ("()"); }
+static boolean isDPostArgumentToken(tokenInfo *const token) +{ + switch (token->keyword) + { + /* Note: some other keywords e.g. immutable are parsed as + * KEYWORD_CONST - see initializeDParser */ + case KEYWORD_CONST: + /* template constraint */ + case KEYWORD_IF: + /* contracts */ + case KEYWORD_IN: + case KEYWORD_OUT: + case KEYWORD_BODY: + return TRUE; + default: + break; + } + /* @attributes */ + if (vStringValue(token->name)[0] == '@') + return TRUE; + return FALSE; +} + /* Skips over characters following the parameter list. This will be either * non-ANSI style function declarations or C++ stuff. Our choices: * @@ -2177,21 +2205,9 @@ static boolean skipPostArgumentStuff (statementInfo *const st, if (isident1 (c)) { readIdentifier (token, c); - if (isLanguage(Lang_d)) - { - switch (token->keyword) - { - /* template constraint */ - case KEYWORD_IF: - /* contracts */ - case KEYWORD_IN: - case KEYWORD_OUT: - case KEYWORD_BODY: - token->keyword = KEYWORD_CONST; - default: - break; - } - } + if (isLanguage(Lang_d) && isDPostArgumentToken(token)) + token->keyword = KEYWORD_CONST; + switch (token->keyword) { case KEYWORD_ATTRIBUTE: skipParens (); break; @@ -3100,8 +3116,18 @@ static void initializeJavaParser (const langType language)
static void initializeDParser (const langType language) { + /* keyword aliases - some are for parsing like const(Type), some are just + * function attributes */ + char *const_aliases[] = {"immutable", "nothrow", "pure", "shared", NULL}; + char **s; + Lang_d = language; buildKeywordHash (language, 6); + + for (s = const_aliases; *s != NULL; s++) + { + addKeyword (*s, language, KEYWORD_CONST); + } }
static void initializeGLSLParser (const langType language)
@@ Diff output truncated at 100000 characters. @@
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: TBD).