Go to file
Lucas f7a4e65093
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
E2E Running
Other tests and make refactored
2024-07-04 14:35:02 +02:00
.gitea/workflows added maven test 2024-05-14 17:59:53 +02:00
.idea Huge Changes in TestFiles, ReflectionsTest, much more 2024-07-03 13:04:33 +02:00
.lib small changes 2024-07-03 17:43:09 +02:00
src E2E Running 2024-07-04 14:35:02 +02:00
.gitignore Update .gitignore 2024-06-26 16:22:38 +02:00
Kurzdokumentation.md small changes 2024-07-03 17:43:09 +02:00
pom.xml E2E Running 2024-07-04 14:35:02 +02:00
readme.md E2E Running 2024-07-04 14:35:02 +02:00

"Nicht Haskel 2.0" Java Compiler

Realisation of a subset of the Java Standard Compiler in the course Compiler Construction of the 4th semester Computer Science at the Duale Hochschule Suttgart (Horb).

This project aims to provide a simplified version of the Java compiler, focusing on key language features and demonstrating the principles of compiler construction.

Realised Java syntax

  • Data types: int, boolean, char
  • Access modifier: public, protected, private
  • Operators: = + - * % / > < >= <= == != ! && || ++ --
  • Keywords: class, this, while, do, if, else, for, return, new, switch, case, break, default, :
  • Statements:
    • if ... if else ... else;
    • while ... ;
    • do ... while;
    • for;
    • switch ... case ... ;
  • Comments:
    • Single line: // comment
    • Multi-line: /* comment */
  • Further functions:
    • All methods are overloadable
    • High maintainability and expandability through implementation of the visitor pattern
    • Logging Input and Outputs
    • Error Handling in the Semantic Check

Project Structure

src/
└── main/
    ├── java/
    │   ├── ast/              -> Defining the structure of the AST
    │   ├── bytecode/         -> Generate Java bytecode
    │   ├── main/             -> Running the compiler
    │   ├── parser/
    │   │   ├── astBuilder/   -> Builder creating the AST
    │   │   ├── generated/    -> Antlr generated grammar
    │   │   └── grammar/      -> Antlr grammar
    │   ├── semantic/         -> Running the semantic check
    │   └── visitor/          -> Visitor interface
    └── resources/
test/
└── java/
│   ├── main/
│   ├── parser/               -> Performs tests on the parser
│   └── semantic/
└── resources/            -> Ressources for running the Tests
    ├──input
    │  ├── combinedFeatureTests
    │  ├── endabgabeTests
    │  ├── failureTests
    │  ├── singleFeatureSemanticTests
    │  ├── singleFeatureTests
    │  ├── typedAstExceptionsTests
    │  └── typedAstFeatureTests
    └──output
        ├── javac
        └── raupenpiler

Class-Diagramm AST

AST Diagramm

Used Tools

  • Maven 4.0
    • Used for automating the build process and managing dependencies.
  • ANTLR4 v.13.1
    • Used to parse the input Java code into the Abstract Syntax Tree.

How to run the compiler

Download