GithubHelp home page GithubHelp logo

jclparser's Introduction

Synopsis

This project enables z/OS developers to parse JCL and to then walk the parse tree. The default build creates a jcl2jcl program that can be used to just generate JCL from JCL. This is meant for testing and understanding of the code. A real use case would be to walk the parse trees to do some sort of analysis.

The altsrc and alttest and alttestsrc directories are historical and were used for testing the parser was working well. I am changing over to now just generate JCL from JCL so that I can 'diff' the output.

Code Example

Here is an example of jcl2jcl being used to parse orig.jcl and print it out.

jcl2jcl --input=testsrc/commented.jcl

The code works on z/OS or off. It has been tested on z/OS and on MacOS using clang.

Motivation

I am not a big fan of JCL, even though I have worked on z/OS forever. I also try to use Unix System Services as much as possible to develop software. jcl2jcl generates JCL from JCL - which can be handy if you want to 'normalize' or 'clean up' JCL.

Installation

To install jcl2jcl:

  • copy the files to z/OS Unix System Services directory. For this example, we assume it is /u/ibmuser/JCLParser
  • cd to the directory (/u/ibmuser/JCLParser)
  • install CMake, Ninja, GNU Make, clang if you haven't already and use the provided CMake code.
  • Alternately, just compile all the C code in src and link it.
  • The resultant program should be called jcl2jcl to use the sample parser.

Building on z/OS

  • Use z/OS Open Tools to download cmake, ninja, gnu make, and install clang.
  • export CLANG_ROOT to the root directory where you installed the clang compiler.
  • Generate build files if first build:
cd JCLParser
mkdir build
cd build
export CC=${CLANG_ROOT}/usr/lpp/IBM/oelcpp/v2r0/bin/clang
export CXX=${CLANG_ROOT}/usr/lpp/IBM/oelcpp/v2r0/bin/clang++ 
cmake ../
  • Re-build code:
cmake --build .

This will create a jcl2jcl binary in your build directory

Building on MacOS

  • Tailor the files in the .vscode directory to suit your needs.
  • cd /u/ibmuser/JCLParser
  • mkdir build
  • cd build
  • cmake ..
  • cmake --build .

API Reference

To get started reading the code, begin in jcl2jcl.c, which has main and drives all the functions in the other files.

Tests

Basic regression testing can be done after building jcl2jcl with:

  • cd tests
  • ./regression.sh

There should be no output. As bugs fixed, files with a filetype of skipjcl should be renamed to jcl to get included in regression testing.

Work to be done

The parser is complete as far as I know. Bug reports welcome. Providing interesting tools with the parser is TBD.

Contributors

Mike Fulton (IBM Canada) is the sole contributor at this point. I am happy to change this :)

The code still needs work. Error messages can (always) be improved and there are missing features people may need. If anyone wants to contribute, please reach out to [email protected] (Mike Fulton)

License

The code uses the Apache license

jclparser's People

Contributors

mikefultondev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

jclparser's Issues

the parms in jcl2sh

Mike, good day, a question, the sample in the README.MD:
jcl2sh <//'IBMUSER.TEST.JCL(UPDATE) >./update.sh
It don't send any message and neither create the update.sh ...
could you comment some action to verify the shell?

'Then' part of conditional not being written out in parsed output

Here is a diff:

< //DRVRCHKF IF (DRVRCHK.RC ^=0) THEN SEND FAILURE NOTE
---
> //DRVRCHKF IF (DRVRCHK.RC ^=0) THEN
52c52
< //COPY1OK  IF (DRVRCHK.RC = 0) THEN COPY FIRST PACK
---
> //COPY1OK IF (DRVRCHK.RC = 0) THEN
62c62
< //COPY1F   IF (COPY1.RC ^= 0) THEN SEND FAILURE NOTE
---
> //COPY1F IF (COPY1.RC ^= 0) THEN
120c120
< //CTIMEOUT IF (RESUBEX.RC ^=0) THEN SEND FINAL FAILURE NOTE
---
> //CTIMEOUT IF (RESUBEX.RC ^=0) THEN

Comment at end of conditionals is not retained

205c205
< // ENDIF /*ENDIF FOR THE IF STARTED AT STEPN007*/
---
> //  ENDIF

