fglock / PerlOnJava

An implementation of the Perl programming language designed to run on the Java platform
Other
20 stars 1 forks source link

PerlOnJava Perl Compiler

This project presents a Perl compiler that compiles Perl into Java bytecode and runs it, providing a method to integrate Perl with Java-based ecosystems.

Table of Contents

  1. Introduction
  2. Features and Limitations
  3. Target Audience
  4. Build Instructions
  5. Running the JAR File
  6. Debugging Tools
  7. Internal Modules
  8. Milestones
  9. License

Introduction

This project aims to develop a Perl compiler that translates Perl code into Java bytecode and executes it on the Java Virtual Machine (JVM). It provides a platform for running Perl scripts in a JVM environment, facilitating integration between Perl and Java.

Features and Limitations

Features

For a detailed feature list, see the FEATURE_MATRIX.md.

Current Limitations

What This Project Is

Target Audience

Build Instructions

Compile and Package with Maven

  1. Ensure you have Maven installed:

  2. Compile and Package the Project:

    • Run the following Maven command to compile and package the project into a shaded JAR:
    mvn clean package
  3. Run the JAR:

    • After packaging, you can run the JAR file with:
    java -jar target/perlonjava-1.0-SNAPSHOT.jar

Compile and Package with Gradle

  1. Ensure you have Gradle installed:

  2. Compile and Package the Project:

    • Run the following Gradle command to compile and package the project into a shaded JAR:
    gradle clean build
  3. Run the JAR:

    • After packaging, you can run the JAR file with:
    java -jar target/perlonjava-1.0-SNAPSHOT.jar

Dependencies

Notes

Running the JAR File

  1. Show Instructions:

    java -jar target/perlonjava-1.0-SNAPSHOT.jar --help
  2. Execute Something:

    java -jar target/perlonjava-1.0-SNAPSHOT.jar -e ' print 123 '

Setting lib path with -I to access Perl modules is optional. Standard modules are included in the jar file.

Debugging Tools

  1. Execute Emitting Debug Information:

    java -jar target/perlonjava-1.0-SNAPSHOT.jar --debug -e ' print 123 '
  2. Compile Only; Can Be Combined with --debug:

    java -jar target/perlonjava-1.0-SNAPSHOT.jar -c -e ' print 123 '
    java -jar target/perlonjava-1.0-SNAPSHOT.jar --debug -c -e ' print 123 '
  3. Execute and Emit Disassembled ASM Code:

    java -jar target/perlonjava-1.0-SNAPSHOT.jar --disassemble -e ' print 123 '
  4. Run the Lexer Only:

    java -jar target/perlonjava-1.0-SNAPSHOT.jar --tokenize -e ' print 123 '
  5. Run the Parser Only:

    java -jar target/perlonjava-1.0-SNAPSHOT.jar --parse -e ' print 123 '

Internal Modules

Project Structure

/
├── src/
│   ├── main/
│   │   └── perl/
│   │   │   └── lib/
│   │   │       └── Perl modules (strict.pm, etc)
│   │   └── java/
│   │       └── org/
│   │           └── perlonjava/
│   │               ├── Main.java
│   │               ├── ArgumentParser.java
│   │               ├── scriptengine/
│   │               │   ├── PerlScriptEngine.java
│   │               │   └── other script engine classes
│   │               ├── astnode/
│   │               │   ├── Node.java
│   │               │   └── other AST node classes
│   │               ├── lexer/
│   │               │   ├── Lexer.java
│   │               │   └── other lexer classes
│   │               ├── parser/
│   │               │   ├── Parser.java
│   │               │   └── other parser classes
│   │               ├── perlmodule/
│   │               │   ├── Universal.java
│   │               │   └── other internalized Perl module classes
│   │               ├── operators/
│   │               |   ├── OperatorHandler.java
│   │               |   ├── ArithmeticOperators.java
│   │               |   └── other operator handling classes
│   │               └── runtime/
│   │                   ├── RuntimeScalar.java
│   │                   └── other runtime classes
│   └── test/
│       ├── java/
│       │   └── org/
│       │       └── perlonjava/
│       │           └── PerlLanguageProviderTest.java
│       └── resources/
│           └── Perl test files
├── build.gradle
├── pom.xml
├── settings.gradle
├── examples/
│   └── Perl example files
└── misc/
    └── project notes

Lexer and Parser

Code Generation

AST Nodes: Node

Runtime packages: Runtime and Operators

Perl Module classes

Main Method

PerlScriptEngine

Milestones

For detailed information on completed and upcoming milestones, see the MILESTONES.md.

License

This project is licensed under the Perl Artistic License 2.0 - see the LICENSE file for details.

Java CI with Maven

Additional Information

For more details on the relationship with the Perlito compiler, see RELATION_WITH_PERLITO_COMPILER.md.