https://github.com/b72u68/smalljava
Mini Java programming language
https://github.com/b72u68/smalljava
Last synced: 4 days ago
JSON representation
Mini Java programming language
- Host: GitHub
- URL: https://github.com/b72u68/smalljava
- Owner: b72u68
- Created: 2022-02-19T03:37:33.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-04-10T16:05:33.000Z (over 3 years ago)
- Last Synced: 2025-01-20T00:41:39.985Z (12 months ago)
- Language: OCaml
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# smallJava
MiniJava programming language interpretation.
## Overview
This grammar is based on the MiniJava language created from Cambridge University
(the link to the grammar of the programming language is
[here](https://www.cambridge.org/resources/052182060X/MCIIJ2e/grammar.html#prod4)).

## Installation and Running
This project requires Ocaml package manager `opam` and module `dune`.
```
# install dependencies
$ opam install dune menhir
# build interpretation
$ make
# remove/clean build
$ make clean
```
Running `make` will create an executable `smolin` in the project directory.
This tool helps converting the MiniJava code in the input file to Python.
For example, the MiniJava code for declaring multiple classes (included in
`/test/declare_class.java`):
```java
class Test {
public static void main(String[] arg) {
System.out.println(!true);
}
}
class Test2 {
int x;
int y;
public int sum(int x, int y) {
return x + y;
}
}
class Test3 extends Test2 {
public int sum(int x, int y) {
return y + x;
}
}
```
becomes
```python
import sys
from typing import List
def main():
arg = sys.argv[1:]
print((not True))
class Test2:
x = None
y = None
def sum(x: int, y: int) -> int:
return (x + y)
class Test3(Test2):
def sum(x: int, y: int) -> int:
return (y + x)
if __name__ == "__main__":
main()
```
after running `smolin`.