-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for Peoplecode (#2302)
- Loading branch information
1 parent
fec39bc
commit bd4d816
Showing
14 changed files
with
414 additions
and
3 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
Prism.languages.peoplecode = { | ||
'comment': RegExp([ | ||
// C-style multiline comments | ||
/\/\*[\s\S]*?\*\//.source, | ||
// REM comments | ||
/\bREM[^;]*;/.source, | ||
// Nested <* *> comments | ||
/<\*(?:[^<*]|\*(?!>)|<(?!\*)|<\*(?:(?!\*>)[\s\S])*\*>)*\*>/.source, | ||
// /+ +/ comments | ||
/\/\+[\s\S]*?\+\//.source, | ||
].join("|")), | ||
'string': { | ||
pattern: /'(?:''|[^'\r\n])*'(?!')|"(?:""|[^"\r\n])*"(?!")/, | ||
greedy: true | ||
}, | ||
'variable': /%\w+/, | ||
'function-definition': { | ||
pattern: /((?:^|[^\w-])(?:function|method)\s+)\w+/i, | ||
lookbehind: true, | ||
alias: 'function' | ||
}, | ||
'class-name': { | ||
pattern: /((?:^|[^-\w])(?:as|catch|class|component|create|extends|global|implements|instance|local|of|property|returns)\s+)\w+(?::\w+)*/i, | ||
lookbehind: true, | ||
inside: { | ||
'punctuation': /:/ | ||
} | ||
}, | ||
'keyword': /\b(?:abstract|alias|as|catch|class|component|constant|create|declare|else|end-(?:class|evaluate|for|function|get|if|method|set|try|while)|evaluate|extends|for|function|get|global|implements|import|instance|if|library|local|method|null|of|out|peopleCode|private|program|property|protected|readonly|ref|repeat|returns?|set|step|then|throw|to|try|until|value|when(?:-other)?|while)\b/i, | ||
'operator-keyword': { | ||
pattern: /\b(?:and|not|or)\b/i, | ||
alias: 'operator' | ||
}, | ||
'function': /[_a-z]\w*(?=\s*\()/i, | ||
|
||
'boolean': /\b(?:false|true)\b/i, | ||
'number': /\b\d+(?:\.\d+)?\b/, | ||
'operator': /<>|[<>]=?|!=|\*\*|[-+*/|=@]/, | ||
'punctuation': /[:.;,()[\]]/ | ||
}; | ||
|
||
Prism.languages.pcode = Prism.languages.peoplecode; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
<h2>Full example</h2> | ||
<pre><code>/* Source: https://github.com/chrismalek/psoftToXML/blob/master/psftToXML.pcode */ | ||
|
||
class psoftToXML | ||
method RowsetToXML(&parentNode As XmlNode, &rowSetIn As Rowset) Returns XmlNode; | ||
method RecordToXML(&parentNode As XmlNode, &recordIn As Record) Returns XmlNode; | ||
method FieldToXML(&ParentNode As XmlNode, &fieldIn As Field) Returns XmlNode; | ||
method RowToXML(&ParentNode As XmlNode, &rowIn As Row) Returns XmlNode; | ||
method psoftToXML(); | ||
property array of string fieldsToSkip; | ||
private | ||
instance string &psObjectTypeString; | ||
end-class; | ||
|
||
method psoftToXML | ||
&psObjectTypeString = "PSOBJECTTYPE"; | ||
%This.fieldsToSkip = CreateArrayRept("", 0); | ||
end-method; | ||
|
||
method FieldToXML | ||
/+ &ParentNode as XmlNode, +/ | ||
/+ &fieldIn as Field +/ | ||
/+ Returns XmlNode +/ | ||
Local XmlNode &outNode; | ||
|
||
Local XmlNode &fldNode, &tempNode; | ||
|
||
&fldNode = &ParentNode.AddElement(&fieldIn.Name); | ||
|
||
&fldNode.AddAttribute("PSFIELDTYPE", &fieldIn.Type); | ||
&fldNode.AddAttribute(%This.psObjectTypeString, "FIELD"); | ||
|
||
If &fieldIn.IsEditXlat Then | ||
&fldNode.AddAttribute("LongTranslateValue", &fieldIn.LongTranslateValue); | ||
End-If; | ||
|
||
Evaluate &fieldIn.Type | ||
When = "LONGCHAR" | ||
When = "IMAGE" | ||
When = "IMAGEREFERENCE" | ||
If All(&fieldIn.Value) Then | ||
|
||
&tempNode = &fldNode.AddCDataSection(&fieldIn.Value); | ||
End-If; | ||
Break; | ||
|
||
When = "NUMBER"; | ||
&tempNode = &fldNode.AddText(&fieldIn.Value); | ||
Break; | ||
When-Other | ||
If All(&fieldIn.Value) Then | ||
&tempNode = &fldNode.AddText(&fieldIn.Value); | ||
End-If; | ||
|
||
Break; | ||
End-Evaluate; | ||
|
||
Return &outNode; | ||
end-method; | ||
|
||
|
||
method RecordToXML | ||
/+ &parentNode as XmlNode, +/ | ||
/+ &recordIn as Record +/ | ||
/+ Returns XmlNode +/ | ||
|
||
Local XmlNode &outNode, &fieldNode; | ||
|
||
Local integer &i; | ||
|
||
&outNode = &parentNode.AddElement(&recordIn.Name); | ||
|
||
&outNode.AddAttribute(%This.psObjectTypeString, "RECORD"); | ||
|
||
For &i = 1 To &recordIn.FieldCount | ||
|
||
If %This.fieldsToSkip.Find(&recordIn.GetField(&i).Name) <= 0 Then | ||
&fieldNode = %This.FieldToXML(&outNode, &recordIn.GetField(&i)); | ||
End-If; | ||
End-For; | ||
|
||
Return &outNode; | ||
end-method; | ||
|
||
|
||
method RowToXML | ||
/+ &ParentNode as XmlNode, +/ | ||
/+ &rowIn as Row +/ | ||
/+ Returns XmlNode +/ | ||
|
||
Local XmlNode &outNode, &recNode; | ||
|
||
Local integer &i; | ||
|
||
&outNode = &ParentNode.AddElement("ROW"); | ||
&outNode.AddAttribute(&psObjectTypeString, "ROW"); | ||
&outNode.AddAttribute("RowNumber", String(&rowIn.RowNumber)); | ||
|
||
For &i = 1 To &rowIn.RecordCount | ||
&recNode = %This.RecordToXML(&outNode, &rowIn.GetRecord(&i)); | ||
End-For; | ||
|
||
Local XmlNode &rsNode; | ||
For &i = 1 To &rowIn.ChildCount | ||
&rsNode = %This.RowsetToXML(&outNode, &rowIn.GetRowset(&i)); | ||
|
||
End-For; | ||
|
||
Return &outNode; | ||
end-method; | ||
|
||
|
||
method RowsetToXML | ||
/+ &parentNode as XmlNode, +/ | ||
/+ &rowSetIn as Rowset +/ | ||
/+ Returns XmlNode +/ | ||
|
||
Local XmlNode &outNode, &rowNode; | ||
|
||
Local integer &i; | ||
&outNode = &parentNode.AddElement(&rowSetIn.DBRecordName); | ||
&outNode.AddAttribute(&psObjectTypeString, "ROWSET"); | ||
|
||
For &i = 1 To &rowSetIn.ActiveRowCount | ||
&rowNode = %This.RowToXML(&outNode, &rowSetIn.GetRow(&i)); | ||
End-For; | ||
Return &outNode; | ||
end-method;</code></pre> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.