Skip to content
Snippets Groups Projects
Commit 22a6b7b6 authored by Johannes Mey's avatar Johannes Mey
Browse files

change handling of comments: now, a comment can have multiple lines

parent ee935cca
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
;
......
......@@ -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());
}
;
......
......@@ -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) {
......
......@@ -415,4 +415,4 @@ aspect Types {
eq BlockData.getEndBlockDataStmt().enclosingScope() = this;
// TODO do not forget the COMMON block
}
\ No newline at end of file
}
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment