editors

changeset 43:1bb7df51432a

add callback regex parser, improve readme
collect namespace, define words
author ne1uno <ne1uno@users.sourceforge.net>
date Wed Nov 30 13:12:19 2011 -0400 (2011-11-30)
parents 3d5955166bdf
children c2af9b14fdd7
files ctags/ReadMe.txt ctags/callback-regex-euphoria.c ctags/ctags-sample ctags/ctags_euphoria_test.e ctags/euphoria.c ctags/simple-regex-euphoria.c
line diff
     1.1 --- a/ctags/ReadMe.txt	Tue Nov 29 05:54:05 2011 -0400
     1.2 +++ b/ctags/ReadMe.txt	Wed Nov 30 13:12:19 2011 -0400
     1.3 @@ -1,12 +1,83 @@
     1.4 -get ctags source or binary from 
     1.5 +get ctags source or binary & source from 
     1.6  from http://ctags.sourceforge.net
     1.7 +or from their svn repo or an archive of the repo trunk
     1.8 +http://ctags.svn.sourceforge.net/viewvc/ctags/trunk/?view=tar
     1.9 +
    1.10  
    1.11  currently late 2011 you have to compile ctags to get euphoria language
    1.12 -add euphoria.c to the ctags source directory
    1.13 +
    1.14 +there are two regex parsers, simple and callback
    1.15 +copy one of the euphoria.c parsers 
    1.16 +to euphoria.c in the ctags source directory
    1.17 +
    1.18  replace eiffel language in parsers.h 
    1.19 -and in source.mak 2 places
    1.20 +and in source.mak 2 places with euphoria
    1.21  
    1.22 -ran ctags. on ctags_euphoria_test.e and euphoria.e
    1.23 +build ctags executable using one of the makefiles.
    1.24 +install or copy the executable to your path
    1.25 +or you can run from the build directory to test
    1.26 +ctags --languages
    1.27 +
    1.28 +ran 
    1.29 +path\ctags.exe -f ctags --recurse=yes --exclude="*.b*" --fields=+a+S+n -V * 
    1.30 +on ctags_euphoria_test.e and euphoria.e
    1.31  to generate ctags-sample
    1.32  
    1.33 +Note: 
    1.34 +	the memtype, memstruct, memunion keywords are from the 
    1.35 +	euphoria 4.1 struct branch and not yet official. the 
    1.36 +	extra parsing will have little to no impact for most projects.
    1.37 +	it would not be too complicated to remove those lines from
    1.38 +	euphoria.c if you find you need the extra speed advantage.
    1.39  
    1.40 +by default the callback euphoria parser collects these kinds of items
    1.41 +
    1.42 +n namespace  both namespace x and include x as y
    1.43 +i ifdef, elsifdef, with/out define words
    1.44 +m memtype
    1.45 +s memstruct
    1.46 +u memunion
    1.47 +c constant
    1.48 +t type
    1.49 +p procedure
    1.50 +f function
    1.51 +
    1.52 +the simple parser collects these kinds only
    1.53 + and may miss some declarations the callback would catch
    1.54 +
    1.55 +m memtype
    1.56 +s memstruct
    1.57 +u memunion
    1.58 +c constant
    1.59 +t type
    1.60 +p procedure
    1.61 +f function
    1.62 +
    1.63 +to limit the kinds, use commandline something like
    1.64 + --euphoria-kinds=+p-c for only procedures no constants
    1.65 + not sure why you need -c if +p means only procedures though.
    1.66 +
    1.67 +these options might be changed by default in some ctag parsers
    1.68 +
    1.69 +neither parser currently can collect more than the first on the
    1.70 +same line as the constant, type, function or procedure declaration 
    1.71 + in a multiline lists of parameters or constants
    1.72 +
    1.73 +public constant x = 0,
    1.74 +  y = 1
    1.75 +-- y is ignored by ctags
    1.76 +
    1.77 +function xyz(atom a,
    1.78 +			atom b)
    1.79 +--b is ignored by ctags 
    1.80 +
    1.81 +
    1.82 +neither euphoria parser really understands euphoria syntax, but, 
    1.83 +running ctags over bad syntax code may cause unpredictable results.
    1.84 +ctags itself is pretty robust and should be fine in any case.
    1.85 +
    1.86 +eui -STRICT -TEST prog is one way to check syntax
    1.87 +
    1.88 +
    1.89 +please report any bugs or add a feature request for improvements,
    1.90 +including sample code if applicable.
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/ctags/callback-regex-euphoria.c	Wed Nov 30 13:12:19 2011 -0400
     2.3 @@ -0,0 +1,221 @@
     2.4 +/*
     2.5 +*   $Id$
     2.6 +*
     2.7 +*   Copyright (c) 2008 by Jeremy Cowgar
     2.8 +*
     2.9 +*   This source code is released for free distribution under the terms of the
    2.10 +*   GNU General Public License.
    2.11 +*
    2.12 +*   This module contains functions for generating tags for Euphoria routines.
    2.13 +*   http://openeuphoria.org/
    2.14 +*
    2.15 +*   m11B28p05:33 ne1 add |public|override.  (mem)*type, constant
    2.16 +*   	it's not ignoring function def inside multiline comments?
    2.17 +*   	will not collect items from a list
    2.18 +*   	multiline function sig is not collected
    2.19 +*   	everything after mem* or constant is captured
    2.20 +*   	next version should be full parser.
    2.21 +*  	t11B29p02:00 can callback regex handle multiline?
    2.22 +*  		this may still fail for public\nitem(\n) to get function sig
    2.23 +*  		really not much different than the simple parser so far
    2.24 +*  		added collect namespace & ifdef, elsifdef, define words
    2.25 +*  		may want to get define but not ifdef/elsifdef?
    2.26 +*  		output a little weird for the include lines and slashes
    2.27 +*  		tag parser still needs to be implemented
    2.28 +*/
    2.29 +
    2.30 +/*
    2.31 +*   INCLUDE FILES
    2.32 +*/
    2.33 +
    2.34 +#include "general.h"    /* always include first */
    2.35 +#include "parse.h"      /* always include */
    2.36 +#include "read.h"
    2.37 +#include "vstring.h"
    2.38 +
    2.39 +/* DATA DEFINITIONS */
    2.40 +
    2.41 +
    2.42 +static kindOption EuphoriaKinds [] = {
    2.43 +	{ TRUE, 'n', "namespace", " xnamespace" },
    2.44 +	{ TRUE, 'm', "memtype", " xmemtype" },
    2.45 +	{ TRUE, 's', "memstruct", " xmemstruct" },
    2.46 +	{ TRUE, 'u', "memunion", " xmemunion" },
    2.47 +	{ TRUE, 'c', "constant", " xconstant" },
    2.48 +	{ TRUE, 't', "type", " xtype" },
    2.49 +	{ TRUE, 'f', "function", " xfunction" },
    2.50 +	{ TRUE, 'p', "procedure", " xprocedure" },
    2.51 +	{ TRUE, 'i', "ifelsedefs", " xifelsedefs" }
    2.52 +};
    2.53 +
    2.54 +typedef enum {
    2.55 +	knamespace=0,
    2.56 +	kmemtype,
    2.57 +	kmemstruct,
    2.58 +	kmemunion,
    2.59 +	kconstant,
    2.60 +	ktype,
    2.61 +	kfunction,
    2.62 +	kprocedure,
    2.63 +	kifelsedef
    2.64 + } EuphoriaKind;
    2.65 +/* FUNCTION DEFINITIONS */
    2.66 +
    2.67 +static void defMemType (const char *const line, const regexMatch *const matches,
    2.68 +						const unsigned int count)
    2.69 +{
    2.70 +	if (count > 2)    /* should always be true per regex */
    2.71 +	{
    2.72 +		vString *const name = vStringNew ();
    2.73 +		vStringNCopyS (name, line + matches [3].start, matches [3].length);
    2.74 +		makeSimpleTag (name, EuphoriaKinds, kmemtype);
    2.75 +	}
    2.76 +}
    2.77 +
    2.78 +
    2.79 +static void defMemStruct (const char *const line, const regexMatch *const matches,
    2.80 +						const unsigned int count)
    2.81 +{
    2.82 +	if (count > 2)    /* should always be true per regex */
    2.83 +	{
    2.84 +		vString *const name = vStringNew ();
    2.85 +		vStringNCopyS (name, line + matches [3].start, matches [3].length);
    2.86 +
    2.87 +		//chk is struct/union
    2.88 +		if ( *(line + matches [2].start) == 'u'){
    2.89 +			makeSimpleTag (name, EuphoriaKinds, kmemunion);
    2.90 +		} else {
    2.91 +			makeSimpleTag (name, EuphoriaKinds, kmemstruct);
    2.92 +		}
    2.93 +	}
    2.94 +}
    2.95 +
    2.96 +
    2.97 +static void defFunDef (const char *const line, const regexMatch *const matches,
    2.98 +						const unsigned int count)
    2.99 +{
   2.100 +	if (count > 2)    /* should always be true per regex */
   2.101 +	{
   2.102 +		vString *const name = vStringNew ();
   2.103 +		vStringNCopyS (name, line + matches [3].start, matches [3].length);
   2.104 +		//chk is fun/pro
   2.105 +		if ( *(line + matches [2].start) == 'f'){
   2.106 +			makeSimpleTag (name, EuphoriaKinds, kfunction);
   2.107 +		} else {
   2.108 +			makeSimpleTag (name, EuphoriaKinds, kprocedure);
   2.109 +		}
   2.110 +	}
   2.111 +}
   2.112 +
   2.113 +static void defType (const char *const line, const regexMatch *const matches,
   2.114 +						const unsigned int count)
   2.115 +{
   2.116 +	if (count > 1)    /* should always be true per regex */
   2.117 +	{
   2.118 +		vString *const name = vStringNew ();
   2.119 +		vStringNCopyS (name, line + matches [2].start, matches [2].length);
   2.120 +		makeSimpleTag (name, EuphoriaKinds, ktype);
   2.121 +	}
   2.122 +}
   2.123 +
   2.124 +
   2.125 +static void defConst (const char *const line, const regexMatch *const matches,
   2.126 +						const unsigned int count)
   2.127 +{
   2.128 +	if (count > 1)    /* should always be true per regex */
   2.129 +	{
   2.130 +		vString *const name = vStringNew ();
   2.131 +		vStringNCopyS (name, line + matches [2].start, matches [2].length);
   2.132 +		makeSimpleTag (name, EuphoriaKinds, kconstant);
   2.133 +	}
   2.134 +}
   2.135 +
   2.136 +
   2.137 +static void deIfDef (const char *const line, const regexMatch *const matches,
   2.138 +						const unsigned int count)
   2.139 +{
   2.140 +	if (count > 1)    /* should always be true per regex */
   2.141 +	{
   2.142 +		vString *const name = vStringNew ();
   2.143 +		//later may want to distinguish ifdef,elsifdef, with/out  define 
   2.144 +		vStringNCopyS (name, line + matches [count-1].start, matches [count-1].length);
   2.145 +		makeSimpleTag (name, EuphoriaKinds, kifelsedef);
   2.146 +	}
   2.147 +}
   2.148 +
   2.149 +
   2.150 +static void defNS (const char *const line, const regexMatch *const matches,
   2.151 +						const unsigned int count)
   2.152 +{
   2.153 +	if (count > 1 )    /* should always be true per regex */
   2.154 +	{
   2.155 +		vString *const name = vStringNew ();
   2.156 +		//this will need work to distinguish namespace x from as x
   2.157 +		//namespace x should be count=4, 
   2.158 +		//y as x should be x=count=$
   2.159 +		// include y as x should be x=$
   2.160 +		vStringNCopyS (name, line + matches [count-1].start, matches [count-1].length);
   2.161 +		makeSimpleTag (name, EuphoriaKinds, knamespace);
   2.162 +	}
   2.163 +}
   2.164 +
   2.165 +static void findEuphoriaTags (void)
   2.166 +{
   2.167 +	while (fileReadLine () != NULL)
   2.168 +		;  /* don't need to do anything here since callback is sufficient */
   2.169 +}
   2.170 +
   2.171 +
   2.172 +/* FUNCTION DEFINITIONS */
   2.173 +
   2.174 +static void installEuphoriaRegex (const langType language)
   2.175 +{
   2.176 +	//is there any sense to rearranging these for most frequent hit order?
   2.177 +	//symbol names can't actually start with numbers, but we let it slide.
   2.178 +
   2.179 +	addCallbackRegex (language,
   2.180 +			"^[ \t\n]*(global|export|public|override)*[ \t\n]*(procedure|function)+[ \t\n]+([a-zA-Z0-9_]+)",
   2.181 +				NULL, defFunDef);
   2.182 +	addCallbackRegex (language,
   2.183 +			"^[ \t\n]*(global|export|public|override)*[ \t\n]*type[ \t\n]+([a-zA-Z0-9_]+)",
   2.184 +				NULL, defType);
   2.185 +
   2.186 +	//will miss some, regx parser can't collect from list
   2.187 +	addCallbackRegex (language,
   2.188 +			"^[ \t\n]*(global|export|public|override)*[ \t\n]*constant[ \t\n,]+([a-zA-Z0-9_]+)",
   2.189 +					NULL, defConst);
   2.190 +
   2.191 +	//memstruct/union/type currently in a branch. 
   2.192 +	// this won't affect parsing std euphoria
   2.193 +	addCallbackRegex (language,
   2.194 +			"^[ \t\n]*(global|export|public|override)*[ \t\n]*mem(struct|union)+[ \t\n]+([a-zA-Z0-9_]+)",
   2.195 +					NULL, defMemStruct);
   2.196 +
   2.197 +	//memtype might be a list and it would only get the first one
   2.198 +	addCallbackRegex (language,
   2.199 +			"^[ \t\n]*(global|export|public|override)*[ \t\n]*memtype[ \t\n]+([a-zA-Z0-9_]+)[ \t\n]+as[ \t\n]+([a-zA-Z0-9_]+)",
   2.200 +					NULL, defMemType);
   2.201 +
   2.202 +	//namespace x vrs include y as x
   2.203 +	//could miss some hypothetical namespace called aswhatever?
   2.204 +	addCallbackRegex (language,
   2.205 +			"^[ \t\n]*(public)*[ \t\n]*(include|namespace)+[ \t\n]+([a-zA-Z0-9\\/~#:\"._-]+)[ \t\n]*(as)*[ \t\n]*([a-zA-Z0-9_]*)",
   2.206 +					NULL, defNS);
   2.207 +
   2.208 +	addCallbackRegex (language,
   2.209 +			"^[ \t\n]*(ifdef|elsifdef|with|without)+[ \t\n]+(not|define)*[ \t\n]*([a-zA-Z0-9_]+)",
   2.210 +					NULL, deIfDef);
   2.211 +}
   2.212 +
   2.213 +/* Create parser definition stucture */
   2.214 +extern parserDefinition* EuphoriaParser (void)
   2.215 +{
   2.216 +	static const char *const extensions [] = { "e", "ed", "ew", "ex", "exu", "exw", "exd", NULL };
   2.217 +	parserDefinition* const def = parserNew ("Euphoria");
   2.218 +	def->initialize = installEuphoriaRegex;
   2.219 +	def->kinds      = EuphoriaKinds;
   2.220 +	def->kindCount  = KIND_COUNT (EuphoriaKinds);
   2.221 +	def->extensions = extensions;
   2.222 +	def->parser     = findEuphoriaTags;
   2.223 +	return def;
   2.224 +}
     3.1 --- a/ctags/ctags-sample	Tue Nov 29 05:54:05 2011 -0400
     3.2 +++ b/ctags/ctags-sample	Wed Nov 30 13:12:19 2011 -0400
     3.3 @@ -1,17 +1,24 @@
     3.4  !_TAG_FILE_FORMAT	2	/extended format; --format=1 will not append ;" to lines/
     3.5  !_TAG_FILE_SORTED	1	/0=unsorted, 1=sorted, 2=foldcase/
     3.6  !_TAG_PROGRAM_AUTHOR	Darren Hiebert	/dhiebert@users.sourceforge.net/
     3.7 -!_TAG_PROGRAM_NAME	Exuberant Ctags	//
     3.8 +!_TAG_PROGRAM_NAME	Exuberant Ctags	5.8//
     3.9  !_TAG_PROGRAM_URL	http://ctags.sourceforge.net	/official site/
    3.10  !_TAG_PROGRAM_VERSION	Development	//
    3.11 -EuphoriaParser	.\euphoria.c	/^extern parserDefinition* EuphoriaParser (void)$/;"	f	line:53	signature:(void)
    3.12 -_1of1function	.\ctags_euphoria_test.e	/^function _1of1function() end function$/;"	f	line:14
    3.13 -_1of1memstruct	.\ctags_euphoria_test.e	/^memstruct _1of1memstruct$/;"	s	line:19
    3.14 -_1of1memtype	.\ctags_euphoria_test.e	/^memtype amemtype as _1of1memtype$/;"	m	line:17
    3.15 -_1of1memunion	.\ctags_euphoria_test.e	/^memunion _1of1memunion$/;"	s	line:22
    3.16 -_1of1procedure	.\ctags_euphoria_test.e	/^function _1of1procedure() end function$/;"	f	line:15
    3.17 -_1of4type	.\ctags_euphoria_test.e	/^public type _1of4type(object w)$/;"	t	line:8
    3.18 -_2of4type	.\ctags_euphoria_test.e	/^export type _2of4type(sequence z) end type$/;"	t	line:10
    3.19 -_3of4type	.\ctags_euphoria_test.e	/^global type _3of4type(integer y) end type$/;"	t	line:11
    3.20 -_4of4type	.\ctags_euphoria_test.e	/^override type _4of4type(atom x) end type$/;"	t	line:12
    3.21 -installEuphoriaRegex	.\euphoria.c	/^static void installEuphoriaRegex (const langType language)$/;"	f	line:26	file:	signature:(const langType language)
    3.22 +_1of1memstruct	./ctags_euphoria_test.e	/^memstruct _1of1memstruct$/;"	s	line:66
    3.23 +_1of1memtype	./ctags_euphoria_test.e	/^memtype _0of1amemtype as _1of1memtype$/;"	m	line:58
    3.24 +_1of1memunion	./ctags_euphoria_test.e	/^memunion _1of1memunion  --$/;"	u	line:60
    3.25 +_1of1procedure	./ctags_euphoria_test.e	/^procedure _1of1procedure() end procedure$/;"	p	line:54
    3.26 +_1of2c	./ctags_euphoria_test.e	/^constant _1of2c=0$/;"	c	line:20
    3.27 +_1of2function	./ctags_euphoria_test.e	/^function _1of2function() return TRUE end function$/;"	f	line:47
    3.28 +_1of4word	./ctags_euphoria_test.e	/^with define _1of4word$/;"	i	line:12
    3.29 +_1of5type	./ctags_euphoria_test.e	/^type _1of5type(object w)$/;"	t	line:27
    3.30 +_2of2function	./ctags_euphoria_test.e	/^function _2of2function($/;"	f	line:48
    3.31 +_2of3namespace	./ctags_euphoria_test.e	/^include std\/types.e as _2of3namespace$/;"	n	line:9
    3.32 +_2of4word	./ctags_euphoria_test.e	/^without define _2of4word$/;"	i	line:13
    3.33 +_2of5type	./ctags_euphoria_test.e	/^public type _2of5type(object w)$/;"	t	line:31
    3.34 +_3of3namespace	./ctags_euphoria_test.e	/^public include "std\\\\io.e" as _3of3namespace  --not a real string$/;"	n	line:10
    3.35 +_3of4word	./ctags_euphoria_test.e	/^ifdef _3of4word then$/;"	i	line:15
    3.36 +_3of5type	./ctags_euphoria_test.e	/^	export type _3of5type(sequence z) return TRUE end type$/;"	t	line:35
    3.37 +_4of4word	./ctags_euphoria_test.e	/^elsifdef _4of4word then$/;"	i	line:16
    3.38 +_4of5type	./ctags_euphoria_test.e	/^ global type _4of5type(integer y)return TRUE end type$/;"	t	line:36
    3.39 +_5of5type	./ctags_euphoria_test.e	/^override type _5of5type($/;"	t	line:38
     4.1 --- a/ctags/ctags_euphoria_test.e	Tue Nov 29 05:54:05 2011 -0400
     4.2 +++ b/ctags/ctags_euphoria_test.e	Wed Nov 30 13:12:19 2011 -0400
     4.3 @@ -1,25 +1,71 @@
     4.4 ---t11B29a03:33 limited test file for ctags euphoria regex parser
     4.5 ---ctags_euphoria_test.e  (struct branch)
     4.6 +-- t11B29a03:33 limited test file for ctags euphoria regex parsers
     4.7 +-- ctags_euphoria_test.e  (struct branch)
     4.8 +-- regex parser misses multiline fuction sig and other lists
     4.9 +
    4.10 +namespace _1of3namespace
    4.11  
    4.12  include std/os.e
    4.13  include std/sequence.e
    4.14 -include std/io.e
    4.15 +include std/types.e as _2of3namespace
    4.16 +public include "std\\io.e" as _3of3namespace  --not a real string
    4.17  
    4.18 -public type _1of4type(object w)
    4.19 - end type
    4.20 -export type _2of4type(sequence z) end type
    4.21 -global type _3of4type(integer y) end type
    4.22 -override type _4of4type(atom x) end type
    4.23 +with define _1of4word
    4.24 +without define _2of4word
    4.25  
    4.26 -function _1of1function() end function
    4.27 -function _1of1procedure() end function
    4.28 +ifdef _3of4word then
    4.29 +elsifdef _4of4word then
    4.30 +elsedef
    4.31 +end ifdef
    4.32  
    4.33 -memtype amemtype as _1of1memtype
    4.34 +constant _1of2c=0
    4.35 +
    4.36 +public 
    4.37 +constant 
    4.38 +	_2of2c = 0
    4.39 +
    4.40 +--filescope
    4.41 +type _1of5type(object w)
    4.42 +	return TRUE
    4.43 +end type
    4.44 +
    4.45 +public type _2of5type(object w)
    4.46 +	return TRUE
    4.47 +end type
    4.48 +
    4.49 +	export type _3of5type(sequence z) return TRUE end type
    4.50 + global type _4of5type(integer y)return TRUE end type
    4.51 +
    4.52 +override type _5of5type(
    4.53 +
    4.54 +	object o
    4.55 +	) return TRUE
    4.56 +end type
    4.57 +
    4.58 +--not likely though legal won't be collected
    4.59 +?1	export type _0of5type(sequence z) return TRUE end type
    4.60 +
    4.61 +function _1of2function() return TRUE end function
    4.62 +function _2of2function(
    4.63 +		atom b
    4.64 +		,atom a) 
    4.65 + return TRUE end function
    4.66 +
    4.67 +
    4.68 +procedure _1of1procedure() end procedure
    4.69 +
    4.70 +memtype  
    4.71 +	int as _0of1amemtype
    4.72 +memtype _0of1amemtype as _1of1memtype
    4.73 +
    4.74 +memunion _1of1memunion  --
    4.75 +	int i
    4.76 +	unsigned char c
    4.77 +end memunion
    4.78 +
    4.79  
    4.80  memstruct _1of1memstruct
    4.81 +	object x
    4.82 +	_1of1memunion y
    4.83  end memstruct
    4.84  
    4.85 -memunion _1of1memunion
    4.86 -end memunion
    4.87 -
    4.88 -
    4.89 +--
     5.1 --- a/ctags/euphoria.c	Tue Nov 29 05:54:05 2011 -0400
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,61 +0,0 @@
     5.4 -/*
     5.5 -*   $Id$
     5.6 -*
     5.7 -*   Copyright (c) 2008 by Jeremy Cowgar
     5.8 -*
     5.9 -*   This source code is released for free distribution under the terms of the
    5.10 -*   GNU General Public License.
    5.11 -*
    5.12 -*   This module contains functions for generating tags for Euphoria routines.
    5.13 -*   http://openeuphoria.org/
    5.14 -*
    5.15 -*   m11B28p05:33 ne1 add |public|override.  (mem)*type
    5.16 -*   	it's not ignoring function def inside multiline comments?
    5.17 -*   	next version should be full parser?
    5.18 -*/
    5.19 -
    5.20 -/*
    5.21 -*   INCLUDE FILES
    5.22 -*/
    5.23 -
    5.24 -#include "general.h"    /* always include first */
    5.25 -#include "parse.h"      /* always include */
    5.26 -
    5.27 -/* FUNCTION DEFINITIONS */
    5.28 -
    5.29 -static void installEuphoriaRegex (const langType language)
    5.30 -{
    5.31 -	//symbol names can't actually start with numbers, but we let it slide.
    5.32 -
    5.33 -    addTagRegex (language,
    5.34 -		"^(global|export|public|override)*[ \t\n]*function[ \t\n]+([a-zA-Z0-9_]+)",
    5.35 -								"\\2", "f,function", NULL);
    5.36 -    addTagRegex (language,
    5.37 -		"^(global|export|public|override)*[ \t\n]*procedure[ \t\n]+([a-zA-Z0-9_]+)",
    5.38 -								"\\2", "p,procedure", NULL);
    5.39 -    addTagRegex (language,
    5.40 -		"^(global|export|public|override)*[ \t\n]*type[ \t\n]+([a-zA-Z0-9_]+)",
    5.41 -								"\\2", "t,type", NULL);
    5.42 -
    5.43 -    //memtype might be a list and it would only get the first one 
    5.44 -    addTagRegex (language,
    5.45 -		"^(global|export|public|override)*[ \t\n]*memtype[ \t\n]+([a-zA-Z0-9_]+)[ \t\n]+as[ \t\n]+([a-zA-Z0-9_]+)",
    5.46 -								"\\3", "m,memtype", NULL);
    5.47 -
    5.48 -	//memstruct/union/type currently in a branch. not sure ctags can capture them?
    5.49 -    addTagRegex (language,
    5.50 -		"^(global|export|public|override)*[ \t\n]*mem(struct|union)+[ \t\n]+([a-zA-Z0-9_]+)",
    5.51 -								"\\3", "s,mem\\2", NULL);
    5.52 -    //namespace and memtype similar
    5.53 -}
    5.54 -
    5.55 -/* Create parser definition stucture */
    5.56 -extern parserDefinition* EuphoriaParser (void)
    5.57 -{
    5.58 -    static const char *const extensions [] = { "e", "ed", "ew", "ex", "exu", "exw", "exd", NULL };
    5.59 -    parserDefinition* const def = parserNew ("Euphoria");
    5.60 -    def->extensions = extensions;
    5.61 -    def->initialize = installEuphoriaRegex;
    5.62 -    def->regex      = TRUE;
    5.63 -    return def;
    5.64 -}
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/ctags/simple-regex-euphoria.c	Wed Nov 30 13:12:19 2011 -0400
     6.3 @@ -0,0 +1,68 @@
     6.4 +/*
     6.5 +*   $Id$
     6.6 +*
     6.7 +*   Copyright (c) 2008 by Jeremy Cowgar
     6.8 +*
     6.9 +*   This source code is released for free distribution under the terms of the
    6.10 +*   GNU General Public License.
    6.11 +*
    6.12 +*   This module contains functions for generating tags for Euphoria routines.
    6.13 +*   http://openeuphoria.org/
    6.14 +*
    6.15 +*   m11B28p05:33 ne1 add |public|override.  (mem)*type, constant
    6.16 +*   	it's not ignoring function def inside multiline comments?
    6.17 +*   	will not collect items from a list
    6.18 +*   	multiline function sig is not collected
    6.19 +*   	everything after mem* or constant is captured
    6.20 +*   	next version should be full parser.
    6.21 +*/
    6.22 +
    6.23 +/*
    6.24 +*   INCLUDE FILES
    6.25 +*/
    6.26 +
    6.27 +#include "general.h"    /* always include first */
    6.28 +#include "parse.h"      /* always include */
    6.29 +
    6.30 +/* FUNCTION DEFINITIONS */
    6.31 +
    6.32 +static void installEuphoriaRegex (const langType language)
    6.33 +{
    6.34 +	//symbol names can't actually start with numbers, but we let it slide.
    6.35 +
    6.36 +	addTagRegex (language,
    6.37 +			"^(global|export|public|override)*[ \t\n]*function[ \t\n]+([a-zA-Z0-9_]+)",
    6.38 +				 "\\2", "f,function", NULL);
    6.39 +	addTagRegex (language,
    6.40 +			"^(global|export|public|override)*[ \t\n]*procedure[ \t\n]+([a-zA-Z0-9_]+)",
    6.41 +				 "\\2", "p,procedure", NULL);
    6.42 +	addTagRegex (language,
    6.43 +			"^(global|export|public|override)*[ \t\n]*type[ \t\n]+([a-zA-Z0-9_]+)",
    6.44 +				 "\\2", "t,type", NULL);
    6.45 +
    6.46 +	//regx parser can't collect from list
    6.47 +	addTagRegex (language,
    6.48 +			"^(global|export|public|override)*[ \t\n]*constant[ \t\n,]+([a-zA-Z0-9_]+)",
    6.49 +				 "\\2", "c,constant", NULL);
    6.50 +
    6.51 +	//memtype might be a list and it would only get the first one
    6.52 +	addTagRegex (language,
    6.53 +			"^(global|export|public|override)*[ \t\n]*memtype[ \t\n]+([a-zA-Z0-9_]+)[ \t\n]+as[ \t\n]+([a-zA-Z0-9_]+)",
    6.54 +				 "\\3", "m,memtype", NULL);
    6.55 +
    6.56 +	//memstruct/union/type currently in a branch
    6.57 +	addTagRegex (language,
    6.58 +			"^(global|export|public|override)*[ \t\n]*mem(struct|union)+[ \t\n]+([a-zA-Z0-9_]+)",
    6.59 +				 "\\3", "s,mem\\2", NULL);
    6.60 +}
    6.61 +
    6.62 +/* Create parser definition stucture */
    6.63 +extern parserDefinition* EuphoriaParser (void)
    6.64 +{
    6.65 +	static const char *const extensions [] = { "e", "ed", "ew", "ex", "exu", "exw", "exd", NULL };
    6.66 +	parserDefinition* const def = parserNew ("Euphoria");
    6.67 +	def->extensions = extensions;
    6.68 +	def->initialize = installEuphoriaRegex;
    6.69 +	def->regex      = TRUE;
    6.70 +	return def;
    6.71 +}

SCM Home | OpenEuphoria.org Home