editors

changeset 44:c2af9b14fdd7

add label collection to callback-regex-euphoria.c
fix a few names
add a few details to readme
author ne1uno <ne1uno@users.sourceforge.net>
date Wed Dec 07 21:13:56 2011 -0400 (2011-12-07)
parents 1bb7df51432a
children 1cab30e3ec7b
files ctags/callback-regex-euphoria.c ctags/ctags-sample ctags/ctags_euphoria_test.e
line diff
     1.1 --- a/ctags/callback-regex-euphoria.c	Wed Nov 30 13:12:19 2011 -0400
     1.2 +++ b/ctags/callback-regex-euphoria.c	Wed Dec 07 21:13:56 2011 -0400
     1.3 @@ -15,13 +15,13 @@
     1.4  *   	multiline function sig is not collected
     1.5  *   	everything after mem* or constant is captured
     1.6  *   	next version should be full parser.
     1.7 -*  	t11B29p02:00 can callback regex handle multiline?
     1.8 -*  		this may still fail for public\nitem(\n) to get function sig
     1.9 -*  		really not much different than the simple parser so far
    1.10 -*  		added collect namespace & ifdef, elsifdef, define words
    1.11 -*  		may want to get define but not ifdef/elsifdef?
    1.12 -*  		output a little weird for the include lines and slashes
    1.13 -*  		tag parser still needs to be implemented
    1.14 +*  t11B29p02:00 can callback regex handle multiline?
    1.15 +*   	this may still fail for public\nitem(\n) to get function sig
    1.16 +*   	really not much different than the simple parser so far
    1.17 +*   	added collect namespace & ifdef, elsifdef, define words
    1.18 +*   	may want to get define but not ifdef/elsifdef?
    1.19 +*   	output a little weird for the include lines and slashes
    1.20 +*   	tag parser still needs to be implemented
    1.21  */
    1.22  
    1.23  /*
    1.24 @@ -37,15 +37,16 @@
    1.25  
    1.26  
    1.27  static kindOption EuphoriaKinds [] = {
    1.28 -	{ TRUE, 'n', "namespace", " xnamespace" },
    1.29 -	{ TRUE, 'm', "memtype", " xmemtype" },
    1.30 -	{ TRUE, 's', "memstruct", " xmemstruct" },
    1.31 -	{ TRUE, 'u', "memunion", " xmemunion" },
    1.32 -	{ TRUE, 'c', "constant", " xconstant" },
    1.33 -	{ TRUE, 't', "type", " xtype" },
    1.34 -	{ TRUE, 'f', "function", " xfunction" },
    1.35 -	{ TRUE, 'p', "procedure", " xprocedure" },
    1.36 -	{ TRUE, 'i', "ifelsedefs", " xifelsedefs" }
    1.37 +	{ TRUE, 'n', "namespace", " namespace x or include y as x" },
    1.38 +	{ TRUE, 'm', "memtype", " memtype" },
    1.39 +	{ TRUE, 's', "memstruct", " memstruct" },
    1.40 +	{ TRUE, 'u', "memunion", " memunion" },
    1.41 +	{ TRUE, 'c', "constant", " constant" },
    1.42 +	{ TRUE, 't', "type", " type" },
    1.43 +	{ TRUE, 'f', "function", " function" },
    1.44 +	{ TRUE, 'p', "procedure", " procedure" },
    1.45 +	{ TRUE, 'i', "ifelsedefs", " ifdef,elsifdef,define words" },
    1.46 +	{ TRUE, 'l', "label ", " label target for loop/goto" }
    1.47  };
    1.48  
    1.49  typedef enum {
    1.50 @@ -57,7 +58,8 @@
    1.51  	ktype,
    1.52  	kfunction,
    1.53  	kprocedure,
    1.54 -	kifelsedef
    1.55 +	kifelsedef,
    1.56 +	klabel
    1.57   } EuphoriaKind;
    1.58  /* FUNCTION DEFINITIONS */
    1.59  
    1.60 @@ -131,20 +133,7 @@
    1.61  }
    1.62  
    1.63  
    1.64 -static void deIfDef (const char *const line, const regexMatch *const matches,
    1.65 -						const unsigned int count)
    1.66 -{
    1.67 -	if (count > 1)    /* should always be true per regex */
    1.68 -	{
    1.69 -		vString *const name = vStringNew ();
    1.70 -		//later may want to distinguish ifdef,elsifdef, with/out  define 
    1.71 -		vStringNCopyS (name, line + matches [count-1].start, matches [count-1].length);
    1.72 -		makeSimpleTag (name, EuphoriaKinds, kifelsedef);
    1.73 -	}
    1.74 -}
    1.75 -
    1.76 -
    1.77 -static void defNS (const char *const line, const regexMatch *const matches,
    1.78 +static void defNs (const char *const line, const regexMatch *const matches,
    1.79  						const unsigned int count)
    1.80  {
    1.81  	if (count > 1 )    /* should always be true per regex */
    1.82 @@ -159,6 +148,38 @@
    1.83  	}
    1.84  }
    1.85  
    1.86 +
    1.87 +
    1.88 +static void defIfDef (const char *const line, const regexMatch *const matches,
    1.89 +						const unsigned int count)
    1.90 +{
    1.91 +	if (count > 1)    /* should always be true per regex */
    1.92 +	{
    1.93 +		vString *const name = vStringNew ();
    1.94 +		//later may want to distinguish ifdef,elsifdef, with/out  define 
    1.95 +		vStringNCopyS (name, line + matches [count-1].start, matches [count-1].length);
    1.96 +		makeSimpleTag (name, EuphoriaKinds, kifelsedef);
    1.97 +	}
    1.98 +}
    1.99 +
   1.100 +static void defLabel (const char *const line, const regexMatch *const matches,
   1.101 +						const unsigned int count)
   1.102 +{
   1.103 +	if (count > 1 )    /* should always be true per regex */
   1.104 +	{
   1.105 +		vString *const name = vStringNew ();
   1.106 +		vStringNCopyS (name, line + matches [count-1].start, matches [count-1].length);
   1.107 +
   1.108 +		// would like to prepend label to the found expression
   1.109 +		// label goto "whatever" instead of goto "whatever" 
   1.110 +		// displayed after the filename in the default output
   1.111 +		// name at this point only has whatever
   1.112 +		// not sure how to access the expression w/o a parser
   1.113 +
   1.114 +		makeSimpleTag (name, EuphoriaKinds, klabel);
   1.115 +	}
   1.116 +}
   1.117 +
   1.118  static void findEuphoriaTags (void)
   1.119  {
   1.120  	while (fileReadLine () != NULL)
   1.121 @@ -176,6 +197,7 @@
   1.122  	addCallbackRegex (language,
   1.123  			"^[ \t\n]*(global|export|public|override)*[ \t\n]*(procedure|function)+[ \t\n]+([a-zA-Z0-9_]+)",
   1.124  				NULL, defFunDef);
   1.125 +
   1.126  	addCallbackRegex (language,
   1.127  			"^[ \t\n]*(global|export|public|override)*[ \t\n]*type[ \t\n]+([a-zA-Z0-9_]+)",
   1.128  				NULL, defType);
   1.129 @@ -183,28 +205,33 @@
   1.130  	//will miss some, regx parser can't collect from list
   1.131  	addCallbackRegex (language,
   1.132  			"^[ \t\n]*(global|export|public|override)*[ \t\n]*constant[ \t\n,]+([a-zA-Z0-9_]+)",
   1.133 -					NULL, defConst);
   1.134 +				NULL, defConst);
   1.135  
   1.136  	//memstruct/union/type currently in a branch. 
   1.137  	// this won't affect parsing std euphoria
   1.138  	addCallbackRegex (language,
   1.139  			"^[ \t\n]*(global|export|public|override)*[ \t\n]*mem(struct|union)+[ \t\n]+([a-zA-Z0-9_]+)",
   1.140 -					NULL, defMemStruct);
   1.141 +				NULL, defMemStruct);
   1.142  
   1.143  	//memtype might be a list and it would only get the first one
   1.144  	addCallbackRegex (language,
   1.145  			"^[ \t\n]*(global|export|public|override)*[ \t\n]*memtype[ \t\n]+([a-zA-Z0-9_]+)[ \t\n]+as[ \t\n]+([a-zA-Z0-9_]+)",
   1.146 -					NULL, defMemType);
   1.147 +				NULL, defMemType);
   1.148  
   1.149  	//namespace x vrs include y as x
   1.150  	//could miss some hypothetical namespace called aswhatever?
   1.151  	addCallbackRegex (language,
   1.152  			"^[ \t\n]*(public)*[ \t\n]*(include|namespace)+[ \t\n]+([a-zA-Z0-9\\/~#:\"._-]+)[ \t\n]*(as)*[ \t\n]*([a-zA-Z0-9_]*)",
   1.153 -					NULL, defNS);
   1.154 +				NULL, defNs);
   1.155  
   1.156  	addCallbackRegex (language,
   1.157  			"^[ \t\n]*(ifdef|elsifdef|with|without)+[ \t\n]+(not|define)*[ \t\n]*([a-zA-Z0-9_]+)",
   1.158 -					NULL, deIfDef);
   1.159 +				NULL, defIfDef);
   1.160 +
   1.161 +	addCallbackRegex (language,
   1.162 +			//add for/while/etc targets, is /s required after keyword?
   1.163 +			"^[ \t\n]*(label|goto|continue|exit)+[ \t\n]+\"([^\"]+)",  //\"
   1.164 +				NULL, defLabel);
   1.165  }
   1.166  
   1.167  /* Create parser definition stucture */
     2.1 --- a/ctags/ctags-sample	Wed Nov 30 13:12:19 2011 -0400
     2.2 +++ b/ctags/ctags-sample	Wed Dec 07 21:13:56 2011 -0400
     2.3 @@ -3,22 +3,24 @@
     2.4  !_TAG_PROGRAM_AUTHOR	Darren Hiebert	/dhiebert@users.sourceforge.net/
     2.5  !_TAG_PROGRAM_NAME	Exuberant Ctags	5.8//
     2.6  !_TAG_PROGRAM_URL	http://ctags.sourceforge.net	/official site/
     2.7 -!_TAG_PROGRAM_VERSION	Development	//
     2.8 -_1of1memstruct	./ctags_euphoria_test.e	/^memstruct _1of1memstruct$/;"	s	line:66
     2.9 -_1of1memtype	./ctags_euphoria_test.e	/^memtype _0of1amemtype as _1of1memtype$/;"	m	line:58
    2.10 -_1of1memunion	./ctags_euphoria_test.e	/^memunion _1of1memunion  --$/;"	u	line:60
    2.11 -_1of1procedure	./ctags_euphoria_test.e	/^procedure _1of1procedure() end procedure$/;"	p	line:54
    2.12 -_1of2c	./ctags_euphoria_test.e	/^constant _1of2c=0$/;"	c	line:20
    2.13 -_1of2function	./ctags_euphoria_test.e	/^function _1of2function() return TRUE end function$/;"	f	line:47
    2.14 -_1of4word	./ctags_euphoria_test.e	/^with define _1of4word$/;"	i	line:12
    2.15 -_1of5type	./ctags_euphoria_test.e	/^type _1of5type(object w)$/;"	t	line:27
    2.16 -_2of2function	./ctags_euphoria_test.e	/^function _2of2function($/;"	f	line:48
    2.17 -_2of3namespace	./ctags_euphoria_test.e	/^include std\/types.e as _2of3namespace$/;"	n	line:9
    2.18 -_2of4word	./ctags_euphoria_test.e	/^without define _2of4word$/;"	i	line:13
    2.19 -_2of5type	./ctags_euphoria_test.e	/^public type _2of5type(object w)$/;"	t	line:31
    2.20 -_3of3namespace	./ctags_euphoria_test.e	/^public include "std\\\\io.e" as _3of3namespace  --not a real string$/;"	n	line:10
    2.21 -_3of4word	./ctags_euphoria_test.e	/^ifdef _3of4word then$/;"	i	line:15
    2.22 -_3of5type	./ctags_euphoria_test.e	/^	export type _3of5type(sequence z) return TRUE end type$/;"	t	line:35
    2.23 -_4of4word	./ctags_euphoria_test.e	/^elsifdef _4of4word then$/;"	i	line:16
    2.24 -_4of5type	./ctags_euphoria_test.e	/^ global type _4of5type(integer y)return TRUE end type$/;"	t	line:36
    2.25 -_5of5type	./ctags_euphoria_test.e	/^override type _5of5type($/;"	t	line:38
    2.26 +!_TAG_PROGRAM_VERSION	Development 5.8 ne1	//
    2.27 +_1of1memstruct	c:/c/LANG/Eu/GUI/euqt/lib/ctag/ctags_euphoria_test.e	/^memstruct _1of1memstruct$/;"	s	line:66
    2.28 +_1of1memtype	c:/c/LANG/Eu/GUI/euqt/lib/ctag/ctags_euphoria_test.e	/^memtype _0o21amemtype as _1of1memtype$/;"	m	line:56
    2.29 +_1of1memunion	c:/c/LANG/Eu/GUI/euqt/lib/ctag/ctags_euphoria_test.e	/^memunion _1of1memunion  --$/;"	u	line:60
    2.30 +_1of1procedure	c:/c/LANG/Eu/GUI/euqt/lib/ctag/ctags_euphoria_test.e	/^procedure _1of1procedure() end procedure$/;"	p	line:54
    2.31 +_1of2c	c:/c/LANG/Eu/GUI/euqt/lib/ctag/ctags_euphoria_test.e	/^constant _1of2c=0$/;"	c	line:20
    2.32 +_1of2function	c:/c/LANG/Eu/GUI/euqt/lib/ctag/ctags_euphoria_test.e	/^function _1of2function() return TRUE end function$/;"	f	line:47
    2.33 +_1of2label	c:/c/LANG/Eu/GUI/euqt/lib/ctag/ctags_euphoria_test.e	/^	goto "_1of2label"$/;"	l	line:72
    2.34 +_1of4word	c:/c/LANG/Eu/GUI/euqt/lib/ctag/ctags_euphoria_test.e	/^with define _1of4word$/;"	i	line:12
    2.35 +_1of5type	c:/c/LANG/Eu/GUI/euqt/lib/ctag/ctags_euphoria_test.e	/^type _1of5type(object w)$/;"	t	line:27
    2.36 +_2of2function	c:/c/LANG/Eu/GUI/euqt/lib/ctag/ctags_euphoria_test.e	/^function _2of2function($/;"	f	line:48
    2.37 +_2of2label	c:/c/LANG/Eu/GUI/euqt/lib/ctag/ctags_euphoria_test.e	/^label "_2of2label"$/;"	l	line:75
    2.38 +_2of3namespace	c:/c/LANG/Eu/GUI/euqt/lib/ctag/ctags_euphoria_test.e	/^include std\/types.e as _2of3namespace$/;"	n	line:9
    2.39 +_2of4word	c:/c/LANG/Eu/GUI/euqt/lib/ctag/ctags_euphoria_test.e	/^without define _2of4word$/;"	i	line:13
    2.40 +_2of5type	c:/c/LANG/Eu/GUI/euqt/lib/ctag/ctags_euphoria_test.e	/^public type _2of5type(object w)$/;"	t	line:31
    2.41 +_3of3namespace	c:/c/LANG/Eu/GUI/euqt/lib/ctag/ctags_euphoria_test.e	/^public include "std\\\\io.e" as _3of3namespace  --not a real string$/;"	n	line:10
    2.42 +_3of4word	c:/c/LANG/Eu/GUI/euqt/lib/ctag/ctags_euphoria_test.e	/^ifdef _3of4word then$/;"	i	line:15
    2.43 +_3of5type	c:/c/LANG/Eu/GUI/euqt/lib/ctag/ctags_euphoria_test.e	/^	export type _3of5type(sequence z) return TRUE end type$/;"	t	line:35
    2.44 +_4of4word	c:/c/LANG/Eu/GUI/euqt/lib/ctag/ctags_euphoria_test.e	/^elsifdef _4of4word then$/;"	i	line:16
    2.45 +_4of5type	c:/c/LANG/Eu/GUI/euqt/lib/ctag/ctags_euphoria_test.e	/^ global type _4of5type(integer y)return TRUE end type$/;"	t	line:36
    2.46 +_5of5type	c:/c/LANG/Eu/GUI/euqt/lib/ctag/ctags_euphoria_test.e	/^override type _5of5type($/;"	t	line:38
     3.1 --- a/ctags/ctags_euphoria_test.e	Wed Nov 30 13:12:19 2011 -0400
     3.2 +++ b/ctags/ctags_euphoria_test.e	Wed Dec 07 21:13:56 2011 -0400
     3.3 @@ -53,9 +53,9 @@
     3.4  
     3.5  procedure _1of1procedure() end procedure
     3.6  
     3.7 +memtype _0o21amemtype as _1of1memtype
     3.8  memtype  
     3.9 -	int as _0of1amemtype
    3.10 -memtype _0of1amemtype as _1of1memtype
    3.11 +	int as _1of2amemtype
    3.12  
    3.13  memunion _1of1memunion  --
    3.14  	int i
    3.15 @@ -68,4 +68,9 @@
    3.16  	_1of1memunion y
    3.17  end memstruct
    3.18  
    3.19 +while TRUE label "_0of2label" do 
    3.20 +	goto "_1of2label"
    3.21 +end while 
    3.22 +
    3.23 +label "_2of2label"
    3.24  --

SCM Home | OpenEuphoria.org Home