[geany/geany] 33c84f: PHP: parse traits
Colomban Wendling
git-noreply at xxxxx
Wed Jul 3 17:42:14 UTC 2013
Branch: refs/heads/master
Author: Colomban Wendling <ban at herbesfolles.org>
Committer: Colomban Wendling <ban at herbesfolles.org>
Date: Mon, 15 Apr 2013 17:17:57 UTC
Commit: 33c84f739db61e12ee8638e75e386db2b8b2480f
https://github.com/geany/geany/commit/33c84f739db61e12ee8638e75e386db2b8b2480f
Log Message:
-----------
PHP: parse traits
http://www.php.net/manual/en/language.oop5.traits.php
Modified Paths:
--------------
tagmanager/ctags/php.c
Modified: tagmanager/ctags/php.c
30 files changed, 30 insertions(+), 0 deletions(-)
===================================================================
@@ -105,6 +105,7 @@
K_INTERFACE,
K_LOCAL_VARIABLE,
K_NAMESPACE,
+ K_TRAIT,
K_VARIABLE,
COUNT_KIND
} phpKind;
@@ -116,6 +117,7 @@
{ TRUE, 'i', "interface", "interfaces" },
{ FALSE, 'l', "local", "local variables" },
{ TRUE, 'n', "namespace", "namespaces" },
+ { TRUE, 't', "trait", "traits" },
{ TRUE, 'v', "variable", "variables" }
};
@@ -957,6 +959,33 @@ static boolean parseClassOrIface (tokenInfo *const token, const phpKind kind)
return readNext;
}
+/* parses a trait:
+ * trait Foo {} */
+static boolean parseTrait (tokenInfo *const token)
+{
+ boolean readNext = TRUE;
+ tokenInfo *name;
+
+ readToken (token);
+ if (token->type != TOKEN_IDENTIFIER)
+ return FALSE;
+
+ name = newToken ();
+ copyToken (name, token, TRUE);
+
+ makeSimplePhpTag (name, K_TRAIT, ACCESS_UNDEFINED);
+
+ readToken (token);
+ if (token->type == TOKEN_OPEN_CURLY)
+ enterScope (token, name->string, K_TRAIT);
+ else
+ readNext = FALSE;
+
+ deleteToken (name);
+
+ return readNext;
+}
+
/* parse a function
*
* if @name is NULL, parses a normal function
@@ -1253,6 +1282,7 @@ static void enterScope (tokenInfo *const parentToken,
{
case KEYWORD_class: readNext = parseClassOrIface (token, K_CLASS); break;
case KEYWORD_interface: readNext = parseClassOrIface (token, K_INTERFACE); break;
+ case KEYWORD_trait: readNext = parseTrait (token); break;
case KEYWORD_function: readNext = parseFunction (token, NULL); break;
case KEYWORD_const: readNext = parseConstant (token); break;
case KEYWORD_define: readNext = parseDefine (token); break;
--------------
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