1 /* Parser grammar for quick source code scan of Java(TM) language programs.
2 Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
3 Contributed by Alexandre Petit-Bianco (apbianco@cygnus.com)
5 This file is part of GNU CC.
7 GNU CC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU CC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.
22 Java and all Java-based marks are trademarks or registered trademarks
23 of Sun Microsystems, Inc. in the United States and other countries.
24 The Free Software Foundation is independent of Sun Microsystems, Inc. */
26 /* This file parses Java source code. Action can be further completed
27 to achieve a desired behavior. This file isn't part of the Java
28 language gcc front end.
30 The grammar conforms to the Java grammar described in "The Java(TM)
31 Language Specification. J. Gosling, B. Joy, G. Steele. Addison Wesley
32 1996, ISBN 0-201-63451-1"
34 Some rules have been modified to support JDK1.1 inner classes
35 definitions and other extensions. */
46 extern
char *input_filename
;
47 extern
FILE *finput
, *out
;
49 /* Obstack for the lexer. */
50 struct obstack temporary_obstack
;
52 /* The current parser context. */
53 static struct parser_ctxt
*ctxp
;
55 /* Error and warning counts, current line number, because they're used
58 int java_warning_count
;
61 /* Tweak default rules when necessary. */
63 #define USE_ABSORBER absorber = 0
65 /* Keep track of the current class name and package name. */
66 static char *current_class
;
67 static const char *package_name
;
69 /* Keep track of the current inner class qualifier. */
70 static int current_class_length
;
72 /* Keep track of whether things have be listed before. */
73 static int previous_output
;
75 /* Record modifier uses */
76 static int modifier_value
;
78 /* Record (almost) cyclomatic complexity. */
79 static int complexity
;
81 /* Keeps track of number of bracket pairs after a variable declarator
83 static int bracket_count
;
85 /* Numbers anonymous classes */
86 static int anonymous_count
;
88 /* Record a method declaration */
89 struct method_declarator
{
90 const char *method_name
;
93 #define NEW_METHOD_DECLARATOR(D,N,A) \
96 (struct method_declarator
*)xmalloc
(sizeof
(struct method_declarator
)); \
97 (D
)->method_name
= (N
); \
101 /* Two actions for this grammar */
102 static void report_class_declaration PARAMS
((const char *));
103 static void report_main_declaration PARAMS
((struct method_declarator
*));
104 static void push_class_context PARAMS
((const char *));
105 static void pop_class_context PARAMS
((void));
107 void report PARAMS
((void));
115 struct method_declarator
*declarator
;
116 int value
; /* For modifiers */
125 /* Things defined here have to match the order of what's in the
126 binop_lookup table. */
128 %token PLUS_TK MINUS_TK MULT_TK DIV_TK REM_TK
129 %token LS_TK SRS_TK ZRS_TK
130 %token AND_TK XOR_TK OR_TK
131 %token BOOL_AND_TK BOOL_OR_TK
132 %token EQ_TK NEQ_TK GT_TK GTE_TK LT_TK LTE_TK
134 /* This maps to the same binop_lookup entry than the token above */
136 %token PLUS_ASSIGN_TK MINUS_ASSIGN_TK MULT_ASSIGN_TK DIV_ASSIGN_TK
138 %token LS_ASSIGN_TK SRS_ASSIGN_TK ZRS_ASSIGN_TK
139 %token AND_ASSIGN_TK XOR_ASSIGN_TK OR_ASSIGN_TK
142 /* Modifier TOKEN have to be kept in this order. Don't scramble it */
144 %token PUBLIC_TK PRIVATE_TK PROTECTED_TK
145 %token STATIC_TK FINAL_TK SYNCHRONIZED_TK
146 %token VOLATILE_TK TRANSIENT_TK NATIVE_TK
147 %token PAD_TK ABSTRACT_TK MODIFIER_TK
150 /* Keep those two in order, too */
151 %token DECR_TK INCR_TK
153 /* From now one, things can be in any order */
155 %token DEFAULT_TK IF_TK THROW_TK
156 %token BOOLEAN_TK DO_TK IMPLEMENTS_TK
157 %token THROWS_TK BREAK_TK IMPORT_TK
158 %token ELSE_TK INSTANCEOF_TK RETURN_TK
159 %token VOID_TK CATCH_TK INTERFACE_TK
160 %token CASE_TK EXTENDS_TK FINALLY_TK
161 %token SUPER_TK WHILE_TK CLASS_TK
162 %token SWITCH_TK CONST_TK TRY_TK
163 %token FOR_TK NEW_TK CONTINUE_TK
164 %token GOTO_TK PACKAGE_TK THIS_TK
166 %token BYTE_TK SHORT_TK INT_TK LONG_TK
167 %token CHAR_TK INTEGRAL_TK
169 %token FLOAT_TK DOUBLE_TK FP_TK
173 %token REL_QM_TK REL_CL_TK NOT_TK NEG_TK
175 %token ASSIGN_ANY_TK ASSIGN_TK
176 %token OP_TK CP_TK OCB_TK CCB_TK OSB_TK CSB_TK SC_TK C_TK DOT_TK
178 %token STRING_LIT_TK CHAR_LIT_TK INT_LIT_TK FP_LIT_TK
179 %token TRUE_TK FALSE_TK BOOL_LIT_TK NULL_TK
181 %type
<node
> ID_TK identifier name simple_name qualified_name type
182 primitive_type reference_type array_type formal_parameter_list
183 formal_parameter class_or_interface_type class_type interface_type
184 %type
<declarator
> method_declarator
185 %type
<value
> MODIFIER_TK
188 /* 19.2 Production from 2.3: The Syntactic Grammar */
193 /* 19.3 Productions from 3: Lexical structure */
203 /* 19.4 Productions from 4: Types, Values and Variables */
212 /* use preset global here. FIXME */
213 $$
= xstrdup
("int");
217 /* use preset global here. FIXME */
218 $$
= xstrdup
("double");
222 /* use preset global here. FIXME */
223 $$
= xstrdup
("boolean");
228 class_or_interface_type
232 class_or_interface_type:
237 class_or_interface_type
/* Default rule */
241 class_or_interface_type
247 while
(bracket_count
-- > 0)
248 $$
= concat
("[", $1, NULL
);
252 while
(bracket_count
-- > 0)
253 $$
= concat
("[", $1, NULL
);
257 /* 19.5 Productions from 6: Names */
259 simple_name
/* Default rule */
260 | qualified_name
/* Default rule */
264 identifier
/* Default rule */
268 name DOT_TK identifier
270 $$
= concat
($1, ".", $3, NULL
);
278 /* 19.6: Production from 7: Packages */
280 | package_declaration
281 | import_declarations
283 | package_declaration import_declarations
284 | package_declaration type_declarations
285 | import_declarations type_declarations
286 | package_declaration import_declarations type_declarations
291 | import_declarations import_declaration
296 | type_declarations type_declaration
300 PACKAGE_TK name SC_TK
301 { package_name
= $2; }
305 single_type_import_declaration
306 | type_import_on_demand_declaration
309 single_type_import_declaration:
313 type_import_on_demand_declaration:
314 IMPORT_TK name DOT_TK MULT_TK SC_TK
319 | interface_declaration
323 /* 19.7 Shortened from the original:
324 modifiers: modifier | modifiers modifier
325 modifier: any of public... */
335 | modifiers MODIFIER_TK
345 /* 19.8.1 Production from $8.1: Class Declaration */
347 modifiers CLASS_TK identifier super interfaces
349 report_class_declaration
($3);
353 | CLASS_TK identifier super interfaces
354 { report_class_declaration
($2); }
359 | EXTENDS_TK class_type
363 | IMPLEMENTS_TK interface_type_list
369 | interface_type_list C_TK interface_type
375 { pop_class_context
(); }
376 | OCB_TK class_body_declarations CCB_TK
377 { pop_class_context
(); }
380 class_body_declarations:
381 class_body_declaration
382 | class_body_declarations class_body_declaration
385 class_body_declaration:
386 class_member_declaration
388 | constructor_declaration
389 | block
/* Added, JDK1.1, instance initializer */
392 class_member_declaration:
395 | class_declaration
/* Added, JDK1.1 inner classes */
396 | interface_declaration
/* Added, JDK1.1 inner classes */
400 /* 19.8.2 Productions from 8.3: Field Declarations */
402 type variable_declarators SC_TK
404 | modifiers type variable_declarators SC_TK
405 { modifier_value
= 0; }
408 variable_declarators:
409 /* Should we use build_decl_list () instead ? FIXME */
410 variable_declarator
/* Default rule */
411 | variable_declarators C_TK variable_declarator
415 variable_declarator_id
416 | variable_declarator_id ASSIGN_TK variable_initializer
419 variable_declarator_id:
421 { bracket_count
= 0; USE_ABSORBER
; }
422 | variable_declarator_id OSB_TK CSB_TK
426 variable_initializer:
431 /* 19.8.3 Productions from 8.4: Method Declarations */
433 method_header method_body
437 type method_declarator throws
439 | VOID_TK method_declarator throws
440 | modifiers type method_declarator throws
441 { modifier_value
= 0; }
442 | modifiers VOID_TK method_declarator throws
444 report_main_declaration
($3);
450 identifier OP_TK CP_TK
452 struct method_declarator
*d
;
453 NEW_METHOD_DECLARATOR
(d
, $1, NULL
);
456 | identifier OP_TK formal_parameter_list CP_TK
458 struct method_declarator
*d
;
459 NEW_METHOD_DECLARATOR
(d
, $1, $3);
462 | method_declarator OSB_TK CSB_TK
465 formal_parameter_list:
467 | formal_parameter_list C_TK formal_parameter
469 $$
= concat
($1, ",", $3, NULL
);
474 type variable_declarator_id
480 char *n
= xmalloc
(bracket_count
+ 1 + strlen
($$
));
481 for
(i
= 0; i
< bracket_count
; ++i
)
483 strcpy
(n
+ bracket_count
, $$
);
489 | modifiers type variable_declarator_id
/* Added, JDK1.1 final locals */
494 char *n
= xmalloc
(bracket_count
+ 1 + strlen
($$
));
495 for
(i
= 0; i
< bracket_count
; ++i
)
497 strcpy
(n
+ bracket_count
, $$
);
506 | THROWS_TK class_type_list
512 | class_type_list C_TK class_type
521 /* 19.8.4 Productions from 8.5: Static Initializers */
526 static: /* Test lval.sub_token here */
531 /* 19.8.5 Productions from 8.6: Constructor Declarations */
532 /* NOTE FOR FURTHER WORK ON CONSTRUCTORS:
533 - If a forbidded modifier is found, the the error is either the use of
534 a forbidded modifier for a constructor OR bogus attempt to declare a
535 method without having specified the return type. FIXME */
536 constructor_declaration:
537 constructor_declarator throws constructor_body
538 | modifiers constructor_declarator throws constructor_body
539 { modifier_value
= 0; }
540 /* extra SC_TK, FIXME */
541 | constructor_declarator throws constructor_body SC_TK
542 /* extra SC_TK, FIXME */
543 | modifiers constructor_declarator throws constructor_body SC_TK
544 { modifier_value
= 0; }
545 /* I'm not happy with the SC_TK addition. It isn't in the grammer and should
546 probably be matched by and empty statement. But it doesn't work. FIXME */
549 constructor_declarator:
550 simple_name OP_TK CP_TK
552 | simple_name OP_TK formal_parameter_list CP_TK
558 | OCB_TK explicit_constructor_invocation CCB_TK
559 | OCB_TK block_statements CCB_TK
560 | OCB_TK explicit_constructor_invocation block_statements CCB_TK
563 /* Error recovery for that rule moved down expression_statement: rule. */
564 explicit_constructor_invocation:
565 this_or_super OP_TK CP_TK SC_TK
566 | this_or_super OP_TK argument_list CP_TK SC_TK
567 /* Added, JDK1.1 inner classes. Modified because the rule
568 'primary' couldn't work. */
569 | name DOT_TK SUPER_TK OP_TK argument_list CP_TK SC_TK
571 | name DOT_TK SUPER_TK OP_TK CP_TK SC_TK
575 this_or_super: /* Added, simplifies error diagnostics */
580 /* 19.9 Productions from 9: Interfaces */
581 /* 19.9.1 Productions from 9.1: Interfaces Declarations */
582 interface_declaration:
583 INTERFACE_TK identifier
584 { report_class_declaration
($2); modifier_value
= 0; }
586 | modifiers INTERFACE_TK identifier
587 { report_class_declaration
($3); modifier_value
= 0; }
589 | INTERFACE_TK identifier extends_interfaces
590 { report_class_declaration
($2); modifier_value
= 0; }
592 | modifiers INTERFACE_TK identifier extends_interfaces
593 { report_class_declaration
($3); modifier_value
= 0; }
598 EXTENDS_TK interface_type
599 | extends_interfaces C_TK interface_type
604 { pop_class_context
(); }
605 | OCB_TK interface_member_declarations CCB_TK
606 { pop_class_context
(); }
609 interface_member_declarations:
610 interface_member_declaration
611 | interface_member_declarations interface_member_declaration
614 interface_member_declaration:
616 | abstract_method_declaration
617 | class_declaration
/* Added, JDK1.1 inner classes */
618 | interface_declaration
/* Added, JDK1.1 inner classes */
621 constant_declaration:
625 abstract_method_declaration:
629 /* 19.10 Productions from 10: Arrays */
632 | OCB_TK variable_initializers CCB_TK
634 | OCB_TK variable_initializers C_TK CCB_TK
637 variable_initializers:
639 | variable_initializers C_TK variable_initializer
642 /* 19.11 Production from 14: Blocks and Statements */
645 | OCB_TK block_statements CCB_TK
650 | block_statements block_statement
654 local_variable_declaration_statement
656 | class_declaration
/* Added, JDK1.1 inner classes */
659 local_variable_declaration_statement:
660 local_variable_declaration SC_TK
/* Can't catch missing ';' here */
663 local_variable_declaration:
664 type variable_declarators
666 | modifiers type variable_declarators
/* Added, JDK1.1 final locals */
667 { modifier_value
= 0; }
671 statement_without_trailing_substatement
674 | if_then_else_statement
680 statement_without_trailing_substatement
681 | labeled_statement_nsi
682 | if_then_else_statement_nsi
683 | while_statement_nsi
687 statement_without_trailing_substatement:
690 | expression_statement
696 | synchronized_statement
714 labeled_statement_nsi:
715 label_decl statement_nsi
718 /* We concentrate here a bunch of error handling rules that we couldn't write
719 earlier, because expression_statement catches a missing ';'. */
720 expression_statement:
721 statement_expression SC_TK
724 statement_expression:
726 | pre_increment_expression
727 | pre_decrement_expression
728 | post_increment_expression
729 | post_decrement_expression
731 | class_instance_creation_expression
735 IF_TK OP_TK expression CP_TK statement
{ ++complexity
; }
738 if_then_else_statement:
739 IF_TK OP_TK expression CP_TK statement_nsi ELSE_TK statement
743 if_then_else_statement_nsi:
744 IF_TK OP_TK expression CP_TK statement_nsi ELSE_TK statement_nsi
749 SWITCH_TK OP_TK expression CP_TK switch_block
754 | OCB_TK switch_labels CCB_TK
755 | OCB_TK switch_block_statement_groups CCB_TK
756 | OCB_TK switch_block_statement_groups switch_labels CCB_TK
759 switch_block_statement_groups:
760 switch_block_statement_group
761 | switch_block_statement_groups switch_block_statement_group
764 switch_block_statement_group:
765 switch_labels block_statements
{ ++complexity
; }
771 | switch_labels switch_label
775 CASE_TK constant_expression REL_CL_TK
776 | DEFAULT_TK REL_CL_TK
780 WHILE_TK OP_TK expression CP_TK
{ ++complexity
; }
784 while_expression statement
788 while_expression statement_nsi
796 do_statement_begin statement WHILE_TK OP_TK expression CP_TK SC_TK
801 for_begin SC_TK expression SC_TK for_update CP_TK statement
802 | for_begin SC_TK SC_TK for_update CP_TK statement
806 for_begin SC_TK expression SC_TK for_update CP_TK statement_nsi
807 | for_begin SC_TK SC_TK for_update CP_TK statement_nsi
815 for_header for_init
{ ++complexity
; }
817 for_init: /* Can be empty */
818 | statement_expression_list
819 | local_variable_declaration
822 for_update: /* Can be empty */
823 | statement_expression_list
826 statement_expression_list:
828 | statement_expression_list C_TK statement_expression
833 | BREAK_TK identifier SC_TK
836 /* `continue' with a label is considered for complexity but ordinary
840 | CONTINUE_TK identifier SC_TK
{ ++complexity
; }
845 | RETURN_TK expression SC_TK
849 THROW_TK expression SC_TK
{ ++complexity
; }
852 synchronized_statement:
853 synchronized OP_TK expression CP_TK block
854 | synchronized OP_TK expression CP_TK
error
857 synchronized: /* Test lval.sub_token here */
864 | TRY_TK block finally
865 | TRY_TK block catches finally
870 | catches catch_clause
874 CATCH_TK OP_TK formal_parameter CP_TK block
{ ++complexity
; }
878 FINALLY_TK block
{ ++complexity
; }
881 /* 19.12 Production from 15: Expressions */
884 | array_creation_expression
887 primary_no_new_array:
890 | OP_TK expression CP_TK
891 | class_instance_creation_expression
896 /* Added, JDK1.1 inner classes. Documentation is wrong
897 refering to a 'ClassName' (class_name) rule that doesn't
898 exist. Used name instead. */
899 | name DOT_TK THIS_TK
906 | array_type DOT_TK CLASS_TK
908 | primitive_type DOT_TK CLASS_TK
910 | VOID_TK DOT_TK CLASS_TK
914 class_instance_creation_expression:
915 NEW_TK class_type OP_TK argument_list CP_TK
916 | NEW_TK class_type OP_TK CP_TK
917 | anonymous_class_creation
918 | something_dot_new identifier OP_TK CP_TK
919 | something_dot_new identifier OP_TK CP_TK class_body
920 | something_dot_new identifier OP_TK argument_list CP_TK
921 | something_dot_new identifier OP_TK argument_list CP_TK class_body
924 anonymous_class_creation:
925 NEW_TK class_type OP_TK CP_TK
926 { report_class_declaration
(NULL
); }
928 | NEW_TK class_type OP_TK argument_list CP_TK
929 { report_class_declaration
(NULL
); }
933 something_dot_new: /* Added, not part of the specs. */
936 | primary DOT_TK NEW_TK
941 | argument_list C_TK expression
942 | argument_list C_TK
error
945 array_creation_expression:
946 NEW_TK primitive_type dim_exprs
947 | NEW_TK class_or_interface_type dim_exprs
948 | NEW_TK primitive_type dim_exprs dims
949 | NEW_TK class_or_interface_type dim_exprs dims
950 /* Added, JDK1.1 anonymous array. Initial documentation rule
952 | NEW_TK class_or_interface_type dims array_initializer
953 | NEW_TK primitive_type dims array_initializer
962 OSB_TK expression CSB_TK
967 { bracket_count
= 1; }
973 primary DOT_TK identifier
974 | SUPER_TK DOT_TK identifier
977 /* We include method invocation in the complexity measure on the
978 theory that most method calls are virtual and therefore involve a
982 { USE_ABSORBER
; ++complexity
; }
983 | name OP_TK argument_list CP_TK
984 { USE_ABSORBER
; ++complexity
; }
985 | primary DOT_TK identifier OP_TK CP_TK
{ ++complexity
; }
986 | primary DOT_TK identifier OP_TK argument_list CP_TK
{ ++complexity
; }
987 | SUPER_TK DOT_TK identifier OP_TK CP_TK
{ ++complexity
; }
988 | SUPER_TK DOT_TK identifier OP_TK argument_list CP_TK
{ ++complexity
; }
992 name OSB_TK expression CSB_TK
994 | primary_no_new_array OSB_TK expression CSB_TK
1001 | post_increment_expression
1002 | post_decrement_expression
1005 post_increment_expression:
1006 postfix_expression INCR_TK
1009 post_decrement_expression:
1010 postfix_expression DECR_TK
1014 pre_increment_expression
1015 | pre_decrement_expression
1016 | PLUS_TK unary_expression
1017 | MINUS_TK unary_expression
1018 | unary_expression_not_plus_minus
1021 pre_increment_expression:
1022 INCR_TK unary_expression
1025 pre_decrement_expression:
1026 DECR_TK unary_expression
1029 unary_expression_not_plus_minus:
1031 | NOT_TK unary_expression
1032 | NEG_TK unary_expression
1036 cast_expression: /* Error handling here is potentially weak */
1037 OP_TK primitive_type dims CP_TK unary_expression
1038 | OP_TK primitive_type CP_TK unary_expression
1039 | OP_TK expression CP_TK unary_expression_not_plus_minus
1040 | OP_TK name dims CP_TK unary_expression_not_plus_minus
1043 multiplicative_expression:
1045 | multiplicative_expression MULT_TK unary_expression
1046 | multiplicative_expression DIV_TK unary_expression
1047 | multiplicative_expression REM_TK unary_expression
1050 additive_expression:
1051 multiplicative_expression
1052 | additive_expression PLUS_TK multiplicative_expression
1053 | additive_expression MINUS_TK multiplicative_expression
1058 | shift_expression LS_TK additive_expression
1059 | shift_expression SRS_TK additive_expression
1060 | shift_expression ZRS_TK additive_expression
1063 relational_expression:
1065 | relational_expression LT_TK shift_expression
1066 | relational_expression GT_TK shift_expression
1067 | relational_expression LTE_TK shift_expression
1068 | relational_expression GTE_TK shift_expression
1069 | relational_expression INSTANCEOF_TK reference_type
1072 equality_expression:
1073 relational_expression
1074 | equality_expression EQ_TK relational_expression
1075 | equality_expression NEQ_TK relational_expression
1080 | and_expression AND_TK equality_expression
1083 exclusive_or_expression:
1085 | exclusive_or_expression XOR_TK and_expression
1088 inclusive_or_expression:
1089 exclusive_or_expression
1090 | inclusive_or_expression OR_TK exclusive_or_expression
1093 conditional_and_expression:
1094 inclusive_or_expression
1095 | conditional_and_expression BOOL_AND_TK inclusive_or_expression
1099 conditional_or_expression:
1100 conditional_and_expression
1101 | conditional_or_expression BOOL_OR_TK conditional_and_expression
1105 conditional_expression: /* Error handling here is weak */
1106 conditional_or_expression
1107 | conditional_or_expression REL_QM_TK expression REL_CL_TK conditional_expression
1111 assignment_expression:
1112 conditional_expression
1117 left_hand_side assignment_operator assignment_expression
1127 assignment_operator:
1133 assignment_expression
1136 constant_expression:
1142 /* Create a new parser context */
1145 java_push_parser_context
()
1147 struct parser_ctxt
*new
=
1148 (struct parser_ctxt
*) xcalloc
(1, sizeof
(struct parser_ctxt
));
1155 push_class_context
(name
)
1158 /* If we already have CURRENT_CLASS set, we're in an inter
1159 class. Mangle its name. */
1164 int additional_length
;
1166 /* NAME set to NULL indicates an anonymous class, which are named by
1170 sprintf
(anonymous
, "%d", ++anonymous_count
);
1176 additional_length
= strlen
(p
)+1; /* +1 for `$' */
1177 current_class
= xrealloc
(current_class
,
1178 current_class_length
+ additional_length
+ 1);
1179 current_class
[current_class_length
] = '$';
1180 strcpy
(¤t_class
[current_class_length
+1], p
);
1181 current_class_length
+= additional_length
;
1187 current_class_length
= strlen
(name
);
1188 current_class
= xmalloc
(current_class_length
+1);
1189 strcpy
(current_class
, name
);
1194 pop_class_context
()
1196 /* Go back to the last `$' and cut. */
1197 while
(--current_class_length
> 0
1198 && current_class
[current_class_length
] != '$')
1200 if
(current_class_length
)
1202 current_class
= xrealloc
(current_class
, current_class_length
+1);
1203 current_class
[current_class_length
] = '\0';
1207 current_class
= NULL
;
1208 anonymous_count
= 0;
1212 /* Actions defined here */
1215 report_class_declaration
(name
)
1218 extern
int flag_dump_class
, flag_list_filename
;
1220 push_class_context
(name
);
1221 if
(flag_dump_class
)
1223 if
(!previous_output
)
1225 if
(flag_list_filename
)
1226 fprintf
(out
, "%s: ", input_filename
);
1227 previous_output
= 1;
1231 fprintf
(out
, "%s.%s ", package_name
, current_class
);
1233 fprintf
(out
, "%s ", current_class
);
1238 report_main_declaration
(declarator
)
1239 struct method_declarator
*declarator
;
1241 extern
int flag_find_main
;
1244 && modifier_value
== 2
1245 && !strcmp
(declarator
->method_name
, "main")
1247 && declarator
->args
[0] == '['
1248 && (! strcmp
(declarator
->args
+1, "String")
1249 ||
! strcmp
(declarator
->args
+ 1, "java.lang.String"))
1252 if
(!previous_output
)
1255 fprintf
(out
, "%s.%s ", package_name
, current_class
);
1257 fprintf
(out
, "%s", current_class
);
1258 previous_output
= 1;
1266 extern
int flag_complexity
;
1267 if
(flag_complexity
)
1268 fprintf
(out
, "%s %d\n", input_filename
, complexity
);
1271 /* Reset global status used by the report functions. */
1273 void reset_report
()
1275 previous_output
= 0;
1276 package_name
= NULL
;
1277 current_class
= NULL
;
1283 const char *msg ATTRIBUTE_UNUSED
;
1285 fprintf
(stderr
, "%s: %d: %s\n", input_filename
, lineno
, msg
);