[geany/geany] 1bed45: Merge pull request #270 from b4n/zephir-filetype

Colomban Wendling git-noreply at xxxxx
Wed Apr 8 23:06:57 UTC 2015


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Wed, 08 Apr 2015 23:06:57 UTC
Commit:      1bed458ab9e9c9d3d37440a8c7543c27b073e556
             https://github.com/geany/geany/commit/1bed458ab9e9c9d3d37440a8c7543c27b073e556

Log Message:
-----------
Merge pull request #270 from b4n/zephir-filetype

Zephir filetype


Modified Paths:
--------------
    data/Makefile.am
    data/filetype_extensions.conf
    data/filetypes.zephir
    scintilla/scintilla_changes.patch
    scintilla/src/Catalogue.cxx
    src/editor.c
    src/filetypes.c
    src/filetypes.h
    src/highlighting.c
    src/highlightingmappings.h
    src/symbols.c
    tagmanager/ctags/parsers.h
    tagmanager/ctags/php.c
    tagmanager/src/tm_parser.h
    tests/ctags/Makefile.am
    tests/ctags/return-hint.zep
    tests/ctags/return-hint.zep.tags
    tests/ctags/simple.zep
    tests/ctags/simple.zep.tags

Modified: data/Makefile.am
3 lines changed, 2 insertions(+), 1 deletions(-)
===================================================================
@@ -69,7 +69,8 @@ filetypes = \
 	filetypes.verilog \
 	filetypes.vhdl \
 	filetypes.xml \
-	filetypes.yaml
+	filetypes.yaml \
+	filetypes.zephir
 
 tagfiles = \
 	c99.tags \


Modified: data/filetype_extensions.conf
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -67,6 +67,7 @@ Verilog=*.v;
 VHDL=*.vhd;*.vhdl;
 XML=*.xml;*.sgml;*.xsl;*.xslt;*.xsd;*.xhtml;*.xul;*.dtd;*.xtpl;
 YAML=*.yaml;*.yml;
+Zephir=*.zep;
 None=*;
 
 # Note: restarting is required after editing groups


Modified: data/filetypes.zephir
24 lines changed, 24 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,24 @@
+# For complete documentation of this file, please see Geany's main documentation
+[styling=HTML]
+
+[keywords=HTML]
+# all items must be in one line
+# these are Zephir instructions, overriding PHP list
+php=abstract bool break case catch class const continue default empty else false fetch finally fixed float for foreach function if int integer interface isset let long namespace new null private protected public return static string switch this throw true try typeof uint ulong unlikely var void while
+
+[lexer_properties=PHP]
+
+[settings=PHP]
+# default extension used when saving files
+extension=zep
+
+[indentation]
+#width=4
+# 0 is spaces, 1 is tabs, 2 is tab & spaces
+#type=1
+
+[build_settings]
+# %f will be replaced by the complete filename
+# %e will be replaced by the filename without extension
+# (use only one of it at one time)
+compiler=zephir build


Modified: scintilla/scintilla_changes.patch
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -112,7 +112,7 @@ index 41d5d54..70ce3bc 100644
  	LINK_LEXER(lmPascal);
 -	LINK_LEXER(lmPB);
  	LINK_LEXER(lmPerl);
--	LINK_LEXER(lmPHPSCRIPT);
+ 	LINK_LEXER(lmPHPSCRIPT);
 -	LINK_LEXER(lmPLM);
  	LINK_LEXER(lmPO);
 -	LINK_LEXER(lmPOV);


