diff --git a/Codegen/src/Generators/LinearNodeSourceCodeMapper.cs b/Codegen/src/Generators/LinearNodeSourceCodeMapper.cs
index 5ac726fd0..aa1fb3de8 100644
--- a/Codegen/src/Generators/LinearNodeSourceCodeMapper.cs
+++ b/Codegen/src/Generators/LinearNodeSourceCodeMapper.cs
@@ -1115,6 +1115,9 @@ public void Accept(Node node)
//Create All SourceTextBuffer Content associated to Nodes
CreateNodeSourceTextBufferContents();
+ // Comment specific parts (Formalized Comments)
+ CommentSpecificParts(node);
+
//Now Complete Function Declaration Lines relocation.
CompleteFunctionDeclarationLinesRelocation();
@@ -1269,6 +1272,65 @@ public static bool HasIntersection(List l1, List l2)
return false;
}
+ public Tuple GetFormalizedCommentEnclosingTokensIfAny(Node node)
+ {
+ Token formalizedCommentStartToken =
+ node.CodeElement?.ConsumedTokens.FirstOrDefault(t => t.TokenType == TokenType.FormalizedCommentsStart);
+ Token formalizedCommentStopToken =
+ node.CodeElement?.ConsumedTokens.FirstOrDefault(t => t.TokenType == TokenType.FormalizedCommentsStop);
+ if (formalizedCommentStartToken != null && formalizedCommentStopToken != null)
+ return new Tuple(formalizedCommentStartToken, formalizedCommentStopToken);
+ return null;
+ }
+
+ public void CommentSpecificParts(Node node)
+ {
+ if (node is Compiler.CodeModel.Program)
+ {
+ // Formalised Comments
+ var formalizedCommentsToken = GetFormalizedCommentEnclosingTokensIfAny(node);
+ if (formalizedCommentsToken != null)
+ {// The node have a formalized Comment
+ NodeData nodeData = Nodes.FirstOrDefault(n => n.node == node);
+ if (nodeData != null)
+ {
+ // Split the Buffer to get an array of string representing the lines
+ string content = new string(nodeData.Buffer.ToArray());
+ string[] lines = content.Split(
+ new[] { "\r\n", "\r", "\n" },
+ StringSplitOptions.None
+ );
+
+ int linestart = formalizedCommentsToken.Item1.Line;
+ int linestop = formalizedCommentsToken.Item2.Line;
+
+ int tempoCommentedLines = 0;
+ int tempoTestedLines = 0;
+ // for each lines, if it is inside the formalized comment then comment them (replace the 6th character by a '*')
+ for (int i = 0; i < lines.Length - 1; i++)
+ {
+ tempoTestedLines++;
+ if (nodeData.Positions.Item4[i] >= linestart && nodeData.Positions.Item4[i] <= linestop &&
+ lines[i].Length >= 7)
+ {
+ tempoCommentedLines++;
+ lines[i] = lines[i].Substring(0, 6) + '*' + lines[i].Substring(7, lines[i].Length - 7);
+ }
+ }
+
+ // Replace the buffer content by the new one commented
+ string newContent = string.Join(Environment.NewLine, lines);
+ nodeData.Buffer.Insert(newContent, 0, newContent.Length);
+ }
+ }
+ }
+
+ foreach (var child in node.Children)
+ {
+ CommentSpecificParts(child);
+ }
+ }
+
///
/// Dump All Structures.
///
diff --git a/Codegen/test/TestTypeCobolCodegen.cs b/Codegen/test/TestTypeCobolCodegen.cs
index 24de4f3a6..9ec1d2dce 100644
--- a/Codegen/test/TestTypeCobolCodegen.cs
+++ b/Codegen/test/TestTypeCobolCodegen.cs
@@ -761,15 +761,24 @@ public void DeclarativesWithProcedures2()
CodegenTestUtils.ParseGenerateCompare(Path.Combine("TypeCobol", "DeclarativesWithProcedures2") + ".tcbl", skeletons, false, "TestTypeCobolVersion");
}
- [TestMethod]
- [TestCategory("Codegen")]
- [TestProperty("Time", "fast")]
- public void DeclarativesWithInstructionsWithinTest()
- {
- var skeletons = CodegenTestUtils.ParseConfig(Path.Combine("TypeCobol", "skeletons") + ".xml");
- CodegenTestUtils.ParseGenerateCompare(Path.Combine("TypeCobol", "DeclarativesWithInstructionsWithin") + ".rdz.tcbl", skeletons, false, "TestTypeCobolVersion");
+ [TestMethod]
+ [TestCategory("Codegen")]
+ [TestProperty("Time", "fast")]
+ public void DeclarativesWithInstructionsWithinTest()
+ {
+ var skeletons = CodegenTestUtils.ParseConfig(Path.Combine("TypeCobol", "skeletons") + ".xml");
+ CodegenTestUtils.ParseGenerateCompare(Path.Combine("TypeCobol", "DeclarativesWithInstructionsWithin") + ".rdz.tcbl", skeletons, false, "TestTypeCobolVersion");
}
+ [TestMethod]
+ [TestCategory("Codegen")]
+ [TestProperty("Time", "fast")]
+ public void FormalizedCommentsTest()
+ {
+ var skeletons = CodegenTestUtils.ParseConfig(Path.Combine("TypeCobol", "skeletons") + ".xml");
+ CodegenTestUtils.ParseGenerateCompare(Path.Combine("TypeCobol", "FormalizedComments") + ".tcbl", skeletons, false, "TestTypeCobolVersion");
+ }
+
#if EUROINFO_RULES
[TestMethod]
diff --git a/Codegen/test/resources/input/TypeCobol/FormalizedComments.tcbl b/Codegen/test/resources/input/TypeCobol/FormalizedComments.tcbl
new file mode 100644
index 000000000..3b85aaa7b
--- /dev/null
+++ b/Codegen/test/resources/input/TypeCobol/FormalizedComments.tcbl
@@ -0,0 +1,55 @@
+
+ *<<< My program
+ @ Description : description
+ @deprecated:
+ @ replacedBy : MyFonction2
+ @ rEsTrIcTiOn : Do not Use BOOL var
+ @ need : some needs
+ - description
+ @ see : Thank you for your attention
+ @ todo :
+ - Add BOOL support
+ - implement a call counter
+ *>>>
+ IDENTIFICATION DIVISION.
+ PROGRAM-ID. SandBox.
+
+ DATA DIVISION.
+ LOCAL-STORAGE SECTION.
+
+ *<<<
+ @ description : inline typedef
+ *>>>
+ 01 myType TYPEDEF STRICT PUBLIC pic X(01).
+
+ *<<< Vect2D *>>>
+ 01 Vect2D TYPEDEF STRICT.
+ 02 Coord2d.
+ 03 X PIC 9(4).
+ 03 Y PIC 9(4).
+
+ PROCEDURE DIVISION.
+
+ *<<< MyProc info
+ @ deprec : It is
+ deprecated
+ - need : long need
+ @ todo:
+ - todo1
+ - todo 2
+ @ params:
+ - myDate: just a date
+ - bla: bla < 2
+ - toto: toto
+ -blu: will be ignored *>>>
+ DECLARE PROCEDURE MyProc PRIVATE
+ INPUT myDate TYPE Date
+ bla Pic S9(1)V9(12)
+ IN-OUT myBool TYPE BOOL
+ OUTPUT toto TYPE BOOL
+ bli Pic PPP999PPP.
+ PROCEDURE DIVISION.
+ CONTINUE.
+ END-DECLARE.
+
+ END PROGRAM SandBox.
\ No newline at end of file
diff --git a/Codegen/test/resources/output/TypeCobol/FormalizedComments.tcbl b/Codegen/test/resources/output/TypeCobol/FormalizedComments.tcbl
new file mode 100644
index 000000000..3dbd28249
--- /dev/null
+++ b/Codegen/test/resources/output/TypeCobol/FormalizedComments.tcbl
@@ -0,0 +1,126 @@
+ *TypeCobol_Version:TestTypeCobolVersion
+
+ *<<< My program
+ * @ Description : description
+ * @deprecated:
+ * @ replacedBy : MyFonction2
+ * @ rEsTrIcTiOn : Do not Use BOOL var
+ * @ need : some needs
+ * - description
+ * @ see : Thank you for your attention
+ * @ todo :
+ * - Add BOOL support
+ * - implement a call counter
+ *>>>
+ IDENTIFICATION DIVISION.
+ PROGRAM-ID. SandBox.
+
+ DATA DIVISION.
+ LOCAL-STORAGE SECTION.
+
+ *<<<
+ * @ description : inline typedef
+ * *>>>
+ *01 myType TYPEDEF STRICT PUBLIC pic X(01).
+ *
+
+
+
+
+ *<<< Vect2D *>>>
+ *01 Vect2D TYPEDEF STRICT.
+ *
+
+ * 02 Coord2d.
+ * 03 X PIC 9(4).
+ * 03 Y PIC 9(4).
+
+ PROCEDURE DIVISION.
+
+ *<<< MyProc info
+ * @ deprec : It is
+ *deprecated
+ * - need : long need
+ * @ todo:
+ * - todo1
+ * - todo 2
+ * @ params:
+ * - myDate: just a date
+ * - bla: bla < 2
+ * - toto: toto
+ * -blu: will be ignored *>>>
+ *DECLARE PROCEDURE MyProc PRIVATE
+ * INPUT myDate TYPE Date
+ * bla Pic S9(1)V9(12)
+ * IN-OUT myBool TYPE BOOL
+ * OUTPUT toto TYPE BOOL
+ * bli Pic PPP999PPP.
+ *
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ END PROGRAM SandBox.
+ *
+ *<<< MyProc info
+ * @ deprec : It is
+ *deprecated
+ * - need : long need
+ * @ todo:
+ * - todo1
+ * - todo 2
+ * @ params:
+ * - myDate: just a date
+ * - bla: bla < 2
+ * - toto: toto
+ * -blu: will be ignored *>>>
+ *DECLARE PROCEDURE MyProc PRIVATE
+ * INPUT myDate TYPE Date
+ * bla Pic S9(1)V9(12)
+ * IN-OUT myBool TYPE BOOL
+ * OUTPUT toto TYPE BOOL
+ * bli Pic PPP999PPP.
+ *_________________________________________________________________
+ IDENTIFICATION DIVISION.
+ PROGRAM-ID. a726b68dMyProc.
+ DATA DIVISION.
+ LINKAGE SECTION.
+ 01 myDate.
+ 02 YYYY PIC 9(4).
+ 02 MM PIC 9(2).
+ 02 DD PIC 9(2).
+ 01 bla Pic S9(1)V9(12).
+ 01 myBool-value PIC X VALUE LOW-VALUE.
+ 88 myBool VALUE 'T'.
+ 88 myBool-false VALUE 'F'
+ X'00' thru 'S'
+ 'U' thru X'FF'.
+ 01 toto-value PIC X VALUE LOW-VALUE.
+ 88 toto VALUE 'T'.
+ 88 toto-false VALUE 'F'
+ X'00' thru 'S'
+ 'U' thru X'FF'.
+ 01 bli Pic PPP999PPP.
+ PROCEDURE DIVISION
+ USING BY REFERENCE myDate
+ BY REFERENCE bla
+ BY REFERENCE myBool-value
+ BY REFERENCE toto-value
+ BY REFERENCE bli
+ .
+ CONTINUE.
+ END PROGRAM a726b68dMyProc.