Conversion of PL/I code into similar Java code. It is a fork of my plithon PL/I to Python project.
Important: this work is primarily the intermediate result of a learning process. It is not intended to be the full realisation of the work shown in the title. It contains errors which I am trying to correct. It is not complete, but will be expanded.
plijava is a lightweight PL/I → Java transpiler and runtime helper. It parses a subset of PL/I source code, generates equivalent Java source, optionally compiles it with javac, and can run the resulting class. The project is intended as a practical proof-of-concept and learning tool for converting simple PL/I programs to Java.
This repository contains:
plijava.py— main transpiler (lexer, parser, code generator, runner)pl1code/— example PL/I input files used as test casesjavalib/— Java runtime helpers (DriverShim, PliJavaRuntime, RndRuntime)run.py— small non-interactive wrapper to run the transpilerrequirements.txt— Python dependenciestests/— minimal pytest integration tests
Status: functional proof-of-concept. The tool supports a useful subset of PL/I but is not a complete PL/I translator. See the code and tests for specifics.
- Parse PL/I procedure definitions and declarations
- Translate basic statements: assignments, arithmetic,
if,doloops,select/when,put/skipoutput - One- and two-dimensional arrays (integer indexing)
- Record-style declarations (basic support)
exec sql "..." into var;support for simple SQL-to-variable mapping (MySQL/DB2 via JDBC)- Generate helper classes for database access and random utilities
- Optional automatic invocation of
javacandjavato compile/run generated code
plijava.pyuses PLY (lex/yacc) to parse PL/I.- The parser emits Java source strings.
- The script writes generated Java to
<classname>.java, formats (optional), compiles withjavac, and runs withjava.
- Python 3.8+
- Java Development Kit (JDK) with
javacandjavaavailable (or setJAVA_HOME) - Python dependencies (see
requirements.txt):ply(andpytestfor tests) - MySQL Java JDBC driver (for MySQL support) or IBM's JDBC driver (for Db2 Community Edition)
- Optional:
astyleopen source Java formatter for beautified Java output
- Clone or copy this repository into a working directory.
- (Recommended) Create and activate a Python virtual environment:
python -m venv .venv
.\.venv\Scripts\Activate.ps1 # PowerShell on Windows- Install Python dependencies:
pip install -r requirements.txt- Ensure a JDK is installed and either:
- set
JAVA_HOME(recommended), or - have
javac/javaon yourPATH.
- set
- Tested only under Windows 11
- Call the program:
python plijava.py - Select your PL/I input file in the explorer window
- If you want to include SQL statements, store your credentials in
c:/temp/creds.txt(location can be overridden withPLIJAVA_CREDS_FILE).
Interactive (file dialog):
python plijava.pyNon-interactive (useful for CI or scripts):
python run.py --input pl1code/simple.pliEnvironment variables supported:
PLIJAVA_INPUT_FILE— path to PL/I input filePLIJAVA_CREDS_FILE— path to credentials file for SQL operations (falls back toc:/temp/creds.txt)PLIJAVA_DEBUG— set to1ortrueto enable debug loggingJAVA_HOME/JDK_HOME— used to locatejavac/javaif not onPATH
Credentials file format (single record):
host="localhost", user="root", password="secret", database="sakila", dbsys="mysql", jdbc_path="C:/path/to/mysql-connector.jar", port="3306"
pytest -qTests exercise that plijava.py runs and, if javac is present, attempt to compile generated Java.
dcl variable-name <fixed bin(15|31) | char(length)>;variable = <arithmetic-expression> | <string-expression>;- operators in arithmetic_expression:
+ - * / ( ) - operators in string-expression: builtins:
substr index decimal if relational-expression then statement else statement;select(expression) when(value) statement; other statement; end;put skip list(variable | constant);- one-dimensional arrays (only integer indexing)
- record i/o simple version (open close read write)
- do-while loop
exec sql "select sql-select-field" into variable;— MySQL and Db2 connectionget list(variable-list);— read variables from console per prompt
- The transpiler implements a useful subset of PL/I; many features are not supported or are partially supported (see code comments).
- Developed primarily on Windows; path handling is Windows-oriented.
parsetab.pyis generated by PLY; regenerate it only when grammar changes.- Avoid committing real credentials — use
PLIJAVA_CREDS_FILEto point to a local file outside the repo.
This repository is provided as-is for educational and experimental use.