Modified: scintilla/src/Catalogue.cxx
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -107,6 +107,7 @@ int Scintilla_LinkLexers() {
 	LINK_LEXER(lmOctave);
 	LINK_LEXER(lmPascal);
 	LINK_LEXER(lmPerl);
+	LINK_LEXER(lmPHPSCRIPT);
 	LINK_LEXER(lmPO);
 	LINK_LEXER(lmPowerShell);
 	LINK_LEXER(lmProps);


Modified: src/editor.c
4 lines changed, 4 insertions(+), 0 deletions(-)
===================================================================
@@ -1261,6 +1261,7 @@ static gboolean lexer_has_braces(ScintillaObject *sci)
 		case SCLEX_CPP:
 		case SCLEX_D:
 		case SCLEX_HTML:	/* for PHP & JS */
+		case SCLEX_PHPSCRIPT:
 		case SCLEX_PASCAL:	/* for multiline comments? */
 		case SCLEX_BASH:
 		case SCLEX_PERL:
@@ -2871,6 +2872,7 @@ static gint get_multiline_comment_style(GeanyEditor *editor, gint line_start)
 	{
 		case SCLEX_XML:
 		case SCLEX_HTML:
+		case SCLEX_PHPSCRIPT:
 		{
 			if (is_style_php(sci_get_style_at(editor->sci, line_start)))
 				style_comment = SCE_HPHP_COMMENT;
@@ -3408,6 +3410,7 @@ static gboolean in_block_comment(gint lexer, gint style)
 				style == SCE_D_COMMENTNESTED);
 
 		case SCLEX_HTML:
+		case SCLEX_PHPSCRIPT:
 			return (style == SCE_HPHP_COMMENT);
 
 		case SCLEX_CSS:
@@ -4956,6 +4959,7 @@ void editor_set_indentation_guides(GeanyEditor *editor)
 		/* C-like (structured) languages benefit from the "look both" method */
 		case SCLEX_CPP:
 		case SCLEX_HTML:
+		case SCLEX_PHPSCRIPT:
 		case SCLEX_XML:
 		case SCLEX_PERL:
 		case SCLEX_LATEX:


Modified: src/filetypes.c
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -192,6 +192,7 @@ static void init_builtin_filetypes(void)
 	FT_INIT( RUST,       RUST,         "Rust",             NULL,                      SOURCE_FILE, COMPILED );
 	FT_INIT( COFFEESCRIPT, NONE,       "CoffeeScript",     NULL,                      SOURCE_FILE, SCRIPT   );
 	FT_INIT( GO,         GO,           "Go",               NULL,                      SOURCE_FILE, COMPILED );
+	FT_INIT( ZEPHIR,     ZEPHIR,       "Zephir",           NULL,                      SOURCE_FILE, COMPILED );
 }
 
 


Modified: src/filetypes.h
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -102,6 +102,7 @@ typedef enum
 	GEANY_FILETYPES_RUST,
 	GEANY_FILETYPES_COFFEESCRIPT,
 	GEANY_FILETYPES_GO,
+	GEANY_FILETYPES_ZEPHIR,
 	/* ^ append items here */
 	GEANY_MAX_BUILT_IN_FILETYPES	/* Don't use this, use filetypes_array->len instead */
 }


