Skip to content

Conversation

@ajshedivy
Copy link

@ajshedivy ajshedivy commented Jan 13, 2025

Changes

Add RPG parser cli for AI tools.

to test cli:

  1. checkout feat/rpgparser-cli
  2. navigate to cli directory
cd cli/rpgparser
  1. build cli:
npm i 
npm run webpack:dev
  1. test cli:
node dist/index.js -h
node dist/index.js --files test/copy1.rpgle -o test.json          

Output:

{
  "keyword": {},
  "parameters": [],
  "subroutines": [],
  "procedures": [
    {
      "type": "procedure",
      "name": "theExtProcedure",
      "keyword": {
        "EXTPROC": true
      },
      "description": "",
      "tags": [],
      "position": {
        "path": "/Users/adamshedivy/Documents/IBM/sandbox/oss/vscode/vscode-rpgle/cli/rpgparse/test/copy1.rpgle",
        "range": {
          "start": 15,
          "end": 30,
          "line": 2
        }
      },
      "references": [
        {
          "uri": "/Users/adamshedivy/Documents/IBM/sandbox/oss/vscode/vscode-rpgle/cli/rpgparse/test/copy1.rpgle",
          "offset": {
            "start": 15,
            "end": 30,
            "line": 2
          }
        }
      ],
      "subItems": [
        {
          "type": "subitem",
          "name": "theNewValue",
          "keyword": {
            "CHAR": "20"
          },
          "description": "",
          "tags": [],
          "position": {
            "path": "/Users/adamshedivy/Documents/IBM/sandbox/oss/vscode/vscode-rpgle/cli/rpgparse/test/copy1.rpgle",
            "range": {
              "start": 42,
              "end": 53,
              "line": 3
            }
          },
          "references": [
            {
              "uri": "/Users/adamshedivy/Documents/IBM/sandbox/oss/vscode/vscode-rpgle/cli/rpgparse/test/copy1.rpgle",
              "offset": {
                "start": 42,
                "end": 53,
                "line": 3
              }
            }
          ],
          "subItems": [],
          "readParms": false,
          "range": {
            "start": null,
            "end": null
          }
        }
      ],
      "readParms": true,
      "range": {
        "start": 2,
        "end": 4
      }
    }
  ],
  "files": [],
  "variables": [],
  "structs": [],
  "constants": [],
  "sqlReferences": [],
  "indicators": [],
  "tags": [],
  "includes": []
}

Current usage:

Usage: "" [options]

Options:
  -f, --files <glob>       Specify the files to scan (required)
  -c, --cwd <directory>    Specify the current working directory
  -d, --outdir <directory> Specify the output directory
  -o, --output <file>      Specify the output file
  -h, --help               Display this help message

TODO:

  • how should cli handle reference paths ?
  • test and package on npm
  • documentation

Checklist

  • have tested my change
  • updated relevant documentation
  • Remove any/all console.logs I added
  • eslint is not complaining
  • have added myself to the contributors' list in the README
  • for feature PRs: PR only includes one feature enhancement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants