JSON Output - TypeCobolTeam/TypeCobol GitHub Wiki
Proposal of JSON dump to be produced by our paser, feel free to comment! ٩(•̤̀ᵕ•̤́๑)
{
"Files": [
{
"Sample": "path/to/sample.cbl", // (string) path to COBOL sample file
"Result": "path/to/result.txt", // (string) path to expected result file
"CodeElements": [ // list of CodeElements parsed in sample file
{ // CodeElement
"Type": "IfStatement", // (string) CodeElement class name
"FirstTokenLineIndexInMainDocument": 42, // (int >0) line of the CodeElement 1st token
"LastTokenLineIndexInMainDocument": 44, // (int >0) line of the CodeElement last token
"ConsumedTokens": [ // list of Tokens (ie. "words") composing this CodeElements
{ // first token
"Type": "IF", // (string) reserved words are their own type
"Text": "IF", // (string) words composing the Token
"Line": 42, // (int >0) on which line is the Token
"Column": 1, // (int >0) starting character of the Token as long as of the CodeElement
"EndColumn": 2, // (int >0) last character
"UsesVirtualSpaceAtEndOfLine": false // (boolean) used for line continuations
},
// ... other tokens ...
{ // last token
"Type": "UserDefinedWord", // all that is not a reserved word / literal / identifier
"Text": "toto",
"Line": 44, // a CodeElement can be across multiple lines (first was on line 42)
"Column": 3,
"EndColumn": 7,
"UsesVirtualSpaceAtEndOfLine": false // this is true for some Tokens of multiline CodeElements
}
],
"Diagnostics": [
{
"ColumnStart": 4, // (int >0) character where the red waves underlining should begin
"ColumnEnd": 15, // (int >0) character where the red waves underlining should end
"Message": "<description of the problem>", // (string) error message -english only for now
"Code": 28, // (int) error code
"Severity": "error", // "error" | "warning" | "info"
"Category": "Syntax" // "TextFormat" | "Tokens" | "Directives" | "Syntax" | "Semantics"
"OffendingSymbol": {
// this is one of the Tokens of the "ConsumedTokens" list
},
"RuleStack": "rules>used>to>try>to>reduce>this>set>of>symbols"
}
]
}
],
// 'legacy' diagnostics can be linked to the whole document instead of a specific Token ;
// in this case, you could use the Diagnostic's "OffendingSymbol" to locate the error.
// Not an ideal solution, I know ⊙︿⊙
// We'll get rid of this "document wide" diagnostics ... someday
"Diagnostics": []
}
]
}