diff --git a/Parser/spec/parser/Fortran2008.rats b/Parser/spec/parser/Fortran2008.rats index 9cc8d467a09decbea700f1569ff1434b7c1fffc5..6a96484727c6a32cfd41832404b52b05d7578d76 100644 --- a/Parser/spec/parser/Fortran2008.rats +++ b/Parser/spec/parser/Fortran2008.rats @@ -91,21 +91,14 @@ CommentConstruct comment_construct = //// CommentExternalSubprogram:ExternalSubprogram ::= Comment ; -//// Comment ::= [CommentContent] ; +//// Comment ::= CommentContent* ; //// CommentContent ::= <String> ; Comment comment = - EXCLAMATIONMARK c:COMMENT_CONTENT LB - { - yyValue = new Comment(new Opt<CommentContent>(new CommentContent(c))); - } -/ SS LB - { - yyValue = new Comment(new Opt<CommentContent>()); - } -/ SS SEMICOLON - { - yyValue = new Comment(new Opt<CommentContent>()); - } + l:( + EXCLAMATIONMARK s:COMMENT_CONTENT LB {yyValue = new CommentContent(s); } + / SS LB { yyValue = new CommentContent(""); } + / SS SEMICOLON { yyValue = new CommentContent(""); } + )+ { yyValue = new Comment(new List<CommentContent>().addAll(((Pair) l).list())); } ; // ============================================================================= @@ -4910,7 +4903,7 @@ EndIfStmt end_if_stmt = IfStmt if_stmt = IF LPAREN e:expr RPAREN s:action_stmt { - yyValue = new IfStmt(new Opt<Label>(), new Comment(new Opt<CommentContent>()), e, s); + yyValue = new IfStmt(new Opt<Label>(), new Comment(new List<CommentContent>()), e, s); } ; diff --git a/Parser/spec/parser/OpenAcc.rats b/Parser/spec/parser/OpenAcc.rats index 9f5a623b5116c1d9d8fd9c0b8cc2ec1de24a9671..768563f384267f0aef627b373b171a33d697abab 100644 --- a/Parser/spec/parser/OpenAcc.rats +++ b/Parser/spec/parser/OpenAcc.rats @@ -377,11 +377,11 @@ AccDirective acc_directive = AccEnterDataDirective acc_enter_data_directive = A_P A_ENTER A_DATA clauses:acc_clause_list LB { - yyValue = new AccEnterDataDirective(new Opt<Label>(), new Comment(new Opt<CommentContent>()), clauses); + yyValue = new AccEnterDataDirective(new Opt<Label>(), new Comment(new List<CommentContent>()), clauses); } / A_P A_ENTER A_DATA LB { - yyValue = new AccEnterDataDirective(new Opt<Label>(), new Comment(new Opt<CommentContent>()), new List()); + yyValue = new AccEnterDataDirective(new Opt<Label>(), new Comment(new List<CommentContent>()), new List()); } ; @@ -389,11 +389,11 @@ AccEnterDataDirective acc_enter_data_directive = AccExitDataDirective acc_exit_data_directive = A_P A_EXIT A_DATA clauses:acc_clause_list LB { - yyValue = new AccExitDataDirective(new Opt<Label>(), new Comment(new Opt<CommentContent>()), clauses); + yyValue = new AccExitDataDirective(new Opt<Label>(), new Comment(new List<CommentContent>()), clauses); } / A_P A_EXIT A_DATA LB { - yyValue = new AccExitDataDirective(new Opt<Label>(), new Comment(new Opt<CommentContent>()), new List()); + yyValue = new AccExitDataDirective(new Opt<Label>(), new Comment(new List<CommentContent>()), new List()); } ; @@ -402,7 +402,7 @@ AccExitDataDirective acc_exit_data_directive = AccCacheDirective acc_cache_directive = A_P A_CACHE list:p_var_list LB { - yyValue = new AccCacheDirective(new Opt<Label>(), new Comment(new Opt<CommentContent>()), list); + yyValue = new AccCacheDirective(new Opt<Label>(), new Comment(new List<CommentContent>()), list); } ; @@ -411,11 +411,11 @@ AccCacheDirective acc_cache_directive = AccUpdateDirective acc_update_directive = A_P A_UPDATE clauses:acc_clause_list LB { - yyValue = new AccUpdateDirective(new Opt<Label>(), new Comment(new Opt<CommentContent>()), clauses); + yyValue = new AccUpdateDirective(new Opt<Label>(), new Comment(new List<CommentContent>()), clauses); } / A_P A_UPDATE LB { - yyValue = new AccUpdateDirective(new Opt<Label>(), new Comment(new Opt<CommentContent>()), new List()); + yyValue = new AccUpdateDirective(new Opt<Label>(), new Comment(new List<CommentContent>()), new List()); } ; @@ -426,11 +426,11 @@ AccUpdateDirective acc_update_directive = AccDeclareDirective acc_declare_directive = A_P A_DECLARE clauses:acc_clause_list LB { - yyValue = new AccDeclareDirective(new Opt<Label>(), new Comment(new Opt<CommentContent>()), clauses); + yyValue = new AccDeclareDirective(new Opt<Label>(), new Comment(new List<CommentContent>()), clauses); } / A_P A_DECLARE LB { - yyValue = new AccDeclareDirective(new Opt<Label>(), new Comment(new Opt<CommentContent>()), new List()); + yyValue = new AccDeclareDirective(new Opt<Label>(), new Comment(new List<CommentContent>()), new List()); } ; @@ -440,12 +440,12 @@ AccRoutineDirective acc_routine_directive = A_P A_ROUTINE n:(LPAREN yyValue:name RPAREN)? clauses:acc_clause_list LB { Opt<Name> n_opt = (n==null) ? new Opt<Name>() : new Opt<Name>(n); - yyValue = new AccRoutineDirective(new Opt<Label>(), new Comment(new Opt<CommentContent>()), n_opt, clauses); + yyValue = new AccRoutineDirective(new Opt<Label>(), new Comment(new List<CommentContent>()), n_opt, clauses); } / A_P A_ROUTINE n:(LPAREN yyValue:name RPAREN) LB { Opt<Name> n_opt = (n==null) ? new Opt<Name>() : new Opt<Name>(n); - yyValue = new AccRoutineDirective(new Opt<Label>(), new Comment(new Opt<CommentContent>()), n_opt, new List()); + yyValue = new AccRoutineDirective(new Opt<Label>(), new Comment(new List<CommentContent>()), n_opt, new List()); } ; @@ -454,19 +454,19 @@ AccRoutineDirective acc_routine_directive = AccWaitDirective acc_wait_directive = A_P A_WAIT clauses:acc_clause_list LB { - yyValue = new AccWaitDirective(new Opt<Label>(), new Comment(new Opt<CommentContent>()), new List(), clauses); + yyValue = new AccWaitDirective(new Opt<Label>(), new Comment(new List<CommentContent>()), new List(), clauses); } / A_P A_WAIT LPAREN list:expr_list RPAREN clauses:acc_clause_list LB { - yyValue = new AccWaitDirective(new Opt<Label>(), new Comment(new Opt<CommentContent>()), list, clauses); + yyValue = new AccWaitDirective(new Opt<Label>(), new Comment(new List<CommentContent>()), list, clauses); } / A_P A_WAIT LB { - yyValue = new AccWaitDirective(new Opt<Label>(), new Comment(new Opt<CommentContent>()), new List(), new List()); + yyValue = new AccWaitDirective(new Opt<Label>(), new Comment(new List<CommentContent>()), new List(), new List()); } / A_P A_WAIT LPAREN list:expr_list RPAREN LB { - yyValue = new AccWaitDirective(new Opt<Label>(), new Comment(new Opt<CommentContent>()), list, new List()); + yyValue = new AccWaitDirective(new Opt<Label>(), new Comment(new List<CommentContent>()), list, new List()); } ; diff --git a/Parser/spec/printer/Printing.jadd b/Parser/spec/printer/Printing.jadd index d28ebe2503f52d15817a947b6b90759600c54e31..2a6a81704cee206d46474e4476dcdb5b9811889d 100644 --- a/Parser/spec/printer/Printing.jadd +++ b/Parser/spec/printer/Printing.jadd @@ -36,14 +36,16 @@ class PrettyPrint { } public void Comment.prettyPrint(PrettyPrinter s){ - if (hasCommentContent()) { - s.ensureWs(); - s.append("!"); - getCommentContent().prettyPrint(s); - } else { - s.append(""); + for (CommentContent cc : getCommentContentList()) { + if (!cc.getString().trim().isEmpty()) { + s.ensureWs(); + s.append("!"); + cc.prettyPrint(s); + } else { + s.append(""); + } + s.lb(); } - s.lb(); } public void CommentContent.prettyPrint(PrettyPrinter s) { diff --git a/Parser/spec/semantics/Types.jrag b/Parser/spec/semantics/Types.jrag index 17fa1be13f8688e741e7a47d4bf64ea68683a785..1be46960b6184e81dff31b144dcd267db760a528 100644 --- a/Parser/spec/semantics/Types.jrag +++ b/Parser/spec/semantics/Types.jrag @@ -415,4 +415,4 @@ aspect Types { eq BlockData.getEndBlockDataStmt().enclosingScope() = this; // TODO do not forget the COMMON block -} \ No newline at end of file +} diff --git a/Parser/test-data/rewrites/B_Designator_OR_FunctionReference.f90 b/Parser/test-data/rewrites/B_Designator_OR_FunctionReference.f90 index efbe7a8c8d04ffff36920a63fcd53346deb09dd4..164d067e75ba349df81a151d70abc9105a8e78f0 100644 --- a/Parser/test-data/rewrites/B_Designator_OR_FunctionReference.f90 +++ b/Parser/test-data/rewrites/B_Designator_OR_FunctionReference.f90 @@ -2,12 +2,13 @@ TYPE FULLNAME CHARACTER (LEN = 50) FIRST,LAST - + END TYPE PERSON TYPE PERSON INTEGER AGE TYPE (FULLNAME) NAME + END TYPE PERSON TYPE (PERSON) :: CHAIRMAN