Modified: src/highlighting.c
4 lines changed, 4 insertions(+), 0 deletions(-)
===================================================================
@@ -1046,6 +1046,7 @@ void highlighting_init_styles(guint filetype_idx, GKeyFile *config, GKeyFile *co
 		init_styleset_case(VERILOG);
 		init_styleset_case(XML);
 		init_styleset_case(YAML);
+		init_styleset_case(ZEPHIR);
 		default:
 			if (ft->lexer_filetype)
 				geany_debug("Filetype %s has a recursive lexer_filetype %s set!",
@@ -1131,6 +1132,7 @@ void highlighting_set_styles(ScintillaObject *sci, GeanyFiletype *ft)
 		styleset_case(VERILOG);
 		styleset_case(XML);
 		styleset_case(YAML);
+		styleset_case(ZEPHIR);
 		case GEANY_FILETYPES_NONE:
 		default:
 			styleset_default(sci, ft->id);
@@ -1490,6 +1492,7 @@ gboolean highlighting_is_string_style(gint lexer, gint style)
 
 		case SCLEX_XML:
 		case SCLEX_HTML:
+		case SCLEX_PHPSCRIPT:
 			return (
 				style == SCE_HBA_STRING ||
 				style == SCE_HBA_STRINGEOL ||
@@ -1674,6 +1677,7 @@ gboolean highlighting_is_comment_style(gint lexer, gint style)
 
 		case SCLEX_XML:
 		case SCLEX_HTML:
+		case SCLEX_PHPSCRIPT:
 			return (
 				style == SCE_HBA_COMMENTLINE ||
 				style == SCE_HB_COMMENTLINE ||


Modified: src/highlightingmappings.h
7 lines changed, 7 insertions(+), 0 deletions(-)
===================================================================
@@ -1611,6 +1611,13 @@ static const HLKeyword highlighting_keywords_YAML[] =
 };
 #define highlighting_properties_YAML	EMPTY_PROPERTIES
 
+
+/* Zephir */
+#define highlighting_lexer_ZEPHIR		SCLEX_PHPSCRIPT
+#define highlighting_styles_ZEPHIR		highlighting_styles_PHP
+#define highlighting_keywords_ZEPHIR	highlighting_keywords_PHP
+#define highlighting_properties_ZEPHIR	highlighting_properties_PHP
+
 G_END_DECLS
 
 #endif /* GEANY_HIGHLIGHTING_MAPPINGS_H */


Modified: src/symbols.c
2 lines changed, 2 insertions(+), 0 deletions(-)
===================================================================
@@ -302,6 +302,7 @@ const gchar *symbols_get_context_separator(gint ft_id)
 		/*case GEANY_FILETYPES_RUBY:*/ /* not sure what to use atm*/
 		case GEANY_FILETYPES_PHP:
 		case GEANY_FILETYPES_RUST:
+		case GEANY_FILETYPES_ZEPHIR:
 			return "::";
 
 		/* avoid confusion with other possible separators in group/section name */
@@ -724,6 +725,7 @@ static void add_top_level_items(GeanyDocument *doc)
 			break;
 		}
 		case GEANY_FILETYPES_PHP:
+		case GEANY_FILETYPES_ZEPHIR:
 		{
 			tag_list_add_groups(tag_store,
 				&(tv_iters.tag_namespace), _("Namespaces"), "classviewer-namespace",


Modified: tagmanager/ctags/parsers.h
3 lines changed, 2 insertions(+), 1 deletions(-)
===================================================================
@@ -64,7 +64,8 @@
     AbaqusParser, \
     RustParser, \
     GoParser, \
-    JsonParser
+    JsonParser, \
+    ZephirParser
 
 #endif	/* _PARSERS_H */
 


Modified: tagmanager/ctags/php.c
57 lines changed, 49 insertions(+), 8 deletions(-)
===================================================================
@@ -227,6 +227,7 @@ typedef struct {
 } tokenInfo;
 
 static langType Lang_php;
+static langType Lang_zephir;
 
 static boolean InPhp = FALSE; /* whether we are between <? ?> */
 
@@ -240,14 +241,14 @@ static struct {
 static vString *CurrentNamesapce;
 
 
-static void buildPhpKeywordHash (void)
+static void buildPhpKeywordHash (const langType language)
 {
 	const size_t count = sizeof (PhpKeywordTable) / sizeof (PhpKeywordTable[0]);
 	size_t i;
 	for (i = 0; i < count ; i++)
 	{
 		const keywordDesc* const p = &PhpKeywordTable[i];
-		addKeyword (p->name, Lang_php, (int) p->id);
+		addKeyword (p->name, language, (int) p->id);
 	}
 }
 
@@ -974,7 +975,7 @@ static void readToken (tokenInfo *const token)
 			else
 			{
 				parseIdentifier (token->string, c);
-				token->keyword = analyzeToken (token->string, Lang_php);
+				token->keyword = analyzeToken (token->string, getSourceLanguage ());
 				if (token->keyword == KEYWORD_NONE)
 					token->type = TOKEN_IDENTIFIER;
 				else
@@ -1180,6 +1181,17 @@ static boolean parseFunction (tokenInfo *const token, const tokenInfo *name)
 		readToken (token); /* normally it's an open brace or "use" keyword */
 	}
 
+	/* if parsing Zephir, skip function return type hint */
+	if (getSourceLanguage () == Lang_zephir && token->type == TOKEN_OPERATOR)
+	{
+		do
+			readToken (token);
+		while (token->type != TOKEN_EOF &&
+			   token->type != TOKEN_OPEN_CURLY &&
+			   token->type != TOKEN_CLOSE_CURLY &&
+			   token->type != TOKEN_SEMICOLON);
+	}
+
 	/* skip use(...) */
 	if (token->type == TOKEN_KEYWORD && token->keyword == KEYWORD_use)
 	{
@@ -1435,11 +1447,10 @@ static void enterScope (tokenInfo *const parentToken,
 	deleteToken (token);
 }
 
-static void findPhpTags (void)
+static void findTags (void)
 {
 	tokenInfo *const token = newToken ();
 
-	InPhp = FALSE;
 	CurrentStatement.access = ACCESS_UNDEFINED;
 	CurrentStatement.impl = IMPL_UNDEFINED;
 	CurrentNamesapce = vStringNew ();
@@ -1454,10 +1465,28 @@ static void findPhpTags (void)
 	deleteToken (token);
 }
 
-static void initialize (const langType language)
+static void findPhpTags (void)
+{
+	InPhp = FALSE;
+	findTags ();
+}
+
+static void findZephirTags (void)
+{
+	InPhp = TRUE;
+	findTags ();
+}
+
+static void initializePhpParser (const langType language)
 {
 	Lang_php = language;
-	buildPhpKeywordHash ();
+	buildPhpKeywordHash (language);
+}
+
+static void initializeZephirParser (const langType language)
+{
+	Lang_zephir = language;
+	buildPhpKeywordHash (language);
 }
 
 extern parserDefinition* PhpParser (void)
@@ -1468,7 +1497,19 @@ extern parserDefinition* PhpParser (void)
 	def->kindCount  = KIND_COUNT (PhpKinds);
 	def->extensions = extensions;
 	def->parser     = findPhpTags;
-	def->initialize = initialize;
+	def->initialize = initializePhpParser;
+	return def;
+}
+
+extern parserDefinition* ZephirParser (void)
+{
+	static const char *const extensions [] = { "zep", NULL };
+	parserDefinition* def = parserNew ("Zephir");
+	def->kinds      = PhpKinds;
+	def->kindCount  = KIND_COUNT (PhpKinds);
+	def->extensions = extensions;
+	def->parser     = findZephirTags;
+	def->initialize = initializeZephirParser;
 	return def;
 }
 


Modified: tagmanager/src/tm_parser.h
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -71,6 +71,7 @@ typedef enum
 	TM_PARSER_RUST,
 	TM_PARSER_GO,
 	TM_PARSER_JSON,
+	TM_PARSER_ZEPHIR,
 	TM_PARSER_COUNT
 } TMParserType;
 


Modified: tests/ctags/Makefile.am
2 lines changed, 2 insertions(+), 0 deletions(-)
===================================================================
@@ -237,6 +237,7 @@ test_sources = \
 	recursive.f95					\
 	refcurs.sql						\
 	regexp.js						\
+	return-hint.zep					\
 	rules.t2t						\
 	sample.t2t						\
 	secondary_fcn_name.js			\
@@ -258,6 +259,7 @@ test_sources = \
 	simple.rb						\
 	simple.sh						\
 	simple.tcl						\
+	simple.zep						\
 	size_t_wchar_t_alias.d			\
 	size_t_wchar_t_typedef.c		\
 	spurious_label_tags.c			\


Modified: tests/ctags/return-hint.zep
14 lines changed, 14 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,14 @@
+class Test
+{
+    public function first(string str) -> string
+    {
+        function nested() {
+            
+        }
+    }
+    
+    public function second(int i) -> int
+    {
+        
+    }
+}


Modified: tests/ctags/return-hint.zep.tags
5 lines changed, 5 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,5 @@
+# format=tagmanager
+Test�1�0
+first�16�(string str)�Test�0
+nested�16�()�Test::first�0
+second�16�(int i)�Test�0


Modified: tests/ctags/simple.zep
19 lines changed, 19 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,19 @@
+/* from http://zephir-lang.com/language.html */
+namespace Test;
+
+class MyClass
+{
+
+    public function someMethod1()
+    {
+        int a = 1, b = 2;
+        return a + b;
+    }
+
+    public function someMethod2()
+    {
+        int a = 3, b = 4;
+        return a + b;
+    }
+
+}


Modified: tests/ctags/simple.zep.tags
5 lines changed, 5 insertions(+), 0 deletions(-)
===================================================================
@@ -0,0 +1,5 @@
+# format=tagmanager
+MyClass�1�Test�0
+Test�256�0
+someMethod1�16�()�Test::MyClass�0
+someMethod2�16�()�Test::MyClass�0



--------------
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