Mercurial > emacs
comparison lib-src/etags.c @ 89978:566253900690
Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-40
Merge from emacs--cvs-trunk--0
Patches applied:
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-535
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-536
sync-tree with gnus--rel--5.10
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-537
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-538
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-539
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-540
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-541
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-542
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-545
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-546
Merge from gnus--rel--5.10
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-547
- miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-548
Update from CVS
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-549
Use symbol-matching for generic-mode keywords
* miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-550
Update from CVS
* miles@gnu.org--gnu-2004/gnus--devo--0--patch-2
Add {arch}/=cvs-sync-make-log
* miles@gnu.org--gnu-2004/gnus--rel--5.8--base-0
Import from Gnus CVS branch V5-8
* miles@gnu.org--gnu-2004/gnus--rel--5.8--patch-1
{arch}/=tagging-method: Add CVS and autoconf grot to junk regexp
* miles@gnu.org--gnu-2004/gnus--rel--5.8--patch-2
Use explicit tags for autoconf input files
* miles@gnu.org--gnu-2004/gnus--rel--5.8--patch-3
Remove RCS keywords
* miles@gnu.org--gnu-2004/gnus--rel--5.8--patch-4
Fix copied explicit id-tags
* miles@gnu.org--gnu-2004/gnus--rel--5.8--patch-5
Add {arch}/=cvs-sync-make-log
* miles@gnu.org--gnu-2004/gnus--rel--5.8--patch-6
configure.in: Use ifelse instead of m4_if for arch-tag: comment
* miles@gnu.org--gnu-2004/gnus--rel--5.10--base-0
tag of miles@gnu.org--gnu-2004/gnus--rel--5.8--base-0
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-1
Gnus 5.10, from CVS branch v5-10
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-2
Merge from gnus--rel--5.8
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-3
Use explicit tags for autoconf input files
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-4
sync-tree with gnus--rel--5.8
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-5
Update from CVS
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-6
Merge from gnus--rel--5.8
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-7
Remove RCS keywords
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-8
Merge from gnus--rel--5.8
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-9
Update from CVS
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-10
Add {arch}/=cvs-sync-make-log
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-11
Merge from gnus--rel--5.8
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-12
Update from CVS: make.bat: Fix line endings around arch-tag.
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-13
- miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-17
Update from CVS
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-21
Merge from emacs--cvs-trunk--0
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-22
Update from CVS: lisp/nndb.el (require): Remove tcp and duplicate cl.
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-23
Update from CVS
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-24
lisp/nnimap.el (nnimap-open-connection): Remove extraneous end-paren
* miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-25
- miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-26
Update from CVS
author | Miles Bader <miles@gnu.org> |
---|---|
date | Wed, 15 Sep 2004 09:00:10 +0000 |
parents | cce1c0ee76ee a02f327b4165 |
children | cb7f41387eb3 |
comparison
equal
deleted
inserted
replaced
89977:549fdd6f6856 | 89978:566253900690 |
---|---|
30 * 1994 Line-by-line regexp tags by Tom Tromey. | 30 * 1994 Line-by-line regexp tags by Tom Tromey. |
31 * 2001 Nested classes by Francesco Potort́ (concept by Mykola Dzyuba). | 31 * 2001 Nested classes by Francesco Potort́ (concept by Mykola Dzyuba). |
32 * 2002 #line directives by Francesco Potort́. | 32 * 2002 #line directives by Francesco Potort́. |
33 * | 33 * |
34 * Francesco Potort́ <pot@gnu.org> has maintained and improved it since 1993. | 34 * Francesco Potort́ <pot@gnu.org> has maintained and improved it since 1993. |
35 * | |
36 */ | 35 */ |
37 | 36 |
38 char pot_etags_version[] = "@(#) pot revision number is 16.58"; | 37 /* |
38 * If you want to add support for a new language, start by looking at the LUA | |
39 * language, which is the simplest. Alternatively, consider shipping a | |
40 * configuration file containing regexp definitions for etags. | |
41 */ | |
42 | |
43 char pot_etags_version[] = "@(#) pot revision number is 17.5"; | |
39 | 44 |
40 #define TRUE 1 | 45 #define TRUE 1 |
41 #define FALSE 0 | 46 #define FALSE 0 |
42 | 47 |
43 #ifdef DEBUG | 48 #ifdef DEBUG |
59 # define PTR void * | 64 # define PTR void * |
60 # endif | 65 # endif |
61 # ifndef __P /* for Xemacs */ | 66 # ifndef __P /* for Xemacs */ |
62 # define __P(args) args | 67 # define __P(args) args |
63 # endif | 68 # endif |
64 #else | 69 #else /* no config.h */ |
65 # if defined(__STDC__) && (__STDC__ || defined(__SUNPRO_C)) | 70 # if defined(__STDC__) && (__STDC__ || defined(__SUNPRO_C)) |
66 # define __P(args) args /* use prototypes */ | 71 # define __P(args) args /* use prototypes */ |
67 # define PTR void * /* for generic pointers */ | 72 # define PTR void * /* for generic pointers */ |
68 # else | 73 # else /* not standard C */ |
69 # define __P(args) () /* no prototypes */ | 74 # define __P(args) () /* no prototypes */ |
70 # define const /* remove const for old compilers' sake */ | 75 # define const /* remove const for old compilers' sake */ |
71 # define PTR long * /* don't use void* */ | 76 # define PTR long * /* don't use void* */ |
72 # endif | 77 # endif |
73 #endif /* !HAVE_CONFIG_H */ | 78 #endif /* !HAVE_CONFIG_H */ |
116 # undef DOS_NT | 121 # undef DOS_NT |
117 # define DOS_NT | 122 # define DOS_NT |
118 # ifndef HAVE_GETCWD | 123 # ifndef HAVE_GETCWD |
119 # define HAVE_GETCWD | 124 # define HAVE_GETCWD |
120 # endif /* undef HAVE_GETCWD */ | 125 # endif /* undef HAVE_GETCWD */ |
121 #else /* !WINDOWSNT */ | 126 #else /* not WINDOWSNT */ |
122 # ifdef STDC_HEADERS | 127 # ifdef STDC_HEADERS |
123 # include <stdlib.h> | 128 # include <stdlib.h> |
124 # include <string.h> | 129 # include <string.h> |
125 # else | 130 # else /* no standard C headers */ |
126 extern char *getenv (); | 131 extern char *getenv (); |
132 # ifdef VMS | |
133 # define EXIT_SUCCESS 1 | |
134 # define EXIT_FAILURE 0 | |
135 # else /* no VMS */ | |
136 # define EXIT_SUCCESS 0 | |
137 # define EXIT_FAILURE 1 | |
138 # endif | |
127 # endif | 139 # endif |
128 #endif /* !WINDOWSNT */ | 140 #endif /* !WINDOWSNT */ |
129 | 141 |
130 #ifdef HAVE_UNISTD_H | 142 #ifdef HAVE_UNISTD_H |
131 # include <unistd.h> | 143 # include <unistd.h> |
331 static void Cstar_entries __P((FILE *)); | 343 static void Cstar_entries __P((FILE *)); |
332 static void Erlang_functions __P((FILE *)); | 344 static void Erlang_functions __P((FILE *)); |
333 static void Fortran_functions __P((FILE *)); | 345 static void Fortran_functions __P((FILE *)); |
334 static void HTML_labels __P((FILE *)); | 346 static void HTML_labels __P((FILE *)); |
335 static void Lisp_functions __P((FILE *)); | 347 static void Lisp_functions __P((FILE *)); |
348 static void Lua_functions __P((FILE *)); | |
336 static void Makefile_targets __P((FILE *)); | 349 static void Makefile_targets __P((FILE *)); |
337 static void Pascal_functions __P((FILE *)); | 350 static void Pascal_functions __P((FILE *)); |
338 static void Perl_functions __P((FILE *)); | 351 static void Perl_functions __P((FILE *)); |
339 static void PHP_functions __P((FILE *)); | 352 static void PHP_functions __P((FILE *)); |
340 static void PS_functions __P((FILE *)); | 353 static void PS_functions __P((FILE *)); |
635 "In Lisp code, any function defined with `defun', any variable\n\ | 648 "In Lisp code, any function defined with `defun', any variable\n\ |
636 defined with `defvar' or `defconst', and in general the first\n\ | 649 defined with `defvar' or `defconst', and in general the first\n\ |
637 argument of any expression that starts with `(def' in column zero\n\ | 650 argument of any expression that starts with `(def' in column zero\n\ |
638 is a tag."; | 651 is a tag."; |
639 | 652 |
653 static char *Lua_suffixes [] = | |
654 { "lua", "LUA", NULL }; | |
655 static char Lua_help [] = | |
656 "In Lua scripts, all functions are tags."; | |
657 | |
640 static char *Makefile_filenames [] = | 658 static char *Makefile_filenames [] = |
641 { "Makefile", "makefile", "GNUMakefile", "Makefile.in", "Makefile.am", NULL}; | 659 { "Makefile", "makefile", "GNUMakefile", "Makefile.in", "Makefile.am", NULL}; |
642 static char Makefile_help [] = | 660 static char Makefile_help [] = |
643 "In makefiles, targets are tags; additionally, variables are tags\n\ | 661 "In makefiles, targets are tags; additionally, variables are tags\n\ |
644 unless you specify `--no-globals'."; | 662 unless you specify `--no-globals'."; |
761 { "erlang", Erlang_help, Erlang_functions, Erlang_suffixes }, | 779 { "erlang", Erlang_help, Erlang_functions, Erlang_suffixes }, |
762 { "fortran", Fortran_help, Fortran_functions, Fortran_suffixes }, | 780 { "fortran", Fortran_help, Fortran_functions, Fortran_suffixes }, |
763 { "html", HTML_help, HTML_labels, HTML_suffixes }, | 781 { "html", HTML_help, HTML_labels, HTML_suffixes }, |
764 { "java", Cjava_help, Cjava_entries, Cjava_suffixes }, | 782 { "java", Cjava_help, Cjava_entries, Cjava_suffixes }, |
765 { "lisp", Lisp_help, Lisp_functions, Lisp_suffixes }, | 783 { "lisp", Lisp_help, Lisp_functions, Lisp_suffixes }, |
784 { "lua", Lua_help, Lua_functions, Lua_suffixes }, | |
766 { "makefile", Makefile_help,Makefile_targets,NULL,Makefile_filenames}, | 785 { "makefile", Makefile_help,Makefile_targets,NULL,Makefile_filenames}, |
767 { "objc", Objc_help, plain_C_entries, Objc_suffixes }, | 786 { "objc", Objc_help, plain_C_entries, Objc_suffixes }, |
768 { "pascal", Pascal_help, Pascal_functions, Pascal_suffixes }, | 787 { "pascal", Pascal_help, Pascal_functions, Pascal_suffixes }, |
769 { "perl",Perl_help,Perl_functions,Perl_suffixes,NULL,Perl_interpreters}, | 788 { "perl",Perl_help,Perl_functions,Perl_suffixes,NULL,Perl_interpreters}, |
770 { "php", PHP_help, PHP_functions, PHP_suffixes }, | 789 { "php", PHP_help, PHP_functions, PHP_suffixes }, |
1293 { | 1312 { |
1294 char *oldcwd = cwd; | 1313 char *oldcwd = cwd; |
1295 cwd = concat (oldcwd, "/", ""); | 1314 cwd = concat (oldcwd, "/", ""); |
1296 free (oldcwd); | 1315 free (oldcwd); |
1297 } | 1316 } |
1298 if (streq (tagfile, "-")) | 1317 /* Relative file names are made relative to the current directory. */ |
1318 if (streq (tagfile, "-") | |
1319 || strneq (tagfile, "/dev/", 5)) | |
1299 tagfiledir = cwd; | 1320 tagfiledir = cwd; |
1300 else | 1321 else |
1301 tagfiledir = absolute_dirname (tagfile, cwd); | 1322 tagfiledir = absolute_dirname (tagfile, cwd); |
1302 | 1323 |
1303 init (); /* set up boolean "functions" */ | 1324 init (); /* set up boolean "functions" */ |
2371 enum sym_type | 2392 enum sym_type |
2372 { | 2393 { |
2373 st_none, | 2394 st_none, |
2374 st_C_objprot, st_C_objimpl, st_C_objend, | 2395 st_C_objprot, st_C_objimpl, st_C_objend, |
2375 st_C_gnumacro, | 2396 st_C_gnumacro, |
2376 st_C_ignore, | 2397 st_C_ignore, st_C_attribute, |
2377 st_C_javastruct, | 2398 st_C_javastruct, |
2378 st_C_operator, | 2399 st_C_operator, |
2379 st_C_class, st_C_template, | 2400 st_C_class, st_C_template, |
2380 st_C_struct, st_C_extern, st_C_enum, st_C_define, st_C_typedef, st_C_typespec | 2401 st_C_struct, st_C_extern, st_C_enum, st_C_define, st_C_typedef |
2381 }; | 2402 }; |
2382 | 2403 |
2383 static unsigned int hash __P((const char *, unsigned int)); | 2404 static unsigned int hash __P((const char *, unsigned int)); |
2384 static struct C_stab_entry * in_word_set __P((const char *, unsigned int)); | 2405 static struct C_stab_entry * in_word_set __P((const char *, unsigned int)); |
2385 static enum sym_type C_symtype __P((char *, int, int)); | 2406 static enum sym_type C_symtype __P((char *, int, int)); |
2386 | 2407 |
2387 /* Feed stuff between (but not including) %[ and %] lines to: | 2408 /* Feed stuff between (but not including) %[ and %] lines to: |
2388 gperf -c -k 1,3 -o -p -r -t | 2409 gperf -m 5 |
2389 %[ | 2410 %[ |
2411 %compare-strncmp | |
2412 %enum | |
2413 %struct-type | |
2390 struct C_stab_entry { char *name; int c_ext; enum sym_type type; } | 2414 struct C_stab_entry { char *name; int c_ext; enum sym_type type; } |
2391 %% | 2415 %% |
2392 if, 0, st_C_ignore | 2416 if, 0, st_C_ignore |
2393 for, 0, st_C_ignore | 2417 for, 0, st_C_ignore |
2394 while, 0, st_C_ignore | 2418 while, 0, st_C_ignore |
2395 switch, 0, st_C_ignore | 2419 switch, 0, st_C_ignore |
2396 return, 0, st_C_ignore | 2420 return, 0, st_C_ignore |
2397 @interface, 0, st_C_objprot | 2421 __attribute__, 0, st_C_attribute |
2398 @protocol, 0, st_C_objprot | 2422 @interface, 0, st_C_objprot |
2399 @implementation,0, st_C_objimpl | 2423 @protocol, 0, st_C_objprot |
2400 @end, 0, st_C_objend | 2424 @implementation,0, st_C_objimpl |
2401 import, C_JAVA, st_C_ignore | 2425 @end, 0, st_C_objend |
2402 package, C_JAVA, st_C_ignore | 2426 import, (C_JAVA & !C_PLPL), st_C_ignore |
2403 friend, C_PLPL, st_C_ignore | 2427 package, (C_JAVA & !C_PLPL), st_C_ignore |
2404 extends, C_JAVA, st_C_javastruct | 2428 friend, C_PLPL, st_C_ignore |
2405 implements, C_JAVA, st_C_javastruct | 2429 extends, (C_JAVA & !C_PLPL), st_C_javastruct |
2406 interface, C_JAVA, st_C_struct | 2430 implements, (C_JAVA & !C_PLPL), st_C_javastruct |
2407 class, 0, st_C_class | 2431 interface, (C_JAVA & !C_PLPL), st_C_struct |
2408 namespace, C_PLPL, st_C_struct | 2432 class, 0, st_C_class |
2409 domain, C_STAR, st_C_struct | 2433 namespace, C_PLPL, st_C_struct |
2410 union, 0, st_C_struct | 2434 domain, C_STAR, st_C_struct |
2411 struct, 0, st_C_struct | 2435 union, 0, st_C_struct |
2412 extern, 0, st_C_extern | 2436 struct, 0, st_C_struct |
2413 enum, 0, st_C_enum | 2437 extern, 0, st_C_extern |
2414 typedef, 0, st_C_typedef | 2438 enum, 0, st_C_enum |
2415 define, 0, st_C_define | 2439 typedef, 0, st_C_typedef |
2416 operator, C_PLPL, st_C_operator | 2440 define, 0, st_C_define |
2417 template, 0, st_C_template | 2441 operator, C_PLPL, st_C_operator |
2418 bool, C_PLPL, st_C_typespec | 2442 template, 0, st_C_template |
2419 long, 0, st_C_typespec | |
2420 short, 0, st_C_typespec | |
2421 int, 0, st_C_typespec | |
2422 char, 0, st_C_typespec | |
2423 float, 0, st_C_typespec | |
2424 double, 0, st_C_typespec | |
2425 signed, 0, st_C_typespec | |
2426 unsigned, 0, st_C_typespec | |
2427 auto, 0, st_C_typespec | |
2428 void, 0, st_C_typespec | |
2429 static, 0, st_C_typespec | |
2430 const, 0, st_C_typespec | |
2431 volatile, 0, st_C_typespec | |
2432 explicit, C_PLPL, st_C_typespec | |
2433 mutable, C_PLPL, st_C_typespec | |
2434 typename, C_PLPL, st_C_typespec | |
2435 # DEFUN used in emacs, the next three used in glibc (SYSCALL only for mach). | 2443 # DEFUN used in emacs, the next three used in glibc (SYSCALL only for mach). |
2436 DEFUN, 0, st_C_gnumacro | 2444 DEFUN, 0, st_C_gnumacro |
2437 SYSCALL, 0, st_C_gnumacro | 2445 SYSCALL, 0, st_C_gnumacro |
2438 ENTRY, 0, st_C_gnumacro | 2446 ENTRY, 0, st_C_gnumacro |
2439 PSEUDO, 0, st_C_gnumacro | 2447 PSEUDO, 0, st_C_gnumacro |
2440 # These are defined inside C functions, so currently they are not met. | 2448 # These are defined inside C functions, so currently they are not met. |
2441 # EXFUN used in glibc, DEFVAR_* in emacs. | 2449 # EXFUN used in glibc, DEFVAR_* in emacs. |
2442 #EXFUN, 0, st_C_gnumacro | 2450 #EXFUN, 0, st_C_gnumacro |
2443 #DEFVAR_, 0, st_C_gnumacro | 2451 #DEFVAR_, 0, st_C_gnumacro |
2444 %] | 2452 %] |
2445 and replace lines between %< and %> with its output, | 2453 and replace lines between %< and %> with its output, then: |
2446 then make in_word_set and C_stab_entry static. */ | 2454 - remove the #if characterset check |
2455 - make in_word_set static and not inline. */ | |
2447 /*%<*/ | 2456 /*%<*/ |
2448 /* C code produced by gperf version 2.7.1 (19981006 egcs) */ | 2457 /* C code produced by gperf version 3.0.1 */ |
2449 /* Command-line: gperf -c -k 1,3 -o -p -r -t */ | 2458 /* Command-line: gperf -m 5 */ |
2459 /* Computed positions: -k'1-2' */ | |
2460 | |
2450 struct C_stab_entry { char *name; int c_ext; enum sym_type type; }; | 2461 struct C_stab_entry { char *name; int c_ext; enum sym_type type; }; |
2451 | 2462 /* maximum key range = 31, duplicates = 0 */ |
2452 #define TOTAL_KEYWORDS 47 | |
2453 #define MIN_WORD_LENGTH 2 | |
2454 #define MAX_WORD_LENGTH 15 | |
2455 #define MIN_HASH_VALUE 18 | |
2456 #define MAX_HASH_VALUE 138 | |
2457 /* maximum key range = 121, duplicates = 0 */ | |
2458 | 2463 |
2459 #ifdef __GNUC__ | 2464 #ifdef __GNUC__ |
2460 __inline | 2465 __inline |
2466 #else | |
2467 #ifdef __cplusplus | |
2468 inline | |
2469 #endif | |
2461 #endif | 2470 #endif |
2462 static unsigned int | 2471 static unsigned int |
2463 hash (str, len) | 2472 hash (str, len) |
2464 register const char *str; | 2473 register const char *str; |
2465 register unsigned int len; | 2474 register unsigned int len; |
2466 { | 2475 { |
2467 static unsigned char asso_values[] = | 2476 static unsigned char asso_values[] = |
2468 { | 2477 { |
2469 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, | 2478 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, |
2470 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, | 2479 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, |
2471 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, | 2480 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, |
2472 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, | 2481 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, |
2473 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, | 2482 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, |
2474 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, | 2483 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, |
2475 139, 139, 139, 139, 63, 139, 139, 139, 33, 44, | 2484 34, 34, 34, 34, 1, 34, 34, 34, 14, 14, |
2476 62, 139, 139, 139, 139, 139, 139, 139, 139, 139, | 2485 34, 34, 34, 34, 34, 34, 34, 34, 13, 34, |
2477 42, 139, 139, 12, 32, 139, 139, 139, 139, 139, | 2486 13, 34, 34, 12, 34, 34, 34, 34, 34, 11, |
2478 139, 139, 139, 139, 139, 139, 139, 34, 59, 37, | 2487 34, 34, 34, 34, 34, 8, 34, 11, 34, 12, |
2479 24, 58, 33, 3, 139, 16, 139, 139, 42, 60, | 2488 11, 0, 1, 34, 7, 0, 34, 34, 11, 9, |
2480 18, 11, 39, 139, 23, 57, 4, 63, 6, 20, | 2489 0, 4, 0, 34, 7, 4, 14, 21, 34, 15, |
2481 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, | 2490 0, 2, 34, 34, 34, 34, 34, 34, 34, 34, |
2482 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, | 2491 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, |
2483 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, | 2492 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, |
2484 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, | 2493 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, |
2485 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, | 2494 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, |
2486 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, | 2495 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, |
2487 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, | 2496 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, |
2488 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, | 2497 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, |
2489 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, | 2498 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, |
2490 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, | 2499 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, |
2491 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, | 2500 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, |
2492 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, | 2501 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, |
2493 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, | 2502 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, |
2494 139, 139, 139, 139, 139, 139 | 2503 34, 34, 34, 34, 34, 34 |
2495 }; | 2504 }; |
2496 register int hval = len; | 2505 return len + asso_values[(unsigned char)str[1]] + asso_values[(unsigned char)str[0]]; |
2497 | 2506 } |
2498 switch (hval) | 2507 |
2499 { | |
2500 default: | |
2501 case 3: | |
2502 hval += asso_values[(unsigned char)str[2]]; | |
2503 case 2: | |
2504 case 1: | |
2505 hval += asso_values[(unsigned char)str[0]]; | |
2506 break; | |
2507 } | |
2508 return hval; | |
2509 } | |
2510 | |
2511 #ifdef __GNUC__ | |
2512 __inline | |
2513 #endif | |
2514 static struct C_stab_entry * | 2508 static struct C_stab_entry * |
2515 in_word_set (str, len) | 2509 in_word_set (str, len) |
2516 register const char *str; | 2510 register const char *str; |
2517 register unsigned int len; | 2511 register unsigned int len; |
2518 { | 2512 { |
2513 enum | |
2514 { | |
2515 TOTAL_KEYWORDS = 31, | |
2516 MIN_WORD_LENGTH = 2, | |
2517 MAX_WORD_LENGTH = 15, | |
2518 MIN_HASH_VALUE = 3, | |
2519 MAX_HASH_VALUE = 33 | |
2520 }; | |
2521 | |
2519 static struct C_stab_entry wordlist[] = | 2522 static struct C_stab_entry wordlist[] = |
2520 { | 2523 { |
2521 {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, | |
2522 {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, | |
2523 {"if", 0, st_C_ignore}, | |
2524 {""}, {""}, {""}, {""}, | |
2525 {"int", 0, st_C_typespec}, | |
2526 {""}, {""}, | |
2527 {"void", 0, st_C_typespec}, | |
2528 {""}, {""}, | |
2529 {"interface", C_JAVA, st_C_struct}, | |
2530 {""}, | |
2531 {"SYSCALL", 0, st_C_gnumacro}, | |
2532 {""}, | |
2533 {"return", 0, st_C_ignore}, | |
2534 {""}, {""}, {""}, {""}, {""}, {""}, {""}, | |
2535 {"while", 0, st_C_ignore}, | |
2536 {"auto", 0, st_C_typespec}, | |
2537 {""}, {""}, {""}, {""}, {""}, {""}, | |
2538 {"float", 0, st_C_typespec}, | |
2539 {"typedef", 0, st_C_typedef}, | |
2540 {"typename", C_PLPL, st_C_typespec}, | |
2541 {""}, {""}, {""}, | 2524 {""}, {""}, {""}, |
2542 {"friend", C_PLPL, st_C_ignore}, | 2525 {"if", 0, st_C_ignore}, |
2543 {"volatile", 0, st_C_typespec}, | 2526 {"enum", 0, st_C_enum}, |
2544 {""}, {""}, | 2527 {"@end", 0, st_C_objend}, |
2545 {"for", 0, st_C_ignore}, | 2528 {"extern", 0, st_C_extern}, |
2546 {"const", 0, st_C_typespec}, | 2529 {"extends", (C_JAVA & !C_PLPL), st_C_javastruct}, |
2547 {"import", C_JAVA, st_C_ignore}, | 2530 {"for", 0, st_C_ignore}, |
2548 {""}, | 2531 {"interface", (C_JAVA & !C_PLPL), st_C_struct}, |
2549 {"define", 0, st_C_define}, | 2532 {"@protocol", 0, st_C_objprot}, |
2550 {"long", 0, st_C_typespec}, | 2533 {"@interface", 0, st_C_objprot}, |
2551 {"implements", C_JAVA, st_C_javastruct}, | 2534 {"operator", C_PLPL, st_C_operator}, |
2552 {"signed", 0, st_C_typespec}, | 2535 {"return", 0, st_C_ignore}, |
2553 {""}, | 2536 {"friend", C_PLPL, st_C_ignore}, |
2554 {"extern", 0, st_C_extern}, | 2537 {"import", (C_JAVA & !C_PLPL), st_C_ignore}, |
2555 {"extends", C_JAVA, st_C_javastruct}, | 2538 {"@implementation",0, st_C_objimpl}, |
2556 {""}, | 2539 {"define", 0, st_C_define}, |
2557 {"mutable", C_PLPL, st_C_typespec}, | 2540 {"package", (C_JAVA & !C_PLPL), st_C_ignore}, |
2558 {"template", 0, st_C_template}, | 2541 {"implements", (C_JAVA & !C_PLPL), st_C_javastruct}, |
2559 {"short", 0, st_C_typespec}, | 2542 {"namespace", C_PLPL, st_C_struct}, |
2560 {"bool", C_PLPL, st_C_typespec}, | 2543 {"domain", C_STAR, st_C_struct}, |
2561 {"char", 0, st_C_typespec}, | 2544 {"template", 0, st_C_template}, |
2562 {"class", 0, st_C_class}, | 2545 {"typedef", 0, st_C_typedef}, |
2563 {"operator", C_PLPL, st_C_operator}, | 2546 {"struct", 0, st_C_struct}, |
2564 {""}, | 2547 {"switch", 0, st_C_ignore}, |
2565 {"switch", 0, st_C_ignore}, | 2548 {"union", 0, st_C_struct}, |
2566 {""}, | 2549 {"while", 0, st_C_ignore}, |
2567 {"ENTRY", 0, st_C_gnumacro}, | 2550 {"class", 0, st_C_class}, |
2568 {""}, | 2551 {"__attribute__", 0, st_C_attribute}, |
2569 {"package", C_JAVA, st_C_ignore}, | 2552 {"SYSCALL", 0, st_C_gnumacro}, |
2570 {"union", 0, st_C_struct}, | 2553 {"PSEUDO", 0, st_C_gnumacro}, |
2571 {"@end", 0, st_C_objend}, | 2554 {"ENTRY", 0, st_C_gnumacro}, |
2572 {"struct", 0, st_C_struct}, | 2555 {"DEFUN", 0, st_C_gnumacro} |
2573 {"namespace", C_PLPL, st_C_struct}, | |
2574 {""}, {""}, | |
2575 {"domain", C_STAR, st_C_struct}, | |
2576 {"@interface", 0, st_C_objprot}, | |
2577 {"PSEUDO", 0, st_C_gnumacro}, | |
2578 {"double", 0, st_C_typespec}, | |
2579 {""}, | |
2580 {"@protocol", 0, st_C_objprot}, | |
2581 {""}, | |
2582 {"static", 0, st_C_typespec}, | |
2583 {""}, {""}, | |
2584 {"DEFUN", 0, st_C_gnumacro}, | |
2585 {""}, {""}, {""}, {""}, | |
2586 {"explicit", C_PLPL, st_C_typespec}, | |
2587 {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, | |
2588 {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, | |
2589 {""}, | |
2590 {"enum", 0, st_C_enum}, | |
2591 {""}, {""}, | |
2592 {"unsigned", 0, st_C_typespec}, | |
2593 {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, | |
2594 {"@implementation",0, st_C_objimpl} | |
2595 }; | 2556 }; |
2596 | 2557 |
2597 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) | 2558 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) |
2598 { | 2559 { |
2599 register int key = hash (str, len); | 2560 register int key = hash (str, len); |
2600 | 2561 |
2601 if (key <= MAX_HASH_VALUE && key >= 0) | 2562 if (key <= MAX_HASH_VALUE && key >= 0) |
2602 { | 2563 { |
2603 register const char *s = wordlist[key].name; | 2564 register const char *s = wordlist[key].name; |
2604 | 2565 |
2605 if (*str == *s && !strncmp (str + 1, s + 1, len - 1)) | 2566 if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0') |
2606 return &wordlist[key]; | 2567 return &wordlist[key]; |
2607 } | 2568 } |
2608 } | 2569 } |
2609 return 0; | 2570 return 0; |
2610 } | 2571 } |
2622 return st_none; | 2583 return st_none; |
2623 return se->type; | 2584 return se->type; |
2624 } | 2585 } |
2625 | 2586 |
2626 | 2587 |
2588 /* | |
2589 * Ignoring __attribute__ ((list)) | |
2590 */ | |
2591 static bool inattribute; /* looking at an __attribute__ construct */ | |
2592 | |
2627 /* | 2593 /* |
2628 * C functions and variables are recognized using a simple | 2594 * C functions and variables are recognized using a simple |
2629 * finite automaton. fvdef is its state variable. | 2595 * finite automaton. fvdef is its state variable. |
2630 */ | 2596 */ |
2631 static enum | 2597 static enum |
2664 * variable. | 2630 * variable. |
2665 */ | 2631 */ |
2666 static enum | 2632 static enum |
2667 { | 2633 { |
2668 snone, /* nothing seen yet, | 2634 snone, /* nothing seen yet, |
2669 or in struct body if cblev > 0 */ | 2635 or in struct body if bracelev > 0 */ |
2670 skeyseen, /* struct-like keyword seen */ | 2636 skeyseen, /* struct-like keyword seen */ |
2671 stagseen, /* struct-like tag seen */ | 2637 stagseen, /* struct-like tag seen */ |
2672 sintemplate, /* inside template (ignore) */ | |
2673 scolonseen /* colon seen after struct-like tag */ | 2638 scolonseen /* colon seen after struct-like tag */ |
2674 } structdef; | 2639 } structdef; |
2675 | 2640 |
2676 /* | 2641 /* |
2677 * When objdef is different from onone, objtag is the name of the class. | 2642 * When objdef is different from onone, objtag is the name of the class. |
2741 static void popclass_above __P((int)); | 2706 static void popclass_above __P((int)); |
2742 static void write_classname __P((linebuffer *, char *qualifier)); | 2707 static void write_classname __P((linebuffer *, char *qualifier)); |
2743 | 2708 |
2744 static struct { | 2709 static struct { |
2745 char **cname; /* nested class names */ | 2710 char **cname; /* nested class names */ |
2746 int *cblev; /* nested class curly brace level */ | 2711 int *bracelev; /* nested class brace level */ |
2747 int nl; /* class nesting level (elements used) */ | 2712 int nl; /* class nesting level (elements used) */ |
2748 int size; /* length of the array */ | 2713 int size; /* length of the array */ |
2749 } cstack; /* stack for nested declaration tags */ | 2714 } cstack; /* stack for nested declaration tags */ |
2750 /* Current struct nesting depth (namespace, class, struct, union, enum). */ | 2715 /* Current struct nesting depth (namespace, class, struct, union, enum). */ |
2751 #define nestlev (cstack.nl) | 2716 #define nestlev (cstack.nl) |
2752 /* After struct keyword or in struct body, not inside a nested function. */ | 2717 /* After struct keyword or in struct body, not inside a nested function. */ |
2753 #define instruct (structdef == snone && nestlev > 0 \ | 2718 #define instruct (structdef == snone && nestlev > 0 \ |
2754 && cblev == cstack.cblev[nestlev-1] + 1) | 2719 && bracelev == cstack.bracelev[nestlev-1] + 1) |
2755 | 2720 |
2756 static void | 2721 static void |
2757 pushclass_above (cblev, str, len) | 2722 pushclass_above (bracelev, str, len) |
2758 int cblev; | 2723 int bracelev; |
2759 char *str; | 2724 char *str; |
2760 int len; | 2725 int len; |
2761 { | 2726 { |
2762 int nl; | 2727 int nl; |
2763 | 2728 |
2764 popclass_above (cblev); | 2729 popclass_above (bracelev); |
2765 nl = cstack.nl; | 2730 nl = cstack.nl; |
2766 if (nl >= cstack.size) | 2731 if (nl >= cstack.size) |
2767 { | 2732 { |
2768 int size = cstack.size *= 2; | 2733 int size = cstack.size *= 2; |
2769 xrnew (cstack.cname, size, char *); | 2734 xrnew (cstack.cname, size, char *); |
2770 xrnew (cstack.cblev, size, int); | 2735 xrnew (cstack.bracelev, size, int); |
2771 } | 2736 } |
2772 assert (nl == 0 || cstack.cblev[nl-1] < cblev); | 2737 assert (nl == 0 || cstack.bracelev[nl-1] < bracelev); |
2773 cstack.cname[nl] = (str == NULL) ? NULL : savenstr (str, len); | 2738 cstack.cname[nl] = (str == NULL) ? NULL : savenstr (str, len); |
2774 cstack.cblev[nl] = cblev; | 2739 cstack.bracelev[nl] = bracelev; |
2775 cstack.nl = nl + 1; | 2740 cstack.nl = nl + 1; |
2776 } | 2741 } |
2777 | 2742 |
2778 static void | 2743 static void |
2779 popclass_above (cblev) | 2744 popclass_above (bracelev) |
2780 int cblev; | 2745 int bracelev; |
2781 { | 2746 { |
2782 int nl; | 2747 int nl; |
2783 | 2748 |
2784 for (nl = cstack.nl - 1; | 2749 for (nl = cstack.nl - 1; |
2785 nl >= 0 && cstack.cblev[nl] >= cblev; | 2750 nl >= 0 && cstack.bracelev[nl] >= bracelev; |
2786 nl--) | 2751 nl--) |
2787 { | 2752 { |
2788 if (cstack.cname[nl] != NULL) | 2753 if (cstack.cname[nl] != NULL) |
2789 free (cstack.cname[nl]); | 2754 free (cstack.cname[nl]); |
2790 cstack.nl = nl; | 2755 cstack.nl = nl; |
2847 * typdef IN OUT | 2812 * typdef IN OUT |
2848 * objdef IN OUT | 2813 * objdef IN OUT |
2849 */ | 2814 */ |
2850 | 2815 |
2851 static bool | 2816 static bool |
2852 consider_token (str, len, c, c_extp, cblev, parlev, is_func_or_var) | 2817 consider_token (str, len, c, c_extp, bracelev, parlev, is_func_or_var) |
2853 register char *str; /* IN: token pointer */ | 2818 register char *str; /* IN: token pointer */ |
2854 register int len; /* IN: token length */ | 2819 register int len; /* IN: token length */ |
2855 register int c; /* IN: first char after the token */ | 2820 register int c; /* IN: first char after the token */ |
2856 int *c_extp; /* IN, OUT: C extensions mask */ | 2821 int *c_extp; /* IN, OUT: C extensions mask */ |
2857 int cblev; /* IN: curly brace level */ | 2822 int bracelev; /* IN: brace level */ |
2858 int parlev; /* IN: parenthesis level */ | 2823 int parlev; /* IN: parenthesis level */ |
2859 bool *is_func_or_var; /* OUT: function or variable found */ | 2824 bool *is_func_or_var; /* OUT: function or variable found */ |
2860 { | 2825 { |
2861 /* When structdef is stagseen, scolonseen, or snone with cblev > 0, | 2826 /* When structdef is stagseen, scolonseen, or snone with bracelev > 0, |
2862 structtype is the type of the preceding struct-like keyword, and | 2827 structtype is the type of the preceding struct-like keyword, and |
2863 structcblev is the curly brace level where it has been seen. */ | 2828 structbracelev is the brace level where it has been seen. */ |
2864 static enum sym_type structtype; | 2829 static enum sym_type structtype; |
2865 static int structcblev; | 2830 static int structbracelev; |
2866 static enum sym_type toktype; | 2831 static enum sym_type toktype; |
2867 | 2832 |
2868 | 2833 |
2869 toktype = C_symtype (str, len, *c_extp); | 2834 toktype = C_symtype (str, len, *c_extp); |
2870 | 2835 |
2871 /* | 2836 /* |
2872 * Advance the definedef state machine. | 2837 * Skip __attribute__ |
2873 */ | 2838 */ |
2874 switch (definedef) | 2839 if (toktype == st_C_attribute) |
2875 { | 2840 { |
2876 case dnone: | 2841 inattribute = TRUE; |
2877 /* We're not on a preprocessor line. */ | |
2878 if (toktype == st_C_gnumacro) | |
2879 { | |
2880 fvdef = fdefunkey; | |
2881 return FALSE; | |
2882 } | |
2883 break; | |
2884 case dsharpseen: | |
2885 if (toktype == st_C_define) | |
2886 { | |
2887 definedef = ddefineseen; | |
2888 } | |
2889 else | |
2890 { | |
2891 definedef = dignorerest; | |
2892 } | |
2893 return FALSE; | 2842 return FALSE; |
2894 case ddefineseen: | 2843 } |
2895 /* | 2844 |
2896 * Make a tag for any macro, unless it is a constant | 2845 /* |
2897 * and constantypedefs is FALSE. | 2846 * Advance the definedef state machine. |
2898 */ | 2847 */ |
2899 definedef = dignorerest; | 2848 switch (definedef) |
2900 *is_func_or_var = (c == '('); | 2849 { |
2901 if (!*is_func_or_var && !constantypedefs) | 2850 case dnone: |
2902 return FALSE; | 2851 /* We're not on a preprocessor line. */ |
2903 else | 2852 if (toktype == st_C_gnumacro) |
2904 return TRUE; | 2853 { |
2905 case dignorerest: | 2854 fvdef = fdefunkey; |
2906 return FALSE; | 2855 return FALSE; |
2907 default: | 2856 } |
2908 error ("internal error: definedef value.", (char *)NULL); | 2857 break; |
2909 } | 2858 case dsharpseen: |
2910 | 2859 if (toktype == st_C_define) |
2911 /* | 2860 { |
2912 * Now typedefs | 2861 definedef = ddefineseen; |
2913 */ | 2862 } |
2914 switch (typdef) | 2863 else |
2915 { | 2864 { |
2916 case tnone: | 2865 definedef = dignorerest; |
2917 if (toktype == st_C_typedef) | 2866 } |
2918 { | 2867 return FALSE; |
2919 if (typedefs) | 2868 case ddefineseen: |
2920 typdef = tkeyseen; | 2869 /* |
2921 fvextern = FALSE; | 2870 * Make a tag for any macro, unless it is a constant |
2922 fvdef = fvnone; | 2871 * and constantypedefs is FALSE. |
2923 return FALSE; | 2872 */ |
2924 } | 2873 definedef = dignorerest; |
2925 break; | 2874 *is_func_or_var = (c == '('); |
2926 case tkeyseen: | 2875 if (!*is_func_or_var && !constantypedefs) |
2927 switch (toktype) | 2876 return FALSE; |
2928 { | 2877 else |
2929 case st_none: | 2878 return TRUE; |
2930 case st_C_typespec: | 2879 case dignorerest: |
2931 case st_C_class: | 2880 return FALSE; |
2932 case st_C_struct: | 2881 default: |
2933 case st_C_enum: | 2882 error ("internal error: definedef value.", (char *)NULL); |
2934 typdef = ttypeseen; | 2883 } |
2935 break; | 2884 |
2936 } | 2885 /* |
2937 break; | 2886 * Now typedefs |
2938 case ttypeseen: | 2887 */ |
2939 if (structdef == snone && fvdef == fvnone) | 2888 switch (typdef) |
2940 { | 2889 { |
2941 fvdef = fvnameseen; | 2890 case tnone: |
2942 return TRUE; | 2891 if (toktype == st_C_typedef) |
2943 } | 2892 { |
2944 break; | 2893 if (typedefs) |
2945 case tend: | 2894 typdef = tkeyseen; |
2946 switch (toktype) | 2895 fvextern = FALSE; |
2947 { | 2896 fvdef = fvnone; |
2948 case st_C_typespec: | 2897 return FALSE; |
2949 case st_C_class: | 2898 } |
2950 case st_C_struct: | 2899 break; |
2951 case st_C_enum: | 2900 case tkeyseen: |
2952 return FALSE; | 2901 switch (toktype) |
2953 } | 2902 { |
2954 return TRUE; | 2903 case st_none: |
2955 } | 2904 case st_C_class: |
2956 | 2905 case st_C_struct: |
2957 /* | 2906 case st_C_enum: |
2958 * This structdef business is NOT invoked when we are ctags and the | 2907 typdef = ttypeseen; |
2959 * file is plain C. This is because a struct tag may have the same | 2908 } |
2960 * name as another tag, and this loses with ctags. | 2909 break; |
2961 */ | 2910 case ttypeseen: |
2962 switch (toktype) | 2911 if (structdef == snone && fvdef == fvnone) |
2963 { | 2912 { |
2964 case st_C_javastruct: | 2913 fvdef = fvnameseen; |
2965 if (structdef == stagseen) | 2914 return TRUE; |
2966 structdef = scolonseen; | 2915 } |
2967 return FALSE; | 2916 break; |
2968 case st_C_template: | 2917 case tend: |
2969 case st_C_class: | 2918 switch (toktype) |
2970 if ((*c_extp & C_AUTO) /* automatic detection of C++ language */ | 2919 { |
2971 && cblev == 0 | 2920 case st_C_class: |
2972 && definedef == dnone && structdef == snone | 2921 case st_C_struct: |
2973 && typdef == tnone && fvdef == fvnone) | 2922 case st_C_enum: |
2974 *c_extp = (*c_extp | C_PLPL) & ~C_AUTO; | 2923 return FALSE; |
2975 if (toktype == st_C_template) | 2924 } |
2976 break; | 2925 return TRUE; |
2977 /* FALLTHRU */ | 2926 } |
2978 case st_C_struct: | 2927 |
2979 case st_C_enum: | 2928 /* |
2980 if (parlev == 0 | 2929 * This structdef business is NOT invoked when we are ctags and the |
2981 && fvdef != vignore | 2930 * file is plain C. This is because a struct tag may have the same |
2982 && (typdef == tkeyseen | 2931 * name as another tag, and this loses with ctags. |
2983 || (typedefs_or_cplusplus && structdef == snone))) | 2932 */ |
2984 { | 2933 switch (toktype) |
2985 structdef = skeyseen; | 2934 { |
2986 structtype = toktype; | 2935 case st_C_javastruct: |
2987 structcblev = cblev; | 2936 if (structdef == stagseen) |
2988 } | 2937 structdef = scolonseen; |
2989 return FALSE; | 2938 return FALSE; |
2990 } | 2939 case st_C_template: |
2991 | 2940 case st_C_class: |
2992 if (structdef == skeyseen) | 2941 if ((*c_extp & C_AUTO) /* automatic detection of C++ language */ |
2993 { | 2942 && bracelev == 0 |
2994 structdef = stagseen; | 2943 && definedef == dnone && structdef == snone |
2995 return TRUE; | 2944 && typdef == tnone && fvdef == fvnone) |
2996 } | 2945 *c_extp = (*c_extp | C_PLPL) & ~C_AUTO; |
2997 | 2946 if (toktype == st_C_template) |
2998 if (typdef != tnone) | 2947 break; |
2999 definedef = dnone; | 2948 /* FALLTHRU */ |
3000 | 2949 case st_C_struct: |
3001 /* Detect Objective C constructs. */ | 2950 case st_C_enum: |
3002 switch (objdef) | 2951 if (parlev == 0 |
3003 { | 2952 && fvdef != vignore |
3004 case onone: | 2953 && (typdef == tkeyseen |
3005 switch (toktype) | 2954 || (typedefs_or_cplusplus && structdef == snone))) |
3006 { | 2955 { |
3007 case st_C_objprot: | 2956 structdef = skeyseen; |
3008 objdef = oprotocol; | 2957 structtype = toktype; |
3009 return FALSE; | 2958 structbracelev = bracelev; |
3010 case st_C_objimpl: | 2959 if (fvdef == fvnameseen) |
3011 objdef = oimplementation; | 2960 fvdef = fvnone; |
3012 return FALSE; | 2961 } |
3013 } | 2962 return FALSE; |
3014 break; | 2963 } |
3015 case oimplementation: | 2964 |
3016 /* Save the class tag for functions or variables defined inside. */ | 2965 if (structdef == skeyseen) |
3017 objtag = savenstr (str, len); | 2966 { |
3018 objdef = oinbody; | 2967 structdef = stagseen; |
3019 return FALSE; | 2968 return TRUE; |
3020 case oprotocol: | 2969 } |
3021 /* Save the class tag for categories. */ | 2970 |
3022 objtag = savenstr (str, len); | 2971 if (typdef != tnone) |
3023 objdef = otagseen; | 2972 definedef = dnone; |
3024 *is_func_or_var = TRUE; | 2973 |
3025 return TRUE; | 2974 /* Detect Objective C constructs. */ |
3026 case oparenseen: | 2975 switch (objdef) |
3027 objdef = ocatseen; | 2976 { |
3028 *is_func_or_var = TRUE; | 2977 case onone: |
3029 return TRUE; | 2978 switch (toktype) |
3030 case oinbody: | 2979 { |
3031 break; | 2980 case st_C_objprot: |
3032 case omethodsign: | 2981 objdef = oprotocol; |
3033 if (parlev == 0) | 2982 return FALSE; |
3034 { | 2983 case st_C_objimpl: |
3035 objdef = omethodtag; | 2984 objdef = oimplementation; |
3036 linebuffer_setlen (&token_name, len); | 2985 return FALSE; |
3037 strncpy (token_name.buffer, str, len); | 2986 } |
3038 token_name.buffer[len] = '\0'; | 2987 break; |
3039 return TRUE; | 2988 case oimplementation: |
3040 } | 2989 /* Save the class tag for functions or variables defined inside. */ |
3041 return FALSE; | 2990 objtag = savenstr (str, len); |
3042 case omethodcolon: | 2991 objdef = oinbody; |
3043 if (parlev == 0) | 2992 return FALSE; |
3044 objdef = omethodparm; | 2993 case oprotocol: |
3045 return FALSE; | 2994 /* Save the class tag for categories. */ |
3046 case omethodparm: | 2995 objtag = savenstr (str, len); |
3047 if (parlev == 0) | 2996 objdef = otagseen; |
3048 { | 2997 *is_func_or_var = TRUE; |
3049 objdef = omethodtag; | 2998 return TRUE; |
3050 linebuffer_setlen (&token_name, token_name.len + len); | 2999 case oparenseen: |
3051 strncat (token_name.buffer, str, len); | 3000 objdef = ocatseen; |
3052 return TRUE; | 3001 *is_func_or_var = TRUE; |
3053 } | 3002 return TRUE; |
3054 return FALSE; | 3003 case oinbody: |
3055 case oignore: | 3004 break; |
3056 if (toktype == st_C_objend) | 3005 case omethodsign: |
3057 { | 3006 if (parlev == 0) |
3058 /* Memory leakage here: the string pointed by objtag is | 3007 { |
3059 never released, because many tests would be needed to | 3008 fvdef = fvnone; |
3060 avoid breaking on incorrect input code. The amount of | 3009 objdef = omethodtag; |
3061 memory leaked here is the sum of the lengths of the | 3010 linebuffer_setlen (&token_name, len); |
3062 class tags. | 3011 strncpy (token_name.buffer, str, len); |
3063 free (objtag); */ | 3012 token_name.buffer[len] = '\0'; |
3064 objdef = onone; | 3013 return TRUE; |
3065 } | 3014 } |
3066 return FALSE; | 3015 return FALSE; |
3067 } | 3016 case omethodcolon: |
3068 | 3017 if (parlev == 0) |
3069 /* A function, variable or enum constant? */ | 3018 objdef = omethodparm; |
3070 switch (toktype) | 3019 return FALSE; |
3071 { | 3020 case omethodparm: |
3072 case st_C_extern: | 3021 if (parlev == 0) |
3073 fvextern = TRUE; | 3022 { |
3074 /* FALLTHRU */ | 3023 fvdef = fvnone; |
3075 case st_C_typespec: | 3024 objdef = omethodtag; |
3076 switch (fvdef) | 3025 linebuffer_setlen (&token_name, token_name.len + len); |
3077 { | 3026 strncat (token_name.buffer, str, len); |
3078 case finlist: | 3027 return TRUE; |
3079 case flistseen: | 3028 } |
3080 case fignore: | 3029 return FALSE; |
3081 case vignore: | 3030 case oignore: |
3082 break; | 3031 if (toktype == st_C_objend) |
3083 default: | 3032 { |
3084 fvdef = fvnone; | 3033 /* Memory leakage here: the string pointed by objtag is |
3085 } | 3034 never released, because many tests would be needed to |
3086 return FALSE; | 3035 avoid breaking on incorrect input code. The amount of |
3087 case st_C_ignore: | 3036 memory leaked here is the sum of the lengths of the |
3088 fvextern = FALSE; | 3037 class tags. |
3089 fvdef = vignore; | 3038 free (objtag); */ |
3090 return FALSE; | 3039 objdef = onone; |
3091 case st_C_operator: | 3040 } |
3092 fvdef = foperator; | 3041 return FALSE; |
3093 *is_func_or_var = TRUE; | 3042 } |
3094 return TRUE; | 3043 |
3095 case st_none: | 3044 /* A function, variable or enum constant? */ |
3096 if (constantypedefs | 3045 switch (toktype) |
3097 && structdef == snone | 3046 { |
3098 && structtype == st_C_enum && cblev > structcblev) | 3047 case st_C_extern: |
3099 return TRUE; /* enum constant */ | 3048 fvextern = TRUE; |
3100 switch (fvdef) | 3049 switch (fvdef) |
3101 { | 3050 { |
3102 case fdefunkey: | 3051 case finlist: |
3103 if (cblev > 0) | 3052 case flistseen: |
3104 break; | 3053 case fignore: |
3105 fvdef = fdefunname; /* GNU macro */ | 3054 case vignore: |
3106 *is_func_or_var = TRUE; | 3055 break; |
3107 return TRUE; | 3056 default: |
3108 case fvnone: | 3057 fvdef = fvnone; |
3109 if ((strneq (str, "asm", 3) && endtoken (str[3])) | 3058 } |
3110 || (strneq (str, "__asm__", 7) && endtoken (str[7]))) | 3059 return FALSE; |
3111 { | 3060 case st_C_ignore: |
3112 fvdef = vignore; | 3061 fvextern = FALSE; |
3113 return FALSE; | 3062 fvdef = vignore; |
3114 } | 3063 return FALSE; |
3064 case st_C_operator: | |
3065 fvdef = foperator; | |
3066 *is_func_or_var = TRUE; | |
3067 return TRUE; | |
3068 case st_none: | |
3069 if (constantypedefs | |
3070 && structdef == snone | |
3071 && structtype == st_C_enum && bracelev > structbracelev) | |
3072 return TRUE; /* enum constant */ | |
3073 switch (fvdef) | |
3074 { | |
3075 case fdefunkey: | |
3076 if (bracelev > 0) | |
3077 break; | |
3078 fvdef = fdefunname; /* GNU macro */ | |
3079 *is_func_or_var = TRUE; | |
3080 return TRUE; | |
3081 case fvnone: | |
3082 switch (typdef) | |
3083 { | |
3084 case ttypeseen: | |
3085 return FALSE; | |
3086 case tnone: | |
3087 if ((strneq (str, "asm", 3) && endtoken (str[3])) | |
3088 || (strneq (str, "__asm__", 7) && endtoken (str[7]))) | |
3089 { | |
3090 fvdef = vignore; | |
3091 return FALSE; | |
3092 } | |
3093 break; | |
3094 } | |
3095 /* FALLTHRU */ | |
3096 case fvnameseen: | |
3115 if (len >= 10 && strneq (str+len-10, "::operator", 10)) | 3097 if (len >= 10 && strneq (str+len-10, "::operator", 10)) |
3116 { | 3098 { |
3117 if (*c_extp & C_AUTO) /* automatic detection of C++ */ | 3099 if (*c_extp & C_AUTO) /* automatic detection of C++ */ |
3118 *c_extp = (*c_extp | C_PLPL) & ~C_AUTO; | 3100 *c_extp = (*c_extp | C_PLPL) & ~C_AUTO; |
3119 fvdef = foperator; | 3101 fvdef = foperator; |
3120 *is_func_or_var = TRUE; | 3102 *is_func_or_var = TRUE; |
3121 return TRUE; | 3103 return TRUE; |
3122 } | 3104 } |
3123 if (cblev > 0 && !instruct) | 3105 if (bracelev > 0 && !instruct) |
3124 break; | 3106 break; |
3125 fvdef = fvnameseen; /* function or variable */ | 3107 fvdef = fvnameseen; /* function or variable */ |
3126 *is_func_or_var = TRUE; | 3108 *is_func_or_var = TRUE; |
3127 return TRUE; | 3109 return TRUE; |
3128 } | 3110 } |
3214 int curndx, newndx; /* indices for current and new lb */ | 3196 int curndx, newndx; /* indices for current and new lb */ |
3215 register int tokoff; /* offset in line of start of current token */ | 3197 register int tokoff; /* offset in line of start of current token */ |
3216 register int toklen; /* length of current token */ | 3198 register int toklen; /* length of current token */ |
3217 char *qualifier; /* string used to qualify names */ | 3199 char *qualifier; /* string used to qualify names */ |
3218 int qlen; /* length of qualifier */ | 3200 int qlen; /* length of qualifier */ |
3219 int cblev; /* current curly brace level */ | 3201 int bracelev; /* current brace level */ |
3202 int bracketlev; /* current bracket level */ | |
3220 int parlev; /* current parenthesis level */ | 3203 int parlev; /* current parenthesis level */ |
3221 int typdefcblev; /* cblev where a typedef struct body begun */ | 3204 int attrparlev; /* __attribute__ parenthesis level */ |
3205 int templatelev; /* current template level */ | |
3206 int typdefbracelev; /* bracelev where a typedef struct body begun */ | |
3222 bool incomm, inquote, inchar, quotednl, midtoken; | 3207 bool incomm, inquote, inchar, quotednl, midtoken; |
3223 bool yacc_rules; /* in the rules part of a yacc file */ | 3208 bool yacc_rules; /* in the rules part of a yacc file */ |
3224 struct tok savetoken; /* token saved during preprocessor handling */ | 3209 struct tok savetoken; /* token saved during preprocessor handling */ |
3225 | 3210 |
3226 | 3211 |
3229 if (cstack.size == 0) | 3214 if (cstack.size == 0) |
3230 { | 3215 { |
3231 cstack.size = (DEBUG) ? 1 : 4; | 3216 cstack.size = (DEBUG) ? 1 : 4; |
3232 cstack.nl = 0; | 3217 cstack.nl = 0; |
3233 cstack.cname = xnew (cstack.size, char *); | 3218 cstack.cname = xnew (cstack.size, char *); |
3234 cstack.cblev = xnew (cstack.size, int); | 3219 cstack.bracelev = xnew (cstack.size, int); |
3235 } | 3220 } |
3236 | 3221 |
3237 tokoff = toklen = typdefcblev = 0; /* keep compiler quiet */ | 3222 tokoff = toklen = typdefbracelev = 0; /* keep compiler quiet */ |
3238 curndx = newndx = 0; | 3223 curndx = newndx = 0; |
3239 lp = curlb.buffer; | 3224 lp = curlb.buffer; |
3240 *lp = 0; | 3225 *lp = 0; |
3241 | 3226 |
3242 fvdef = fvnone; fvextern = FALSE; typdef = tnone; | 3227 fvdef = fvnone; fvextern = FALSE; typdef = tnone; |
3243 structdef = snone; definedef = dnone; objdef = onone; | 3228 structdef = snone; definedef = dnone; objdef = onone; |
3244 yacc_rules = FALSE; | 3229 yacc_rules = FALSE; |
3245 midtoken = inquote = inchar = incomm = quotednl = FALSE; | 3230 midtoken = inquote = inchar = incomm = quotednl = FALSE; |
3246 token.valid = savetoken.valid = FALSE; | 3231 token.valid = savetoken.valid = FALSE; |
3247 cblev = 0; | 3232 bracelev = bracketlev = parlev = attrparlev = templatelev = 0; |
3248 parlev = 0; | |
3249 if (cjava) | 3233 if (cjava) |
3250 { qualifier = "."; qlen = 1; } | 3234 { qualifier = "."; qlen = 1; } |
3251 else | 3235 else |
3252 { qualifier = "::"; qlen = 2; } | 3236 { qualifier = "::"; qlen = 2; } |
3253 | 3237 |
3255 while (!feof (inf)) | 3239 while (!feof (inf)) |
3256 { | 3240 { |
3257 c = *lp++; | 3241 c = *lp++; |
3258 if (c == '\\') | 3242 if (c == '\\') |
3259 { | 3243 { |
3260 /* If we're at the end of the line, the next character is a | 3244 /* If we are at the end of the line, the next character is a |
3261 '\0'; don't skip it, because it's the thing that tells us | 3245 '\0'; do not skip it, because it is what tells us |
3262 to read the next line. */ | 3246 to read the next line. */ |
3263 if (*lp == '\0') | 3247 if (*lp == '\0') |
3264 { | 3248 { |
3265 quotednl = TRUE; | 3249 quotednl = TRUE; |
3266 continue; | 3250 continue; |
3315 inchar = FALSE; | 3299 inchar = FALSE; |
3316 break; | 3300 break; |
3317 } | 3301 } |
3318 continue; | 3302 continue; |
3319 } | 3303 } |
3320 else | 3304 else if (bracketlev > 0) |
3321 switch (c) | 3305 { |
3322 { | 3306 switch (c) |
3323 case '"': | 3307 { |
3324 inquote = TRUE; | 3308 case ']': |
3325 switch (fvdef) | 3309 if (--bracketlev > 0) |
3326 { | 3310 continue; |
3327 case fdefunkey: | 3311 break; |
3328 case fstartlist: | 3312 case '\0': |
3329 case finlist: | 3313 CNL_SAVE_DEFINEDEF (); |
3330 case fignore: | 3314 break; |
3331 case vignore: | 3315 } |
3332 break; | 3316 continue; |
3333 default: | 3317 } |
3334 fvextern = FALSE; | 3318 else switch (c) |
3335 fvdef = fvnone; | 3319 { |
3336 } | 3320 case '"': |
3321 inquote = TRUE; | |
3322 if (inattribute) | |
3323 break; | |
3324 switch (fvdef) | |
3325 { | |
3326 case fdefunkey: | |
3327 case fstartlist: | |
3328 case finlist: | |
3329 case fignore: | |
3330 case vignore: | |
3331 break; | |
3332 default: | |
3333 fvextern = FALSE; | |
3334 fvdef = fvnone; | |
3335 } | |
3336 continue; | |
3337 case '\'': | |
3338 inchar = TRUE; | |
3339 if (inattribute) | |
3340 break; | |
3341 if (fvdef != finlist && fvdef != fignore && fvdef !=vignore) | |
3342 { | |
3343 fvextern = FALSE; | |
3344 fvdef = fvnone; | |
3345 } | |
3346 continue; | |
3347 case '/': | |
3348 if (*lp == '*') | |
3349 { | |
3350 lp++; | |
3351 incomm = TRUE; | |
3352 continue; | |
3353 } | |
3354 else if (/* cplpl && */ *lp == '/') | |
3355 { | |
3356 c = '\0'; | |
3357 break; | |
3358 } | |
3359 else | |
3360 break; | |
3361 case '%': | |
3362 if ((c_ext & YACC) && *lp == '%') | |
3363 { | |
3364 /* Entering or exiting rules section in yacc file. */ | |
3365 lp++; | |
3366 definedef = dnone; fvdef = fvnone; fvextern = FALSE; | |
3367 typdef = tnone; structdef = snone; | |
3368 midtoken = inquote = inchar = incomm = quotednl = FALSE; | |
3369 bracelev = 0; | |
3370 yacc_rules = !yacc_rules; | |
3371 continue; | |
3372 } | |
3373 else | |
3374 break; | |
3375 case '#': | |
3376 if (definedef == dnone) | |
3377 { | |
3378 char *cp; | |
3379 bool cpptoken = TRUE; | |
3380 | |
3381 /* Look back on this line. If all blanks, or nonblanks | |
3382 followed by an end of comment, this is a preprocessor | |
3383 token. */ | |
3384 for (cp = newlb.buffer; cp < lp-1; cp++) | |
3385 if (!iswhite (*cp)) | |
3386 { | |
3387 if (*cp == '*' && *(cp+1) == '/') | |
3388 { | |
3389 cp++; | |
3390 cpptoken = TRUE; | |
3391 } | |
3392 else | |
3393 cpptoken = FALSE; | |
3394 } | |
3395 if (cpptoken) | |
3396 definedef = dsharpseen; | |
3397 } /* if (definedef == dnone) */ | |
3398 continue; | |
3399 case '[': | |
3400 bracketlev++; | |
3337 continue; | 3401 continue; |
3338 case '\'': | 3402 } /* switch (c) */ |
3339 inchar = TRUE; | |
3340 if (fvdef != finlist && fvdef != fignore && fvdef !=vignore) | |
3341 { | |
3342 fvextern = FALSE; | |
3343 fvdef = fvnone; | |
3344 } | |
3345 continue; | |
3346 case '/': | |
3347 if (*lp == '*') | |
3348 { | |
3349 lp++; | |
3350 incomm = TRUE; | |
3351 continue; | |
3352 } | |
3353 else if (/* cplpl && */ *lp == '/') | |
3354 { | |
3355 c = '\0'; | |
3356 break; | |
3357 } | |
3358 else | |
3359 break; | |
3360 case '%': | |
3361 if ((c_ext & YACC) && *lp == '%') | |
3362 { | |
3363 /* Entering or exiting rules section in yacc file. */ | |
3364 lp++; | |
3365 definedef = dnone; fvdef = fvnone; fvextern = FALSE; | |
3366 typdef = tnone; structdef = snone; | |
3367 midtoken = inquote = inchar = incomm = quotednl = FALSE; | |
3368 cblev = 0; | |
3369 yacc_rules = !yacc_rules; | |
3370 continue; | |
3371 } | |
3372 else | |
3373 break; | |
3374 case '#': | |
3375 if (definedef == dnone) | |
3376 { | |
3377 char *cp; | |
3378 bool cpptoken = TRUE; | |
3379 | |
3380 /* Look back on this line. If all blanks, or nonblanks | |
3381 followed by an end of comment, this is a preprocessor | |
3382 token. */ | |
3383 for (cp = newlb.buffer; cp < lp-1; cp++) | |
3384 if (!iswhite (*cp)) | |
3385 { | |
3386 if (*cp == '*' && *(cp+1) == '/') | |
3387 { | |
3388 cp++; | |
3389 cpptoken = TRUE; | |
3390 } | |
3391 else | |
3392 cpptoken = FALSE; | |
3393 } | |
3394 if (cpptoken) | |
3395 definedef = dsharpseen; | |
3396 } /* if (definedef == dnone) */ | |
3397 | |
3398 continue; | |
3399 } /* switch (c) */ | |
3400 | 3403 |
3401 | 3404 |
3402 /* Consider token only if some involved conditions are satisfied. */ | 3405 /* Consider token only if some involved conditions are satisfied. */ |
3403 if (typdef != tignore | 3406 if (typdef != tignore |
3404 && definedef != dignorerest | 3407 && definedef != dignorerest |
3405 && fvdef != finlist | 3408 && fvdef != finlist |
3406 && structdef != sintemplate | 3409 && templatelev == 0 |
3407 && (definedef != dnone | 3410 && (definedef != dnone |
3408 || structdef != scolonseen)) | 3411 || structdef != scolonseen) |
3412 && !inattribute) | |
3409 { | 3413 { |
3410 if (midtoken) | 3414 if (midtoken) |
3411 { | 3415 { |
3412 if (endtoken (c)) | 3416 if (endtoken (c)) |
3413 { | 3417 { |
3427 { | 3431 { |
3428 bool funorvar = FALSE; | 3432 bool funorvar = FALSE; |
3429 | 3433 |
3430 if (yacc_rules | 3434 if (yacc_rules |
3431 || consider_token (newlb.buffer + tokoff, toklen, c, | 3435 || consider_token (newlb.buffer + tokoff, toklen, c, |
3432 &c_ext, cblev, parlev, &funorvar)) | 3436 &c_ext, bracelev, parlev, |
3437 &funorvar)) | |
3433 { | 3438 { |
3434 if (fvdef == foperator) | 3439 if (fvdef == foperator) |
3435 { | 3440 { |
3436 char *oldlp = lp; | 3441 char *oldlp = lp; |
3437 lp = skip_spaces (lp-1); | 3442 lp = skip_spaces (lp-1); |
3512 || (funorvar | 3517 || (funorvar |
3513 && definedef == dignorerest) | 3518 && definedef == dignorerest) |
3514 || (funorvar | 3519 || (funorvar |
3515 && definedef == dnone | 3520 && definedef == dnone |
3516 && structdef == snone | 3521 && structdef == snone |
3517 && cblev > 0)); | 3522 && bracelev > 0)); |
3518 } | 3523 } |
3519 token.lineno = lineno; | 3524 token.lineno = lineno; |
3520 token.offset = tokoff; | 3525 token.offset = tokoff; |
3521 token.length = toklen; | 3526 token.length = toklen; |
3522 token.line = newlb.buffer; | 3527 token.line = newlb.buffer; |
3537 else if (definedef != dnone | 3542 else if (definedef != dnone |
3538 || fvdef == fdefunname | 3543 || fvdef == fdefunname |
3539 || instruct) | 3544 || instruct) |
3540 make_C_tag (funorvar); | 3545 make_C_tag (funorvar); |
3541 } | 3546 } |
3547 else /* not yacc and consider_token failed */ | |
3548 { | |
3549 if (inattribute && fvdef == fignore) | |
3550 { | |
3551 /* We have just met __attribute__ after a | |
3552 function parameter list: do not tag the | |
3553 function again. */ | |
3554 fvdef = fvnone; | |
3555 } | |
3556 } | |
3542 midtoken = FALSE; | 3557 midtoken = FALSE; |
3543 } | 3558 } |
3544 } /* if (endtoken (c)) */ | 3559 } /* if (endtoken (c)) */ |
3545 else if (intoken (c)) | 3560 else if (intoken (c)) |
3546 still_in_token: | 3561 still_in_token: |
3555 { | 3570 { |
3556 case dnone: | 3571 case dnone: |
3557 switch (fvdef) | 3572 switch (fvdef) |
3558 { | 3573 { |
3559 case fstartlist: | 3574 case fstartlist: |
3575 /* This prevents tagging fb in | |
3576 void (__attribute__((noreturn)) *fb) (void); | |
3577 Fixing this is not easy and not very important. */ | |
3560 fvdef = finlist; | 3578 fvdef = finlist; |
3561 continue; | 3579 continue; |
3562 case flistseen: | 3580 case flistseen: |
3563 if (plainc || declarations) | 3581 if (plainc || declarations) |
3564 { | 3582 { |
3565 make_C_tag (TRUE); /* a function */ | 3583 make_C_tag (TRUE); /* a function */ |
3566 fvdef = fignore; | 3584 fvdef = fignore; |
3567 } | 3585 } |
3568 break; | 3586 break; |
3569 case fvnameseen: | |
3570 fvdef = fvnone; | |
3571 break; | |
3572 } | 3587 } |
3573 if (structdef == stagseen && !cjava) | 3588 if (structdef == stagseen && !cjava) |
3574 { | 3589 { |
3575 popclass_above (cblev); | 3590 popclass_above (bracelev); |
3576 structdef = snone; | 3591 structdef = snone; |
3577 } | 3592 } |
3578 break; | 3593 break; |
3579 case dsharpseen: | 3594 case dsharpseen: |
3580 savetoken = token; | 3595 savetoken = token; |
3594 /* Detect end of line, colon, comma, semicolon and various braces | 3609 /* Detect end of line, colon, comma, semicolon and various braces |
3595 after having handled a token.*/ | 3610 after having handled a token.*/ |
3596 switch (c) | 3611 switch (c) |
3597 { | 3612 { |
3598 case ':': | 3613 case ':': |
3614 if (inattribute) | |
3615 break; | |
3599 if (yacc_rules && token.offset == 0 && token.valid) | 3616 if (yacc_rules && token.offset == 0 && token.valid) |
3600 { | 3617 { |
3601 make_C_tag (FALSE); /* a yacc function */ | 3618 make_C_tag (FALSE); /* a yacc function */ |
3602 break; | 3619 break; |
3603 } | 3620 } |
3628 fvdef = fignore; | 3645 fvdef = fignore; |
3629 break; | 3646 break; |
3630 } | 3647 } |
3631 break; | 3648 break; |
3632 case ';': | 3649 case ';': |
3633 if (definedef != dnone) | 3650 if (definedef != dnone || inattribute) |
3634 break; | 3651 break; |
3635 switch (typdef) | 3652 switch (typdef) |
3636 { | 3653 { |
3637 case tend: | 3654 case tend: |
3638 case ttypeseen: | 3655 case ttypeseen: |
3648 case fignore: | 3665 case fignore: |
3649 if (typdef == tignore || cplpl) | 3666 if (typdef == tignore || cplpl) |
3650 fvdef = fvnone; | 3667 fvdef = fvnone; |
3651 break; | 3668 break; |
3652 case fvnameseen: | 3669 case fvnameseen: |
3653 if ((globals && cblev == 0 && (!fvextern || declarations)) | 3670 if ((globals && bracelev == 0 && (!fvextern || declarations)) |
3654 || (members && instruct)) | 3671 || (members && instruct)) |
3655 make_C_tag (FALSE); /* a variable */ | 3672 make_C_tag (FALSE); /* a variable */ |
3656 fvextern = FALSE; | 3673 fvextern = FALSE; |
3657 fvdef = fvnone; | 3674 fvdef = fvnone; |
3658 token.valid = FALSE; | 3675 token.valid = FALSE; |
3659 break; | 3676 break; |
3660 case flistseen: | 3677 case flistseen: |
3661 if (declarations | 3678 if ((declarations |
3662 && (typdef == tnone || (typdef != tignore && instruct))) | 3679 && (cplpl || !instruct) |
3663 make_C_tag (TRUE); /* a function declaration */ | 3680 && (typdef == tnone || (typdef != tignore && instruct))) |
3681 || (members | |
3682 && plainc && instruct)) | |
3683 make_C_tag (TRUE); /* a function */ | |
3664 /* FALLTHRU */ | 3684 /* FALLTHRU */ |
3665 default: | 3685 default: |
3666 fvextern = FALSE; | 3686 fvextern = FALSE; |
3667 fvdef = fvnone; | 3687 fvdef = fvnone; |
3668 if (declarations | 3688 if (declarations |
3678 } | 3698 } |
3679 if (structdef == stagseen) | 3699 if (structdef == stagseen) |
3680 structdef = snone; | 3700 structdef = snone; |
3681 break; | 3701 break; |
3682 case ',': | 3702 case ',': |
3683 if (definedef != dnone) | 3703 if (definedef != dnone || inattribute) |
3684 break; | 3704 break; |
3685 switch (objdef) | 3705 switch (objdef) |
3686 { | 3706 { |
3687 case omethodtag: | 3707 case omethodtag: |
3688 case omethodparm: | 3708 case omethodparm: |
3700 case vignore: | 3720 case vignore: |
3701 break; | 3721 break; |
3702 case fdefunname: | 3722 case fdefunname: |
3703 fvdef = fignore; | 3723 fvdef = fignore; |
3704 break; | 3724 break; |
3705 case fvnameseen: /* a variable */ | 3725 case fvnameseen: |
3706 if ((globals && cblev == 0 && (!fvextern || declarations)) | 3726 if (parlev == 0 |
3707 || (members && instruct)) | 3727 && ((globals |
3708 make_C_tag (FALSE); | 3728 && bracelev == 0 |
3729 && templatelev == 0 | |
3730 && (!fvextern || declarations)) | |
3731 || (members && instruct))) | |
3732 make_C_tag (FALSE); /* a variable */ | |
3709 break; | 3733 break; |
3710 case flistseen: /* a function */ | 3734 case flistseen: |
3711 if ((declarations && typdef == tnone && !instruct) | 3735 if ((declarations && typdef == tnone && !instruct) |
3712 || (members && typdef != tignore && instruct)) | 3736 || (members && typdef != tignore && instruct)) |
3713 { | 3737 { |
3714 make_C_tag (TRUE); /* a function declaration */ | 3738 make_C_tag (TRUE); /* a function */ |
3715 fvdef = fvnameseen; | 3739 fvdef = fvnameseen; |
3716 } | 3740 } |
3717 else if (!declarations) | 3741 else if (!declarations) |
3718 fvdef = fvnone; | 3742 fvdef = fvnone; |
3719 token.valid = FALSE; | 3743 token.valid = FALSE; |
3722 fvdef = fvnone; | 3746 fvdef = fvnone; |
3723 } | 3747 } |
3724 if (structdef == stagseen) | 3748 if (structdef == stagseen) |
3725 structdef = snone; | 3749 structdef = snone; |
3726 break; | 3750 break; |
3727 case '[': | 3751 case ']': |
3728 if (definedef != dnone) | 3752 if (definedef != dnone || inattribute) |
3729 break; | 3753 break; |
3730 if (structdef == stagseen) | 3754 if (structdef == stagseen) |
3731 structdef = snone; | 3755 structdef = snone; |
3732 switch (typdef) | 3756 switch (typdef) |
3733 { | 3757 { |
3744 case finlist: | 3768 case finlist: |
3745 case fignore: | 3769 case fignore: |
3746 case vignore: | 3770 case vignore: |
3747 break; | 3771 break; |
3748 case fvnameseen: | 3772 case fvnameseen: |
3749 if ((members && cblev == 1) | 3773 if ((members && bracelev == 1) |
3750 || (globals && cblev == 0 | 3774 || (globals && bracelev == 0 |
3751 && (!fvextern || declarations))) | 3775 && (!fvextern || declarations))) |
3752 make_C_tag (FALSE); /* a variable */ | 3776 make_C_tag (FALSE); /* a variable */ |
3753 /* FALLTHRU */ | 3777 /* FALLTHRU */ |
3754 default: | 3778 default: |
3755 fvdef = fvnone; | 3779 fvdef = fvnone; |
3756 } | 3780 } |
3757 break; | 3781 break; |
3758 } | 3782 } |
3759 break; | 3783 break; |
3760 case '(': | 3784 case '(': |
3785 if (inattribute) | |
3786 { | |
3787 attrparlev++; | |
3788 break; | |
3789 } | |
3761 if (definedef != dnone) | 3790 if (definedef != dnone) |
3762 break; | 3791 break; |
3763 if (objdef == otagseen && parlev == 0) | 3792 if (objdef == otagseen && parlev == 0) |
3764 objdef = oparenseen; | 3793 objdef = oparenseen; |
3765 switch (fvdef) | 3794 switch (fvdef) |
3785 break; | 3814 break; |
3786 } | 3815 } |
3787 parlev++; | 3816 parlev++; |
3788 break; | 3817 break; |
3789 case ')': | 3818 case ')': |
3819 if (inattribute) | |
3820 { | |
3821 if (--attrparlev == 0) | |
3822 inattribute = FALSE; | |
3823 break; | |
3824 } | |
3790 if (definedef != dnone) | 3825 if (definedef != dnone) |
3791 break; | 3826 break; |
3792 if (objdef == ocatseen && parlev == 1) | 3827 if (objdef == ocatseen && parlev == 1) |
3793 { | 3828 { |
3794 make_C_tag (TRUE); /* an Objective C category */ | 3829 make_C_tag (TRUE); /* an Objective C category */ |
3818 if (definedef != dnone) | 3853 if (definedef != dnone) |
3819 break; | 3854 break; |
3820 if (typdef == ttypeseen) | 3855 if (typdef == ttypeseen) |
3821 { | 3856 { |
3822 /* Whenever typdef is set to tinbody (currently only | 3857 /* Whenever typdef is set to tinbody (currently only |
3823 here), typdefcblev should be set to cblev. */ | 3858 here), typdefbracelev should be set to bracelev. */ |
3824 typdef = tinbody; | 3859 typdef = tinbody; |
3825 typdefcblev = cblev; | 3860 typdefbracelev = bracelev; |
3826 } | 3861 } |
3827 switch (fvdef) | 3862 switch (fvdef) |
3828 { | 3863 { |
3829 case flistseen: | 3864 case flistseen: |
3830 make_C_tag (TRUE); /* a function */ | 3865 make_C_tag (TRUE); /* a function */ |
3844 make_C_tag (TRUE); /* an Objective C method */ | 3879 make_C_tag (TRUE); /* an Objective C method */ |
3845 objdef = oinbody; | 3880 objdef = oinbody; |
3846 break; | 3881 break; |
3847 default: | 3882 default: |
3848 /* Neutralize `extern "C" {' grot. */ | 3883 /* Neutralize `extern "C" {' grot. */ |
3849 if (cblev == 0 && structdef == snone && nestlev == 0 | 3884 if (bracelev == 0 && structdef == snone && nestlev == 0 |
3850 && typdef == tnone) | 3885 && typdef == tnone) |
3851 cblev = -1; | 3886 bracelev = -1; |
3852 } | 3887 } |
3853 break; | 3888 break; |
3854 } | 3889 } |
3855 switch (structdef) | 3890 switch (structdef) |
3856 { | 3891 { |
3857 case skeyseen: /* unnamed struct */ | 3892 case skeyseen: /* unnamed struct */ |
3858 pushclass_above (cblev, NULL, 0); | 3893 pushclass_above (bracelev, NULL, 0); |
3859 structdef = snone; | 3894 structdef = snone; |
3860 break; | 3895 break; |
3861 case stagseen: /* named struct or enum */ | 3896 case stagseen: /* named struct or enum */ |
3862 case scolonseen: /* a class */ | 3897 case scolonseen: /* a class */ |
3863 pushclass_above (cblev, token.line+token.offset, token.length); | 3898 pushclass_above (bracelev,token.line+token.offset, token.length); |
3864 structdef = snone; | 3899 structdef = snone; |
3865 make_C_tag (FALSE); /* a struct or enum */ | 3900 make_C_tag (FALSE); /* a struct or enum */ |
3866 break; | 3901 break; |
3867 } | 3902 } |
3868 cblev++; | 3903 bracelev++; |
3869 break; | 3904 break; |
3870 case '*': | 3905 case '*': |
3871 if (definedef != dnone) | 3906 if (definedef != dnone) |
3872 break; | 3907 break; |
3873 if (fvdef == fstartlist) | 3908 if (fvdef == fstartlist) |
3879 case '}': | 3914 case '}': |
3880 if (definedef != dnone) | 3915 if (definedef != dnone) |
3881 break; | 3916 break; |
3882 if (!ignoreindent && lp == newlb.buffer + 1) | 3917 if (!ignoreindent && lp == newlb.buffer + 1) |
3883 { | 3918 { |
3884 if (cblev != 0) | 3919 if (bracelev != 0) |
3885 token.valid = FALSE; | 3920 token.valid = FALSE; |
3886 cblev = 0; /* reset curly brace level if first column */ | 3921 bracelev = 0; /* reset brace level if first column */ |
3887 parlev = 0; /* also reset paren level, just in case... */ | 3922 parlev = 0; /* also reset paren level, just in case... */ |
3888 } | 3923 } |
3889 else if (cblev > 0) | 3924 else if (bracelev > 0) |
3890 cblev--; | 3925 bracelev--; |
3891 else | 3926 else |
3892 token.valid = FALSE; /* something gone amiss, token unreliable */ | 3927 token.valid = FALSE; /* something gone amiss, token unreliable */ |
3893 popclass_above (cblev); | 3928 popclass_above (bracelev); |
3894 structdef = snone; | 3929 structdef = snone; |
3895 /* Only if typdef == tinbody is typdefcblev significant. */ | 3930 /* Only if typdef == tinbody is typdefbracelev significant. */ |
3896 if (typdef == tinbody && cblev <= typdefcblev) | 3931 if (typdef == tinbody && bracelev <= typdefbracelev) |
3897 { | 3932 { |
3898 assert (cblev == typdefcblev); | 3933 assert (bracelev == typdefbracelev); |
3899 typdef = tend; | 3934 typdef = tend; |
3900 } | 3935 } |
3901 break; | 3936 break; |
3902 case '=': | 3937 case '=': |
3903 if (definedef != dnone) | 3938 if (definedef != dnone) |
3908 case finlist: | 3943 case finlist: |
3909 case fignore: | 3944 case fignore: |
3910 case vignore: | 3945 case vignore: |
3911 break; | 3946 break; |
3912 case fvnameseen: | 3947 case fvnameseen: |
3913 if ((members && cblev == 1) | 3948 if ((members && bracelev == 1) |
3914 || (globals && cblev == 0 && (!fvextern || declarations))) | 3949 || (globals && bracelev == 0 && (!fvextern || declarations))) |
3915 make_C_tag (FALSE); /* a variable */ | 3950 make_C_tag (FALSE); /* a variable */ |
3916 /* FALLTHRU */ | 3951 /* FALLTHRU */ |
3917 default: | 3952 default: |
3918 fvdef = vignore; | 3953 fvdef = vignore; |
3919 } | 3954 } |
3920 break; | 3955 break; |
3921 case '<': | 3956 case '<': |
3922 if (cplpl && structdef == stagseen) | 3957 if (cplpl |
3923 { | 3958 && (structdef == stagseen || fvdef == fvnameseen)) |
3924 structdef = sintemplate; | 3959 { |
3960 templatelev++; | |
3925 break; | 3961 break; |
3926 } | 3962 } |
3927 goto resetfvdef; | 3963 goto resetfvdef; |
3928 case '>': | 3964 case '>': |
3929 if (structdef == sintemplate) | 3965 if (templatelev > 0) |
3930 { | 3966 { |
3931 structdef = stagseen; | 3967 templatelev--; |
3932 break; | 3968 break; |
3933 } | 3969 } |
3934 goto resetfvdef; | 3970 goto resetfvdef; |
3935 case '+': | 3971 case '+': |
3936 case '-': | 3972 case '-': |
3937 if (objdef == oinbody && cblev == 0) | 3973 if (objdef == oinbody && bracelev == 0) |
3938 { | 3974 { |
3939 objdef = omethodsign; | 3975 objdef = omethodsign; |
3940 break; | 3976 break; |
3941 } | 3977 } |
3942 /* FALLTHRU */ | 3978 /* FALLTHRU */ |
3943 resetfvdef: | 3979 resetfvdef: |
3944 case '#': case '~': case '&': case '%': case '/': case '|': | 3980 case '#': case '~': case '&': case '%': case '/': |
3945 case '^': case '!': case '.': case '?': case ']': | 3981 case '|': case '^': case '!': case '.': case '?': |
3946 if (definedef != dnone) | 3982 if (definedef != dnone) |
3947 break; | 3983 break; |
3948 /* These surely cannot follow a function tag in C. */ | 3984 /* These surely cannot follow a function tag in C. */ |
3949 switch (fvdef) | 3985 switch (fvdef) |
3950 { | 3986 { |
4887 dbp = skip_spaces (dbp); | 4923 dbp = skip_spaces (dbp); |
4888 L_getit (); | 4924 L_getit (); |
4889 } | 4925 } |
4890 } | 4926 } |
4891 } | 4927 } |
4928 } | |
4929 } | |
4930 | |
4931 | |
4932 /* | |
4933 * Lua script language parsing | |
4934 * Original code by David A. Capello <dacap@users.sourceforge.net> (2004) | |
4935 * | |
4936 * "function" and "local function" are tags if they start at column 1. | |
4937 */ | |
4938 static void | |
4939 Lua_functions (inf) | |
4940 FILE *inf; | |
4941 { | |
4942 register char *bp; | |
4943 | |
4944 LOOP_ON_INPUT_LINES (inf, lb, bp) | |
4945 { | |
4946 if (bp[0] != 'f' && bp[0] != 'l') | |
4947 continue; | |
4948 | |
4949 LOOKING_AT (bp, "local"); /* skip possible "local" */ | |
4950 | |
4951 if (LOOKING_AT (bp, "function")) | |
4952 get_tag (bp, NULL); | |
4892 } | 4953 } |
4893 } | 4954 } |
4894 | 4955 |
4895 | 4956 |
4896 /* | 4957 /* |