peoplecodeparser


Namepeoplecodeparser JSON
Version 1.1.6 PyPI version JSON
download
home_pagehttps://github.com/lbaca/PeopleCodeParser
SummaryA PeopleCode parser built with ANTLR 4
upload_time2023-04-10 18:13:24
maintainer
docs_urlNone
authorLeandro Baca
requires_python~=3.6
license
keywords parser peoplesoft peoplecode source application-class application-package antlr antlr4
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PeopleCode Parser Built with ANTLR 4

## About

This project provides an implementation of a PeopleCode parser for programs of all types (event PeopleCode and Application Classes).

It is initially based on PeopleTools 8.56, but built-in functions (the language constructs most susceptible to change between PeopleTools versions) are not referenced individually in the grammar, thereby making it suitable for other PeopleTools versions as well.

## Goals

The primary goal of this parser is to enable applications which analyze PeopleCode and validate coding standards. An example of such an application is the [Static Code Analyzer](https://github.com/lbaca/PSCodeAnalyzer). Said application can use the parser to enforce rules such as "`SQLExec` function calls shall not use string literals as the first argument" (see [test_parser.py](https://github.com/lbaca/PeopleCodeParser/blob/main/tests/test_parser.py#L22-L44) for this precise example).

Another application of the parser is to build documentation generators, such as [AppClassDoc](https://github.com/lbaca/appclassdoc).

As mentioned in the "[About](#About)" section above, the parser grammar does not reference individual built-in functions, which a parser aimed at, say, compiling the language would need to do. For example, it will not enforce the fact that the `SQLExec` function requires a first argument that is either a string or a SQL definition reference, and then has zero or more literals, variable references, Record Field references, etc. Valid PeopleCode programs should be successfully parsed by this parser (with the one exception described further below), but it would also be possible to write a syntactically correct PeopleCode program that would fail to compile due to semantic issues, as in the following absurd example:

```
Local SOME:APPLICATION:Class &anObject;

If SQLExec(&anObject) > &anObject Then
   SomeMadeUpFunction(&anObject);
End-If;
```

This PeopleCode snippet would be accepted as syntactically valid by the parser but would fail to compile in Application Designer.

## Parser Implementation

See the [main project site](https://github.com/lbaca/PeopleCodeParser) for details about the parser's implementation.

## Exceptions to Successful Parsing

The parser was tested against 96,136 PeopleCode programs and Application Classes that fall into one of the following categories:

* They were delivered by Oracle as part of the PeopleSoft HCM 9.2 application (image \#32); or
* They were custom code developed by me for one of my customers; or
* They were part of the development carried out as part of my dissertation (see the [acknowledgements](#Acknowledgements) below).

Of these PeopleCode programs and Application Classes, 96,134 (99.998%) were parsed successfully, and only two Page PeopleCode programs failed to parse. Both errors are attributable to quirks that occur with Directive PeopleCode. Resolving Directive PeopleCode would require a pre-compilation task, but since this is out of scope for the aforementioned [goals](#Goals), the parser simply treats Directive PeopleCode as if it weren't there.

The first error occurs in the `HR_MSS_CT_CONF_FL` Page Activate event, reproduced here in its entirety:

```
import HR_GUIDED_SELF_SERVICE:Pages:*;

Declare Function UseGSSActivityGuide PeopleCode FUNCLIB_HR_GSS.HR_MSS_CT_NAME FieldFormula;

Local HR_GUIDED_SELF_SERVICE:Pages:ConfirmationPageActivate &Confirmation;

&Confirmation = create HR_GUIDED_SELF_SERVICE:Pages:ConfirmationPageActivate();
#If #ToolsRel >= "8.55" #Then
   If UseGSSActivityGuide() Then
      &Confirmation.Activate( True);
   Else
      &Confirmation.Activate( False);
   End-If
#Else
&Confirmation.Activate( False);
#End-If;
```

Note how the `End-If` immediately above the `#Else` directive does not have a trailing semicolon. If the Directive PeopleCode statements were not present, the semicolon would actually be required.

The second error occurs in the `PT_HEADERPAGE` Page Activate event (excerpted below):

```
#If #toolsrel < "8.55.13" #Then
   If Not (IsLogoutEnabled()) Then
#Else
   /* 855-13a - Support guest disabling of Signout via permission */
   If Not (IsLogoutEnabled()) Or
         (IsIScriptAuthorized("WEBLIB_PORTAL", "PT_PORTAL_HDRLINK", "FieldFormula", "IScript_HideSignOutLink", %Action_UpdateDisplay) And
            Not (IsUserInRole("PeopleSoft Administrator"))) Then
   #End-If
   
   PT_WORK.PT_BUTTON_LOGOUT.Visible = False;
End-If;
```

When the Directive PeopleCode statements are ignored, the two `If` statements on the second and fifth lines become unbalanced with the single `End-If` on the last line.

Of the 96,136 PeopleCode programs tested, only 256 (0.27%) included Directive PeopleCode, of which only these two (0.78% of all programs with Directive PeopleCode, and 0.002% overall) cause parsing issues. Considering that custom PeopleCode will rarely (if ever) include Directive PeopleCode statements, and that even if it did it would be unlikely to manifest one of these two quirks, I believe we can live with these odds.

## Acknowledgements

The parser was intially written out of simple curiosity, but was later included as part of the deliverables for my Master of Science dissertation at the University of Liverpool, titled "A Framework for Customizing ERP Systems to Increase Software Reuse and Reduce Rework When Challenged with Evolving Requirements." I mention this primarily in gratitude to my employer, who graciously waived their claim to intellectual property on my work as part of this academic pursuit.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/lbaca/PeopleCodeParser",
    "name": "peoplecodeparser",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "~=3.6",
    "maintainer_email": "",
    "keywords": "parser peoplesoft peoplecode source application-class application-package antlr antlr4",
    "author": "Leandro Baca",
    "author_email": "leandrobaca77@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/3b/bf/6210bb0b93d1f72789a91a8f58e8663e4434f43b941fc8a15506acc19467/peoplecodeparser-1.1.6.tar.gz",
    "platform": null,
    "description": "# PeopleCode Parser Built with ANTLR 4\r\n\r\n## About\r\n\r\nThis project provides an implementation of a PeopleCode parser for programs of all types (event PeopleCode and Application Classes).\r\n\r\nIt is initially based on PeopleTools 8.56, but built-in functions (the language constructs most susceptible to change between PeopleTools versions) are not referenced individually in the grammar, thereby making it suitable for other PeopleTools versions as well.\r\n\r\n## Goals\r\n\r\nThe primary goal of this parser is to enable applications which analyze PeopleCode and validate coding standards. An example of such an application is the [Static Code Analyzer](https://github.com/lbaca/PSCodeAnalyzer). Said application can use the parser to enforce rules such as \"`SQLExec` function calls shall not use string literals as the first argument\" (see [test_parser.py](https://github.com/lbaca/PeopleCodeParser/blob/main/tests/test_parser.py#L22-L44) for this precise example).\r\n\r\nAnother application of the parser is to build documentation generators, such as [AppClassDoc](https://github.com/lbaca/appclassdoc).\r\n\r\nAs mentioned in the \"[About](#About)\" section above, the parser grammar does not reference individual built-in functions, which a parser aimed at, say, compiling the language would need to do. For example, it will not enforce the fact that the `SQLExec` function requires a first argument that is either a string or a SQL definition reference, and then has zero or more literals, variable references, Record Field references, etc. Valid PeopleCode programs should be successfully parsed by this parser (with the one exception described further below), but it would also be possible to write a syntactically correct PeopleCode program that would fail to compile due to semantic issues, as in the following absurd example:\r\n\r\n```\r\nLocal SOME:APPLICATION:Class &anObject;\r\n\r\nIf SQLExec(&anObject) > &anObject Then\r\n   SomeMadeUpFunction(&anObject);\r\nEnd-If;\r\n```\r\n\r\nThis PeopleCode snippet would be accepted as syntactically valid by the parser but would fail to compile in Application Designer.\r\n\r\n## Parser Implementation\r\n\r\nSee the [main project site](https://github.com/lbaca/PeopleCodeParser) for details about the parser's implementation.\r\n\r\n## Exceptions to Successful Parsing\r\n\r\nThe parser was tested against 96,136 PeopleCode programs and Application Classes that fall into one of the following categories:\r\n\r\n* They were delivered by Oracle as part of the PeopleSoft HCM 9.2 application (image \\#32); or\r\n* They were custom code developed by me for one of my customers; or\r\n* They were part of the development carried out as part of my dissertation (see the [acknowledgements](#Acknowledgements) below).\r\n\r\nOf these PeopleCode programs and Application Classes, 96,134 (99.998%) were parsed successfully, and only two Page PeopleCode programs failed to parse. Both errors are attributable to quirks that occur with Directive PeopleCode. Resolving Directive PeopleCode would require a pre-compilation task, but since this is out of scope for the aforementioned [goals](#Goals), the parser simply treats Directive PeopleCode as if it weren't there.\r\n\r\nThe first error occurs in the `HR_MSS_CT_CONF_FL` Page Activate event, reproduced here in its entirety:\r\n\r\n```\r\nimport HR_GUIDED_SELF_SERVICE:Pages:*;\r\n\r\nDeclare Function UseGSSActivityGuide PeopleCode FUNCLIB_HR_GSS.HR_MSS_CT_NAME FieldFormula;\r\n\r\nLocal HR_GUIDED_SELF_SERVICE:Pages:ConfirmationPageActivate &Confirmation;\r\n\r\n&Confirmation = create HR_GUIDED_SELF_SERVICE:Pages:ConfirmationPageActivate();\r\n#If #ToolsRel >= \"8.55\" #Then\r\n   If UseGSSActivityGuide() Then\r\n      &Confirmation.Activate( True);\r\n   Else\r\n      &Confirmation.Activate( False);\r\n   End-If\r\n#Else\r\n&Confirmation.Activate( False);\r\n#End-If;\r\n```\r\n\r\nNote how the `End-If` immediately above the `#Else` directive does not have a trailing semicolon. If the Directive PeopleCode statements were not present, the semicolon would actually be required.\r\n\r\nThe second error occurs in the `PT_HEADERPAGE` Page Activate event (excerpted below):\r\n\r\n```\r\n#If #toolsrel < \"8.55.13\" #Then\r\n   If Not (IsLogoutEnabled()) Then\r\n#Else\r\n   /* 855-13a - Support guest disabling of Signout via permission */\r\n   If Not (IsLogoutEnabled()) Or\r\n         (IsIScriptAuthorized(\"WEBLIB_PORTAL\", \"PT_PORTAL_HDRLINK\", \"FieldFormula\", \"IScript_HideSignOutLink\", %Action_UpdateDisplay) And\r\n            Not (IsUserInRole(\"PeopleSoft Administrator\"))) Then\r\n   #End-If\r\n   \r\n   PT_WORK.PT_BUTTON_LOGOUT.Visible = False;\r\nEnd-If;\r\n```\r\n\r\nWhen the Directive PeopleCode statements are ignored, the two `If` statements on the second and fifth lines become unbalanced with the single `End-If` on the last line.\r\n\r\nOf the 96,136 PeopleCode programs tested, only 256 (0.27%) included Directive PeopleCode, of which only these two (0.78% of all programs with Directive PeopleCode, and 0.002% overall) cause parsing issues. Considering that custom PeopleCode will rarely (if ever) include Directive PeopleCode statements, and that even if it did it would be unlikely to manifest one of these two quirks, I believe we can live with these odds.\r\n\r\n## Acknowledgements\r\n\r\nThe parser was intially written out of simple curiosity, but was later included as part of the deliverables for my Master of Science dissertation at the University of Liverpool, titled \"A Framework for Customizing ERP Systems to Increase Software Reuse and Reduce Rework When Challenged with Evolving Requirements.\" I mention this primarily in gratitude to my employer, who graciously waived their claim to intellectual property on my work as part of this academic pursuit.\r\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A PeopleCode parser built with ANTLR 4",
    "version": "1.1.6",
    "split_keywords": [
        "parser",
        "peoplesoft",
        "peoplecode",
        "source",
        "application-class",
        "application-package",
        "antlr",
        "antlr4"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cda7578e32ffba0d8db539d10e1bd05997a98b2b4df42c2dc60ce74c8fda6581",
                "md5": "269d8643454e4068527a0897763fae69",
                "sha256": "ccbe41fe94eac38606248a2d0362795ef4d3afbcdc8e38de6a6be885708ce3ac"
            },
            "downloads": -1,
            "filename": "peoplecodeparser-1.1.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "269d8643454e4068527a0897763fae69",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "~=3.6",
            "size": 69797,
            "upload_time": "2023-04-10T18:13:17",
            "upload_time_iso_8601": "2023-04-10T18:13:17.203238Z",
            "url": "https://files.pythonhosted.org/packages/cd/a7/578e32ffba0d8db539d10e1bd05997a98b2b4df42c2dc60ce74c8fda6581/peoplecodeparser-1.1.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3bbf6210bb0b93d1f72789a91a8f58e8663e4434f43b941fc8a15506acc19467",
                "md5": "91e568c4750b21ca3647df3c79837ef5",
                "sha256": "4be735bb1cd9eca38ff67b35fa3cff39b769a3dd77caa1447d619672168d2455"
            },
            "downloads": -1,
            "filename": "peoplecodeparser-1.1.6.tar.gz",
            "has_sig": false,
            "md5_digest": "91e568c4750b21ca3647df3c79837ef5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "~=3.6",
            "size": 71310,
            "upload_time": "2023-04-10T18:13:24",
            "upload_time_iso_8601": "2023-04-10T18:13:24.202312Z",
            "url": "https://files.pythonhosted.org/packages/3b/bf/6210bb0b93d1f72789a91a8f58e8663e4434f43b941fc8a15506acc19467/peoplecodeparser-1.1.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-10 18:13:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "lbaca",
    "github_project": "PeopleCodeParser",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "peoplecodeparser"
}
        
Elapsed time: 0.05804s