22
33import java .util .ArrayList ;
44import java .util .Arrays ;
5+ import java .util .logging .Level ;
6+ import java .util .logging .Logger ;
57
68import org .antlr .runtime .Token ;
79import org .w3c .dom .Attr ;
1719 */
1820public class XMLPrinter extends XMLPrinterBase {
1921
22+ private static final Logger LOG = Logger .getLogger (XMLPrinter .class .getName ());
23+
2024 public XMLPrinter (String [] args , IFortranParser parser , String filename ) {
2125 super (args , parser , filename );
2226 }
@@ -93,8 +97,10 @@ public void specification_part(int numUseStmts, int numImportStmts, int numImplS
9397 contextClose ("header" );
9498 contextOpen ("body" );
9599 }
96- if (context .getTagName ().equals ("declaration" ))
100+ if (context .getTagName ().equals ("declaration" )) {
101+ LOG .log (Level .FINER , "closing unclosed declaration at specification_part" );
97102 contextClose ("declaration" );
103+ }
98104 if (!context .getTagName ().equals ("specification" ))
99105 contextOpen ("specification" );
100106 contextCloseAllInner ("specification" );
@@ -2263,8 +2269,10 @@ public void module_subprogram(boolean hasPrefix) {
22632269
22642270 public void use_stmt (Token label , Token useKeyword , Token id , Token onlyKeyword , Token eos , boolean hasModuleNature ,
22652271 boolean hasRenameList , boolean hasOnly ) {
2266- if (context .getTagName ().equals ("declaration" ))
2272+ if (context .getTagName ().equals ("declaration" )) {
2273+ LOG .log (Level .FINE , "closing unclosed declaration at use_stmt id={0}" , id .getText ());
22672274 contextClose ("declaration" );
2275+ }
22682276 if (!context .getTagName ().equals ("use" ))
22692277 contextOpen ("use" );
22702278 setAttribute ("name" , id );
@@ -2274,8 +2282,10 @@ public void use_stmt(Token label, Token useKeyword, Token id, Token onlyKeyword,
22742282 }
22752283
22762284 public void rename_list__begin () {
2277- if (context .getTagName ().equals ("declaration" ))
2285+ if (context .getTagName ().equals ("declaration" )) {
2286+ LOG .log (Level .FINE , "closing unclosed declaration at rename_list__begin" );
22782287 contextClose ("declaration" );
2288+ }
22792289 contextOpen ("use" );
22802290 contextOpen ("rename" );
22812291 if (verbosity >= 100 )
@@ -2288,8 +2298,10 @@ public void rename_list(int count) {
22882298 }
22892299
22902300 public void only_list__begin () {
2291- if (context .getTagName ().equals ("declaration" ))
2301+ if (context .getTagName ().equals ("declaration" )) {
2302+ LOG .log (Level .FINE , "closing unclosed declaration at only_list__begin" );
22922303 contextClose ("declaration" );
2304+ }
22932305 contextOpen ("use" );
22942306 contextOpen ("only" );
22952307 if (verbosity >= 100 )
@@ -2630,8 +2642,10 @@ public void end_mp_subprogram_stmt(Token label, Token keyword1, Token keyword2,
26302642
26312643 public void start_of_file (String filename , String path ) {
26322644 if (contextTryFind ("file" ) != null ) {
2633- if (context .getTagName ().equals ("declaration" ))
2645+ if (context .getTagName ().equals ("declaration" )) {
2646+ LOG .log (Level .FINER , "closing unclosed declaration at start_of_file" );
26342647 contextClose ("declaration" );
2648+ }
26352649 contextOpen ("declaration" );
26362650 setAttribute ("type" , "include" );
26372651 }
0 commit comments