aboutsummaryrefslogtreecommitdiff
path: root/gcc/java/jv-scan.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@cygnus.com>2000-11-20 22:56:14 +0000
committerTom Tromey <tromey@gcc.gnu.org>2000-11-20 22:56:14 +0000
commit1535cc88f20ca7b9c872879fe42c24a8f4222cc3 (patch)
tree158d5ceeea8eedf88fb1e8dfb9d60f780c6684e0 /gcc/java/jv-scan.c
parentd828bc4251657e7064abb66cd50ed7fa7a131a25 (diff)
downloadgcc-1535cc88f20ca7b9c872879fe42c24a8f4222cc3.zip
gcc-1535cc88f20ca7b9c872879fe42c24a8f4222cc3.tar.gz
gcc-1535cc88f20ca7b9c872879fe42c24a8f4222cc3.tar.bz2
jv-scan.c (help): Document --complexity.
* jv-scan.c (help): Document --complexity. (options): Added --complexity. (flag_complexity): New global. (main): Call `report'. * parse-scan.y (complexity): New global. (if_then_statement, if_then_else_statement, if_then_else_statement_nsi, switch_block_statement_group, while_expression, do_statement, for_begin, continue_statement, throw_statement, catch_clause, finally, method_invocation, conditional_and_expression, conditional_or_expression, conditional_expression): Update complexity. (reset_report): Reset complexity. (report): New function. From-SVN: r37595
Diffstat (limited to 'gcc/java/jv-scan.c')
-rw-r--r--gcc/java/jv-scan.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/gcc/java/jv-scan.c b/gcc/java/jv-scan.c
index a96b805..e1ef70a 100644
--- a/gcc/java/jv-scan.c
+++ b/gcc/java/jv-scan.c
@@ -39,6 +39,7 @@ Boston, MA 02111-1307, USA. */
void fatal PARAMS ((const char *s, ...)) ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
void warning PARAMS ((const char *s, ...)) ATTRIBUTE_PRINTF_1;
void gcc_obstack_init PARAMS ((struct obstack *obstack));
+void report PARAMS ((void));
static void usage PARAMS ((void)) ATTRIBUTE_NORETURN;
static void help PARAMS ((void)) ATTRIBUTE_NORETURN;
@@ -61,6 +62,7 @@ char *exec_name;
int flag_find_main = 0;
int flag_dump_class = 0;
int flag_list_filename = 0;
+int flag_complexity = 0;
int pedantic = 0;
@@ -81,6 +83,7 @@ static struct option options[] =
{ "list-filename", no_argument, &flag_list_filename, 1 },
{ "list-class", no_argument, &flag_dump_class, 1 },
{ "encoding", required_argument, NULL, OPT_ENCODING },
+ { "complexity", no_argument, &flag_complexity, 1 },
{ NULL, no_argument, NULL, 0 }
};
@@ -96,6 +99,7 @@ help ()
{
printf ("Usage: jv-scan [OPTION]... FILE...\n\n");
printf ("Print useful information read from Java source files.\n\n");
+ printf (" --complexity Print cyclomatic complexity of input file\n");
printf (" --encoding NAME Specify encoding of input file\n");
printf (" --print-main Print name of class containing `main'\n");
printf (" --list-class List all classes defined in file\n");
@@ -169,12 +173,12 @@ DEFUN (main, (argc, argv),
}
/* No flags? Do nothing */
- if (!flag_find_main && !flag_dump_class)
+ if (! flag_find_main && ! flag_dump_class && ! flag_complexity)
return 0;
/* Check on bad usage */
- if (flag_find_main && flag_dump_class)
- fatal ("Options `--print-main' and `--list-class' can't be turned on at the same time");
+ if (flag_find_main + flag_dump_class + flag_complexity > 1)
+ fatal ("Only one of `--print-main', `--list-class', and `--complexity' allowed");
if (output_file && !(out = fopen (output_file, "w")))
fatal ("Can't open output file `%s'", output_file);
@@ -205,6 +209,7 @@ DEFUN (main, (argc, argv),
java_init_lex (finput, encoding);
yyparse ();
+ report ();
if (ftell (out) != ft)
fputc ('\n', out);
ft = ftell (out);