Skip to content

Commit fa96917

Browse files
committed
Update README.md
1 parent 9a6ebca commit fa96917

1 file changed

Lines changed: 37 additions & 18 deletions

File tree

README.md

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@
66
## Introduction
77

88
**MicroJava** is a *high-level programming language*.
9-
As the name suggests, **MicroJava** is *similar* to **Java** (which you are, probably, already familiar with), but it's *simpler*.
10-
Similarly to Java, MicroJava source files are compiled to **bytecode**, which is then executed by a **virtual machine** (it's called (as you might have guessed) **MicroJava Virtual Machine**). MicroJava VM is a simple *interpretative emulator* (i.e. it does not have any support for some "fancy" techniques such as, e.g., *Just-In-Time compilation*).
9+
As the name suggests, **MicroJava** is *similar* to **Java** (which you are, probably, already familiar with), but it's
10+
*simpler*.
11+
Similarly to Java, MicroJava source files are compiled to **bytecode**, which is then executed by a **virtual machine**
12+
(it's called (as you might have guessed) **MicroJava Virtual Machine**). MicroJava VM is a simple
13+
*interpretative emulator* (i.e. it does not have any support for some "fancy" techniques such as, e.g.,
14+
*Just-In-Time compilation*).
1115

1216
![Compilation process](.readme/compilation.png)
1317

14-
The project specification can be found [here](https://1drv.ms/b/s!AuZ7wmWsDfythjkXnkK3T5gJ7NIy) and [here](https://1drv.ms/b/s!AuZ7wmWsDfythjgxu8VErKo9wBa7) (Serbian language only).
15-
This implementation uses a modern, Gradle-based directory structure rather than the ad-hoc structure suggested in the original project specification.
18+
This project is based on a university-level compiler construction assignment. However, this implementation has been
19+
significantly refactored to align with modern industry standards, including a Gradle-based build system, automated
20+
CI workflow, and a clean, modular directory structure.
1621

1722
## Main language features
1823

@@ -21,7 +26,8 @@ This implementation uses a modern, Gradle-based directory structure rather than
2126
* The main method of a MicroJava program is always called `main`.
2227
When MicroJava program is executed, this method is called first (i.e. it's the program's entry point).
2328
* There are:
24-
* Value/primitive types (`int`, `char` and `bool`) and reference/structured types (one-dimensional arrays and user-defined classes)
29+
* Value/primitive types (`int`, `char` and `bool`) and reference/structured types (one-dimensional arrays and
30+
user-defined classes)
2531
* Integer, character and boolean constants
2632
* Global, local and class variables (i.e. fields)
2733
* Global (static) and class functions (i.e. methods).
@@ -34,14 +40,17 @@ This implementation uses a modern, Gradle-based directory structure rather than
3440
The act of converting a subclass reference into a superclass reference is called up-casting.
3541
* Superclass methods can be **overridden** in its subclass.
3642
Because of that, method binding occurs at run-time, based on the type of the object.
37-
This is **polymorphism** (also called dynamic binding or late binding or run‐time binding) and it is a key principle of OOP.
38-
* Within a method, the name of a field refers to the current object's field, assuming that the field isn't hidden by a method parameter.
43+
This is **polymorphism** (also called dynamic binding or late binding or run‐time binding) and it is a key principle
44+
of OOP.
45+
* Within a method, the name of a field refers to the current object's field, assuming that the field isn't hidden by a
46+
method parameter.
3947
If it is hidden, we can access it through `this.<field-name>`.
4048
In the body of a method, `this` represents reference to the object whose method has been invoked.
4149
* Method overloading is not supported in MicroJava.
4250
* There is no `Object` class, the top‐most class, the class from which all other classes are implicitly derived.
4351
* There is no garbage collector (allocated objects are only deallocated when the program ends).
44-
* Predeclared static methods are `ord` (converts `char` to `int`), `chr` (converts `int` to `char`) and `len` (returns array's length).
52+
* Predeclared static methods are `ord` (converts `char` to `int`), `chr` (converts `int` to `char`) and `len` (returns
53+
array's length).
4554

4655
## Syntax specification
4756

@@ -86,21 +95,31 @@ This implementation uses a modern, Gradle-based directory structure rather than
8695
`charConst` is a sequence starting with `'` followed by a single printable character and ending with `'`.
8796
`boolConst` is either `true` or `false`.
8897

89-
MicroJava's single line comment starts with two forward slashes with no white spaces (`//`) and lasts till the end of line.
98+
MicroJava's single line comment starts with two forward slashes with no white spaces (`//`) and lasts till the end of
99+
line.
90100

91101
## Building and testing the project
92102

93-
To build and test this project you will need [Java 17](https://adoptium.net/temurin/) (the latest LTS release as of February 2023) and [Gradle 7.3](https://docs.gradle.org/current/userguide/userguide.html).
94-
Open command-line interpreter and type one of the following commands:
95-
96-
* `gradlew lexer` (Windows) or `./gradlew lexer` (macOS and Linux) — to generate lexer (tokenizer) implementation (`MJLexer.java`) based on [lexer specification](src/main/resources/mjlexer.flex).
97-
* `gradlew parser` (Windows) or `./gradlew parser` (macOS and Linux) — to generate parser implementation (`MJParser.java`, `sym.java`) and abstract syntax tree implementation (classes inside `ast` directory), based on [parser specification](src/main/resources/mjparser.cup).
98-
* `gradlew build` (Windows) or `./gradlew build` (macOS and Linux) — to build the project, test the compiler and run MicroJava VM. MicroJava Compiler will compile the test file [`simple_calculator.mj`](src/test/resources/simple_calculator.mj) and produce `simple_calculator.obj`. Then, the machine code inside `simple_calculator.obj` will be executed by MicroJava VM.
99-
Note that, for testing purposes, standard input has been substituted with a file named [`input_stream.txt`](src/test/resources/input_stream.txt).
100-
* `gradlew disassemble` (Windows) or `./gradlew disassemble` (macOS and Linux) — to disassemble `simple_calculator.obj` produced in the previous step, using [`rs.etf.pp1.mj.runtime.disasm`](libs/mj-runtime-1.1.jar).
103+
To build and test this project you will need [Java 25](https://adoptium.net/temurin/releases?version=25&os=any&arch=any)
104+
(the latest LTS release as of February 2026) and
105+
[Gradle 9.3.1](https://services.gradle.org/distributions/gradle-9.3.1-all.zip). Open command-line interpreter and type
106+
one of the following commands:
107+
108+
* `gradlew lexer` (Windows) or `./gradlew lexer` (macOS and Linux) — to generate lexer (tokenizer) implementation
109+
(`MJLexer.java`) based on [lexer specification](src/main/resources/mjlexer.flex).
110+
* `gradlew parser` (Windows) or `./gradlew parser` (macOS and Linux) — to generate parser implementation
111+
(`MJParser.java`, `sym.java`) and abstract syntax tree implementation (classes inside `ast` directory), based on
112+
[parser specification](src/main/resources/mjparser.cup).
113+
* `gradlew build` (Windows) or `./gradlew build` (macOS and Linux) — to build the project, test the compiler and run
114+
MicroJava VM. MicroJava Compiler will compile the test file [`simple_calculator.mj`](src/test/resources/simple_calculator.mj) and produce
115+
`simple_calculator.obj`. Then, the machine code inside `simple_calculator.obj` will be executed by MicroJava VM. Note
116+
that, for testing purposes, standard input has been substituted with a file named [`input_stream.txt`](src/test/resources/input_stream.txt).
117+
* `gradlew disassemble` (Windows) or `./gradlew disassemble` (macOS and Linux) — to disassemble `simple_calculator.obj`
118+
produced in the previous step, using [`rs.etf.pp1.mj.runtime.disasm`](libs/mj-runtime-1.1.jar).
101119

102120
You can always run MicroJava Compiler as a standalone application.
103-
In order to achieve this, you just have to type `gradlew run <source-file-name> <obj-file-name>` (Windows) or `./gradlew run <source-file-name> <obj-file-name>` (macOS and Linux).
121+
In order to achieve this, you just have to type `gradlew run <source-file-name> <obj-file-name>` (Windows) or
122+
`./gradlew run <source-file-name> <obj-file-name>` (macOS and Linux).
104123

105124
---
106125
**If you find this repository useful, please consider starring it! ⭐**

0 commit comments

Comments
 (0)