typecobolteam / typecobol.templatetranspiler Goto Github PK
View Code? Open in Web Editor NEWA TypeCobol Razor script template transpiler to C# source code.
License: Other
A TypeCobol Razor script template transpiler to C# source code.
License: Other
Into Visual Studio when the Custom Build Task (.xml to .cs) encounters un error, there is no corresponding message into Visual Studio, only a failure notification.
The Script below is not translated correctly.
@{
var items = "";
if (@Model.definitions.nestedFunctions.Public.Count > 0) {
items += "*\n";
items += "* IF CallIsCopy\n";
items += "* PERFORM Copy-Process-Mode\n";
items += "* ELSE\n";
items += " PERFORM FctList-Process-Mode\n";
items += " perform INIT-LIBRARY\n";
items += "* END-IF\n\n";
items += " GOBACK.\n\n";
items += " FctList-Process-Mode.\n";
items += " IF NOT TC-" + @Model.programName8 + "-FctList-IsLoaded\n";
foreach (var f in @Model.definitions.nestedFunctions.Concat(@Model.definitions.functions.Public, true)) {
items += " SET TC-"+@Model.programName8 + "-" +f.Hash+" TO ENTRY '"+f.Hash+"'\n";
}
items += " SET TC-" + @Model.programName8 + "-FctList-IsLoaded TO TRUE\n";
items += " END-IF\n";
items += " .\n\n";
if (@Model.definitions.nestedFunctions.Public.Count > 0) {
items += " set PntTab-Pnt TO ADDRESS OF TC-"+@Model.programName8+"-PntTab\n";
}
}
}
@items
the resulting transpiled code is the following
@SelfResult.Append(@"
");
var items = "";
if (@Model.definitions.nestedFunctions.Public.Count > 0) {
items += "*\n";
items += "* IF CallIsCopy\n";
items += "* PERFORM Copy-Process-Mode\n";
items += "* ELSE\n";
items += " PERFORM FctList-Process-Mode\n";
items += " perform INIT-LIBRARY\n";
items += "* END-IF\n\n";
items += " GOBACK.\n\n";
items += " FctList-Process-Mode.\n";
items += " IF NOT TC-" + @Model.programName8 + "-FctList-IsLoaded\n";
foreach (var f in @Model.definitions.nestedFunctions.Concat(@Model.definitions.functions.Public, true)) {
items += " SET TC-"+@Model.programName8 + "-" +f.Hash+" TO ENTRY '"+f.Hash+"'\n";
}
items += " SET TC-" + @Model.programName8 + "-FctList-IsLoaded TO TRUE\n";
items += " END-IF\n";
items += " .\n\n";
if (@Model.definitions.nestedFunctions.Public.Count > 0) {
items += " set PntTab-Pnt TO ADDRESS OF TC-"+@Model.programName8+"-PntTab\n";
@SelfResult.Append(@"
}
}
");@SelfResult.Append(@" ");@SelfResult.Append($@"{@items}");@SelfResult.Append(@"
");
The problem is that the two last } } brackets are considered by the CSharpCodeParser as Markup text thus the Tranpiler generates a String construction like:
@SelfResult.Append(@"
}
}
");
This a Microsoft .Razor issue to be investigated, by taking the original CSharpCodeParser and seing what is wrong.
A work around for this issue is to transform the script like for instance like that:
@{
var items = "";
if (@Model.definitions.nestedFunctions.Public.Count > 0) {
items += "*\n";
items += "* IF CallIsCopy\n";
items += "* PERFORM Copy-Process-Mode\n";
items += "* ELSE\n";
items += " PERFORM FctList-Process-Mode\n";
items += " perform INIT-LIBRARY\n";
items += "* END-IF\n\n";
items += " GOBACK.\n\n";
items += " FctList-Process-Mode.\n";
items += " IF NOT TC-" + @Model.programName8 + "-FctList-IsLoaded\n";
foreach (var f in @Model.definitions.nestedFunctions.Concat(@Model.definitions.functions.Public, true))
items += " SET TC-"+@Model.programName8 + "-" +f.Hash+" TO ENTRY '"+f.Hash+"'\n";
items += " SET TC-" + @Model.programName8 + "-FctList-IsLoaded TO TRUE\n";
items += " END-IF\n";
items += " .\n\n";
if (@Model.definitions.nestedFunctions.Public.Count > 0)
items += " set PntTab-Pnt TO ADDRESS OF TC-"+@Model.programName8+"-PntTab\n";
}
}
@items
AND the generated code will be:
@SelfResult.Append(@"
");
var items = "";
if (@Model.definitions.nestedFunctions.Public.Count > 0) {
items += "*\n";
items += "* IF CallIsCopy\n";
items += "* PERFORM Copy-Process-Mode\n";
items += "* ELSE\n";
items += " PERFORM FctList-Process-Mode\n";
items += " perform INIT-LIBRARY\n";
items += "* END-IF\n\n";
items += " GOBACK.\n\n";
items += " FctList-Process-Mode.\n";
items += " IF NOT TC-" + @Model.programName8 + "-FctList-IsLoaded\n";
foreach (var f in @Model.definitions.nestedFunctions.Concat(@Model.definitions.functions.Public, true)) {
items += " SET TC-"+@Model.programName8 + "-" +f.Hash+" TO ENTRY '"+f.Hash+"'\n";
}
items += " SET TC-" + @Model.programName8 + "-FctList-IsLoaded TO TRUE\n";
items += " END-IF\n";
items += " .\n\n";
if (@Model.definitions.nestedFunctions.Public.Count > 0) {
items += " set PntTab-Pnt TO ADDRESS OF TC-"+@Model.programName8+"-PntTab\n";
}
}
@SelfResult.Append($@"{@items}");@SelfResult.Append(@"
");
Update solution/project files to newest compiler:
netstandard 2.0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.