and

51c51
< //DOIT     ELSE    /*DG 04092012 FOR REQ C243
---
> //DOIT ELSE
56c56
< //DOIT   ENDIF     /*DG 04092012 FOR REQ C243

are two examples

Comment line in middle of parameters not treated as comment

Run jcl2jcl on https://github.com/MikeFultonDev/JCLParser/blob/main/testsrc/parmcomments.skipjcl with -v and you will see:

000000001 //IBMUSERC JOB 'CRTHFS'     Job Card                                            |
-> JOB Statement
000000002 //STEP1  EXEC PGM=IEFBR14,                                                      |
-> EXEC Statement
--> continued parameter
000000003 //* Comment                                                                     |
000000004 //       PARM='Hello World'                                                     |
//IBMUSERC JOB 'CRTHFS'  Job Card
//STEP1 EXEC PGM=IEFBR14,
Comment
// PARM='Hello World'

The comment is not being properly printed. Note that for this case, the comment is in the tree - here's a screen shot:

image

but note the newline at the start... So the 'printer' in genJCL could likely deal with this (should validate multi-line comments too).

Also: https://github.com/MikeFultonDev/JCLParser/blob/main/testsrc/odd.skipjcl and https://github.com/MikeFultonDev/JCLParser/blob/main/testsrc/commented.skipjcl

JCL to script generate

Hi @mikefultonbluemix ,

Please advice to me how to fix and run your source code?

Some info for your reference as below:
step 1: clone source and save my server.
step 2: create 2 folder

JCL2SH_SOURCE: save source code here
JCL2SH: empty
step 2:
cd to the directory (/u/ibmuser/JCL2SH) = /home/JCL2SH_SOURCE
edit setenv.sh to point to the various MVS programs that will be tested, and to specify where your code was copied to
=>export JCL2SH_ROOT=/home/JCL2SH
step 3:
create folder bin into folder /home/JCL2SH_SOURCE
step 4:
sh build.sh
please see result as below error:
[root@cock-01 JCL2SH]# sh build.sh
Build Default Version
gcc: error: unrecognized command line option ‘-Wc,FLAG(I)’
gcc: error: unrecognized command line option ‘-Wc,xplink,gonum,offset,langlvl(extended),list(./)’
gcc: error: unrecognized command line option ‘-Wc,FLAG(I)’
gcc: error: unrecognized command line option ‘-Wc,xplink,gonum,offset,langlvl(extended),list(./)’
gcc: error: unrecognized command line option ‘-Wc,FLAG(I)’
gcc: error: unrecognized command line option ‘-Wc,xplink,gonum,offset,langlvl(extended),list(./)’
gcc: error: unrecognized command line option ‘-Wc,FLAG(I)’
gcc: error: unrecognized command line option ‘-Wc,xplink,gonum,offset,langlvl(extended),list(./)’
gcc: error: unrecognized command line option ‘-Wc,FLAG(I)’
gcc: error: unrecognized command line option ‘-Wc,xplink,gonum,offset,langlvl(extended),list(./)’
gcc: error: jcl2sh.o: No such file or directory
gcc: error: scanjcl.o: No such file or directory
gcc: error: gensh.o: No such file or directory
gcc: error: jclargs.o: No such file or directory
gcc: error: jclmsgs.o: No such file or directory

Please advice to how to run your source and document guilde step by step. Thanks for the support.

Thanks and best regards,
Nho Luong.

@nluong9

sintax error on line 707 of scanjcl.c program

The compilation is generating a CCN3046 "sintax error" in line 707 of scanjcl.c program->
KeyValuePair_T* kvp = cur->kvphead;

to eliminate this error, I fixed it adding an->"else {", in line 606 and other->"}" just before the line 743
and then the compilation was ok! and it generates the module jcl2sh in the bin directory ,... but
The problem is at execution time of the jcl2sh to generate the shell, it does not do anything!...

jcl2sh <//'IBMUSER.TEST.JCL(UPDATE) >./update.sh

do you know, what is happening? or an idea or suggestion to fix this situation?
Is it correct the sintax of the execution jcl2sh? is it missing something else?
Thanks a lot for your help!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.