diff --git a/README.md b/README.md index 48655f91..3a5af7f5 100644 --- a/README.md +++ b/README.md @@ -8,62 +8,85 @@ [![Hits-of-Code](https://hitsofcode.com/github/polystat/j2eo)](https://hitsofcode.com/view/github/polystat/j2eo) ![Lines of code](https://img.shields.io/tokei/lines/github/polystat/j2eo) -This is a translator of **Java** programming language to [EOLANG](https://www.eolang.org) programming language. +This is a translator of **Java** programming language +to [EOLANG](https://www.eolang.org) programming language. ## Usage -1. Make sure you have installed: - - **Java 11+** (make sure command `java -version` shows 11+ version of Java in terminal if you have multiple Java - version installed). - - **Gradle 7.4+** to build the project. - - **Maven 3.8+** to run tests (be aware of [possible conflicts](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=980467) of the - latest versions of Maven and Java on some OSs). - - **ANTLR4 4.9.2** to build parser. - - You can refer to ACCEPTANCE.md file for instructions on installing these components. - -2. Clone the repo into your folder: - - HTTPS: +### Prerequisites + +- **Java 11+** (make sure command `java -version` shows 11+ version of Java + in terminal if you have multiple Java + version installed). +- **Gradle 7.4+** to build the project. +- **Maven 3.8+** to run tests (be aware + of [possible conflicts](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=980467) + of the + latest versions of Maven and Java on some OSs). +- **ANTLR4 4.9.2** to build parser. + +You can refer to [ACCEPTANCE.md](ACCEPTANCE.md) file for instructions on +installing these components. + +### Build sources + +In order to build `j2eo` transpiler from sources, you need to: + +1. Clone the repo. You have two options clone it by using `HTTPS` or `SSH`, just + choose one of them which is suitable for you: + 1) HTTPS: + ```shell + git clone https://github.com/polystat/j2eo.git + ``` + 2) SSH: + ```shell + git clone git@github.com:polystat/j2eo.git + ``` +2. Open the project root folder: ```shell - git clone https://github.com/polystat/j2eo.git - cd ./j2eo - ``` - or SSH: - ```shell - git clone git@github.com:polystat/j2eo.git - cd ./j2eo + cd j2eo ``` 3. Build the project: ```shell ./build.sh ``` - - See the [troubleshooting section](./README.md#troubleshooting) in case of problems -4. After build process, **j2eo.jar** file will appear in the project root folder (`./j2eo`). With this file, is it - possible to translate **.java** files or packages to **.eo** packages. Run: + See the [troubleshooting section](./README.md#troubleshooting) in case of + problems - ```shell - java -jar j2eo.jar -o - ``` +### Run transpiler - to get the translation. +After build process, **j2eo.jar** file will appear in the project root +folder (`./j2eo`). With this file, is it possible to translate **.java** files +or packages into **.eo** packages. In order to translate `java` sources +into `eo` sources just run the next command: - For example, - ```shell - java -jar j2eo.jar src/test/resources/SimpleTest.java -o output_eo - ``` - or - ```shell - java -jar j2eo.jar src/test/resources/polystat_tests/test1 -o output_eo - ``` +```shell +java -jar j2eo.jar -o +``` -You can also use [yegor256/j2eo](https://hub.docker.com/r/yegor256/j2eo) image for [Docker](https://docs.docker.com/get-docker/): +For example the following command will translate `SimpleTest.java` file +into `output_eo` directory: + +```shell +java -jar j2eo.jar src/test/resources/SimpleTest.java -o output_eo +``` + +You also can translate an entire folder. For example, the following command +wil translate `test1` directory into `output_eo` directory: + +```shell +java -jar j2eo.jar src/test/resources/polystat_tests/test1 -o output_eo +``` + +You can also use [yegor256/j2eo](https://hub.docker.com/r/yegor256/j2eo) image +for [Docker](https://docs.docker.com/get-docker/): ``` $ docker run -v $(pwd):/eo yegor256/j2eo hello.java --target output ``` -This command will translate `hello.java` in the current directory, saving the output to `output/` subdirectory. +This command will translate `hello.java` in the current directory, saving the +output to `output/` subdirectory. ### Unit tests @@ -78,29 +101,39 @@ gradle test J2EO comes with 1000+ bundled tests. There are two testing scenarios: #### Static check execution: + - Java source code is translated to EO using J2EO project -- Obtained EO code are compared with saved one. If they match — test is passed. If not — test is failed. +- Obtained EO code are compared with saved one. If they match — test is passed. + If not — test is failed. -All saved EO programs are located in [translated_test](src/test/resources/translated_tests) directory. +All saved EO programs are located +in [translated_test](src/test/resources/translated_tests) directory. This scenario can be executed by the following command: `./gradlew test --tests "common.TestJ2EOStaticCheck"` #### Parallel execution: -- original Java source code of the text is compiled with Java compiler and executed. Stdout output is saved. -- Java source code is translated to EO using J2EO project, then compiled with EO compiler and executed. Stdout output is stored. -- Stdout outputs are compared. If they match — test is passed. If not — test is failed. + +- original Java source code of the text is compiled with Java compiler and + executed. Stdout output is saved. +- Java source code is translated to EO using J2EO project, then compiled with EO + compiler and executed. Stdout output is stored. +- Stdout outputs are compared. If they match — test is passed. If not — test is + failed. This scenario may be executed using `./test_candidates.sh` script. -Test suite follows the **Java Language Specification** structure, covering applicable chapters and sections of the Java specifications. +Test suite follows the **Java Language Specification** structure, covering +applicable chapters and sections of the Java specifications. ### Running translator on Hadoop -Hadoop is a large Java project (contains ~1.8M lines of code as of time of writing this). We included it as a benchmark of the translator. +Hadoop is a large Java project (contains ~1.8M lines of code as of time of +writing this). We included it as a benchmark of the translator. -Repository contains a script to build J2EO, download Hadoop repo and run J2EO on it. +Repository contains a script to build J2EO, download Hadoop repo and run J2EO on +it. Usage: @@ -108,7 +141,10 @@ Usage: ./test-hadoop.sh ``` -It will download zipped `hadoop` and unpack it (in a separate folder) into `../j2eo-data` relative to the project's root. Next, it will put the If you no more need that folder, run +It will download zipped `hadoop` and unpack it (in a separate folder) +into `../j2eo-data` relative to the project's root. Next, it will put the If you +no more need that folder, run + ```sh rm -rf ../j2eo-data ``` @@ -117,8 +153,10 @@ rm -rf ../j2eo-data ## Motivation -This project is a part of Polystat project, the goal of which is to statically analyze different languages using EOLANG, -the implementation of phi-calculus. In order to do that, the first step is to convert source language into EO. This +This project is a part of Polystat project, the goal of which is to statically +analyze different languages using EOLANG, +the implementation of phi-calculus. In order to do that, the first step is to +convert source language into EO. This particular repository contains translator from Java to EO. --- @@ -127,17 +165,22 @@ particular repository contains translator from Java to EO. **Q**: Why do we implement yet another Java parser? -**A**: Publicly available parsers only support older versions of Java, while we aim to support the latest version ( +**A**: Publicly available parsers only support older versions of Java, while we +aim to support the latest version ( currently 16). Thus, we had to create our own parser. -Also in recent versions, external Java grammar implemented in ANTLR was added as an alternative. It claims to support Java 17, and it does, as for our testing on big projects. +Also in recent versions, external Java grammar implemented in ANTLR was added as +an alternative. It claims to support Java 17, and it does, as for our testing on +big projects.
**Q**: Why do we implement EO AST? -**A**: Working with AST instead of raw strings allows utilization of Java compiler's type checking to minimize amount of -bugs in our code. It is also much easier to work with abstraction layer than with strings. +**A**: Working with AST instead of raw strings allows utilization of Java +compiler's type checking to minimize amount of +bugs in our code. It is also much easier to work with abstraction layer than +with strings.
@@ -147,33 +190,42 @@ bugs in our code. It is also much easier to work with abstraction layer than wit - First, the Java source code files are parsed recursively. - Then, for each file, translator converts Java AST to EO AST. -- Then, EO AST is printed out as a source code to output directory in the same directory structure. +- Then, EO AST is printed out as a source code to output directory in the same + directory structure. --- ## Troubleshooting ### Java -Make sure you have these in sync (*mentioning* (not pointing to) the same `jdk` directory) + +Make sure you have these in sync (*mentioning* (not pointing to) the same `jdk` +directory) + - `which java` - `which javac` - - configure alternatives in case of mismatch ([link](https://stackoverflow.com/a/47432365)) + - configure alternatives in case of + mismatch ([link](https://stackoverflow.com/a/47432365)) - `echo $JAVA_HOME` - - See how to set `$JAVA_HOME` ([link](https://stackoverflow.com/a/18972665)) - - If it still points to a wrong directory, see where you might have set it ([link](https://unix.stackexchange.com/a/154957)) and edit that place + - See how to set `$JAVA_HOME` ([link](https://stackoverflow.com/a/18972665)) + - If it still points to a wrong directory, see where you might have set + it ([link](https://unix.stackexchange.com/a/154957)) and edit that place --- ## Awesome Bugs translation + [Awesome bugs repo](https://github.com/polystat/awesome-bugs) .java files: + - [directStateAccess](src/test/resources/awesome_bugs/java/directStateAccess) - [divByZero](src/test/resources/awesome_bugs/java/divByZero) - [inheritance](src/test/resources/awesome_bugs/java/inheritance) - [unjustifiedAssumption](src/test/resources/awesome_bugs/java/unjustifiedAssumption) Translations: + - [directStateAccess](src/test/resources/awesome_bugs/eo/directStateAccess) - [divByZero](src/test/resources/awesome_bugs/eo/divByZero) - [inheritance](src/test/resources/awesome_bugs/eo/inheritance) @@ -183,108 +235,125 @@ Translations: ## Test Translations -You can find all the `.java` tests translated to `.eo` files [here.](src/test/resources/translated_tests) -To translate `.java` tests into `.eo` files manually, you have to perform the following steps: +You can find all the `.java` tests translated to `.eo` +files [here.](src/test/resources/translated_tests) +To translate `.java` tests into `.eo` files manually, you have to perform the +following steps: + 1. Build the project 2. Locate `J2EO-xxx.jar` file in the `./build/libs/` folder -3. Copy this `J2EO-xxx.jar` file into the [`./src/test/resources/test_candidates/`](src/test/resources/test_candidates) folder -4. Run [`generate_eo_from_tests.py`](src/test/resources/test_candidates/generate_eo_from_tests.py) script in that folder +3. Copy this `J2EO-xxx.jar` file into + the [`./src/test/resources/test_candidates/`](src/test/resources/test_candidates) + folder + -The script takes some time while performing translation. In the end, you will get updated translated files in the [`./src/test/resources/translated_tests/`](src/test/resources/translated_tests) folder. +Run [`generate_eo_from_tests.py`](src/test/resources/test_candidates/generate_eo_from_tests.py) +script in that folder +The script takes some time while performing translation. In the end, you will +get updated translated files in +the [`./src/test/resources/translated_tests/`](src/test/resources/translated_tests) +folder. ## Examples of Java to EOLang translation -We use Java language specification document as a foundation for Java feature hierarchy. -Java 16 language specification: [see .pdf file](https://docs.oracle.com/javase/specs/jls/se16/jls16.pdf) +We use Java language specification document as a foundation for Java feature +hierarchy. +Java 16 language +specification: [see .pdf file](https://docs.oracle.com/javase/specs/jls/se16/jls16.pdf) + +[Ch. 4 - Types, Values, and Variables](src/test/resources/test_ready/ch_4_types_values_variables) -[Ch. 4 - Types, Values, and Variables](src/test/resources/test_ready/ch_4_types_values_variables) - Increment operator: - [Java](src/test/resources/test_ready/ch_4_types_values_variables/sec_4_2_primitive_types_and_values/sec_4_2_2_integer_operations/IncrementOperator.java) - to - [EO](src/test/resources/translated_tests/ch_4_types_values_variables/sec_4_2_primitive_types_and_values/sec_4_2_2_integer_operations/IncrementOperator.eo) + [Java](src/test/resources/test_ready/ch_4_types_values_variables/sec_4_2_primitive_types_and_values/sec_4_2_2_integer_operations/IncrementOperator.java) + to + [EO](src/test/resources/translated_tests/ch_4_types_values_variables/sec_4_2_primitive_types_and_values/sec_4_2_2_integer_operations/IncrementOperator.eo) [Ch. 5 - Conversions and Contexts](src/test/resources/test_ready/ch_5_conversions_and_contexts) [Ch. 6 - Names](src/test/resources/test_ready/ch_6_names) + - A simple declaration: - [Java](src/test/resources/test_ready/ch_6_names/sec_6_1_declarations/SimpleDeclaration.java) - to - [EO](src/test/resources/translated_tests/ch_6_names/sec_6_1_declarations/SimpleDeclaration.eo) + [Java](src/test/resources/test_ready/ch_6_names/sec_6_1_declarations/SimpleDeclaration.java) + to + [EO](src/test/resources/translated_tests/ch_6_names/sec_6_1_declarations/SimpleDeclaration.eo) [Ch. 7 - Packages and Modules WIP](src/test/resources/test_ready/ch_7_packages_and_modules) [Ch. 8 - Classes](src/test/resources/test_ready/ch_8_classes) + - Method class member: - [Java](src/test/resources/test_ready/ch_8_classes/sec_8_2_class_members/MethodClassMember.java) - to - [EO](src/test/resources/translated_tests/ch_8_classes/sec_8_2_class_members/MethodClassMember.eo) + [Java](src/test/resources/test_ready/ch_8_classes/sec_8_2_class_members/MethodClassMember.java) + to + [EO](src/test/resources/translated_tests/ch_8_classes/sec_8_2_class_members/MethodClassMember.eo) - Field initialization: - [Java](src/test/resources/test_ready/ch_8_classes/sec_8_3_field_declarations/sec_8_3_2_field_initialization/SimpleFieldInit.java) - to - [EO](src/test/resources/translated_tests/ch_8_classes/sec_8_3_field_declarations/sec_8_3_2_field_initialization/SimpleFieldInit.eo) + [Java](src/test/resources/test_ready/ch_8_classes/sec_8_3_field_declarations/sec_8_3_2_field_initialization/SimpleFieldInit.java) + to + [EO](src/test/resources/translated_tests/ch_8_classes/sec_8_3_field_declarations/sec_8_3_2_field_initialization/SimpleFieldInit.eo) - Method declaration: - [Java](src/test/resources/test_ready/ch_8_classes/sec_8_4_method_declarations/sec_8_4_1_formal_parametes/SimpleMethod.java) - to - [EO](src/test/resources/translated_tests/ch_8_classes/sec_8_4_method_declarations/sec_8_4_1_formal_parametes/SimpleMethod.eo) + [Java](src/test/resources/test_ready/ch_8_classes/sec_8_4_method_declarations/sec_8_4_1_formal_parametes/SimpleMethod.java) + to + [EO](src/test/resources/translated_tests/ch_8_classes/sec_8_4_method_declarations/sec_8_4_1_formal_parametes/SimpleMethod.eo) - Inner class: - [Java](src/test/resources/test_ready/ch_8_classes/sec_8_5_member_class_and_interface_declarations/SimpleInnerClass.java) - to - [EO](src/test/resources/translated_tests/ch_8_classes/sec_8_5_member_class_and_interface_declarations/SimpleInnerClass.eo) + [Java](src/test/resources/test_ready/ch_8_classes/sec_8_5_member_class_and_interface_declarations/SimpleInnerClass.java) + to + [EO](src/test/resources/translated_tests/ch_8_classes/sec_8_5_member_class_and_interface_declarations/SimpleInnerClass.eo) [Ch. 9 - Interfaces](src/test/resources/test_ready/ch_9_interfaces) [Ch. 10 - Arrays](src/test/resources/test_ready/ch_10_arrays) + - Primitive array declaration: - [Java](src/test/resources/test_ready/ch_10_arrays/sec_10_2_array_variables/PrimitiveArrayDecl.java) - to - [EO](src/test/resources/translated_tests/ch_10_arrays/sec_10_2_array_variables/PrimitiveArrayDecl.eo) + [Java](src/test/resources/test_ready/ch_10_arrays/sec_10_2_array_variables/PrimitiveArrayDecl.java) + to + [EO](src/test/resources/translated_tests/ch_10_arrays/sec_10_2_array_variables/PrimitiveArrayDecl.eo) [Ch. 11 - Exceptions WIP](src/test/resources/test_ready/ch_11_exceptions) [Ch. 14 - Block Statements, and Patterns](src/test/resources/test_ready/ch_14_blocks_statements_and_patterns) [Ch. 15 - Expressions](src/test/resources/test_ready/ch_15_expressions) -- Left-hand operands are evaluated first: - [Java](src/test/resources/test_ready/ch_15_expressions/sec_15_7_evaluation_order/sec_15_7_1_evaluate_left_hand_operand_first/SimpleLeftHandOperandIsEvaluatedFirst.java) - to - [EO](src/test/resources/translated_tests/ch_15_expressions/sec_15_7_evaluation_order/sec_15_7_1_evaluate_left_hand_operand_first/SimpleLeftHandOperandIsEvaluatedFirst.eo) + +- Left-hand operands are evaluated first: + [Java](src/test/resources/test_ready/ch_15_expressions/sec_15_7_evaluation_order/sec_15_7_1_evaluate_left_hand_operand_first/SimpleLeftHandOperandIsEvaluatedFirst.java) + to + [EO](src/test/resources/translated_tests/ch_15_expressions/sec_15_7_evaluation_order/sec_15_7_1_evaluate_left_hand_operand_first/SimpleLeftHandOperandIsEvaluatedFirst.eo) - Integer literal: - [Java](src/test/resources/test_ready/ch_15_expressions/sec_15_8_primary_expressions/sec_15_8_1_lexical_literals/IntegerLiteral.java) - to - [EO](src/test/resources/translated_tests/ch_15_expressions/sec_15_8_primary_expressions/sec_15_8_1_lexical_literals/IntegerLiteral.eo) + [Java](src/test/resources/test_ready/ch_15_expressions/sec_15_8_primary_expressions/sec_15_8_1_lexical_literals/IntegerLiteral.java) + to + [EO](src/test/resources/translated_tests/ch_15_expressions/sec_15_8_primary_expressions/sec_15_8_1_lexical_literals/IntegerLiteral.eo) - Complex parenthesized expression: - [Java](src/test/resources/test_ready/ch_15_expressions/sec_15_8_primary_expressions/sec_15_8_5_parenthesized_expressions/ComplexParenthExpression.java) - to - [EO](src/test/resources/translated_tests/ch_15_expressions/sec_15_8_primary_expressions/sec_15_8_5_parenthesized_expressions/ComplexParenthExpression.eo) + [Java](src/test/resources/test_ready/ch_15_expressions/sec_15_8_primary_expressions/sec_15_8_5_parenthesized_expressions/ComplexParenthExpression.java) + to + [EO](src/test/resources/translated_tests/ch_15_expressions/sec_15_8_primary_expressions/sec_15_8_5_parenthesized_expressions/ComplexParenthExpression.eo) - Creation of a simple integer array: - [Java](src/test/resources/test_ready/ch_15_expressions/sec_15_10_array_creation_and_access_expressions/sec_15_10_1_array_creation_expressions/SimpleIntegerArray.java) - to - [EO](src/test/resources/translated_tests/ch_15_expressions/sec_15_10_array_creation_and_access_expressions/sec_15_10_1_array_creation_expressions/SimpleIntegerArray.eo) + [Java](src/test/resources/test_ready/ch_15_expressions/sec_15_10_array_creation_and_access_expressions/sec_15_10_1_array_creation_expressions/SimpleIntegerArray.java) + to + [EO](src/test/resources/translated_tests/ch_15_expressions/sec_15_10_array_creation_and_access_expressions/sec_15_10_1_array_creation_expressions/SimpleIntegerArray.eo) - Postfix increment: - [Java](src/test/resources/test_ready/ch_15_expressions/sec_15_14_postfix_expressions/sec_15_14_2_postfix_increment_operator/SimplePostfixIncrement.java) - to - [EO](src/test/resources/translated_tests/ch_15_expressions/sec_15_14_postfix_expressions/sec_15_14_2_postfix_increment_operator/SimplePostfixIncrement.eo) + [Java](src/test/resources/test_ready/ch_15_expressions/sec_15_14_postfix_expressions/sec_15_14_2_postfix_increment_operator/SimplePostfixIncrement.java) + to + [EO](src/test/resources/translated_tests/ch_15_expressions/sec_15_14_postfix_expressions/sec_15_14_2_postfix_increment_operator/SimplePostfixIncrement.eo) - Unary plus operator: - [Java](src/test/resources/test_ready/ch_15_expressions/sec_15_15_unary_operators/sec_15_15_3_unary_plus_operator/SimpleUnaryPlus.java) - to - [EO](src/test/resources/translated_tests/ch_15_expressions/sec_15_15_unary_operators/sec_15_15_3_unary_plus_operator/SimpleUnaryPlus.eo) + [Java](src/test/resources/test_ready/ch_15_expressions/sec_15_15_unary_operators/sec_15_15_3_unary_plus_operator/SimpleUnaryPlus.java) + to + [EO](src/test/resources/translated_tests/ch_15_expressions/sec_15_15_unary_operators/sec_15_15_3_unary_plus_operator/SimpleUnaryPlus.eo) - Multiplication operator: - [Java](src/test/resources/test_ready/ch_15_expressions/sec_15_17_multiplicative_operators/sec_15_17_1_multiplication_operator/SimpleMultiplication.java) - to - [EO](src/test/resources/translated_tests/ch_15_expressions/sec_15_17_multiplicative_operators/sec_15_17_1_multiplication_operator/SimpleMultiplication.eo) + [Java](src/test/resources/test_ready/ch_15_expressions/sec_15_17_multiplicative_operators/sec_15_17_1_multiplication_operator/SimpleMultiplication.java) + to + [EO](src/test/resources/translated_tests/ch_15_expressions/sec_15_17_multiplicative_operators/sec_15_17_1_multiplication_operator/SimpleMultiplication.eo) - Variable right shift: - [Java](src/test/resources/test_ready/ch_15_expressions/sec_15_19_shift_operators/VariableRightShift.java) - to - [EO](src/test/resources/translated_tests/ch_15_expressions/sec_15_19_shift_operators/VariableRightShift.eo) + [Java](src/test/resources/test_ready/ch_15_expressions/sec_15_19_shift_operators/VariableRightShift.java) + to + [EO](src/test/resources/translated_tests/ch_15_expressions/sec_15_19_shift_operators/VariableRightShift.eo) - Greater operator: - [Java](src/test/resources/test_ready/ch_15_expressions/sec_15_20_relational_operators/sec_15_20_1_numerical_comparison_operators/SimpleGreaterComparison.java) - to - [EO](src/test/resources/translated_tests/ch_15_expressions/sec_15_20_relational_operators/sec_15_20_1_numerical_comparison_operators/SimpleGreaterComparison.eo) + [Java](src/test/resources/test_ready/ch_15_expressions/sec_15_20_relational_operators/sec_15_20_1_numerical_comparison_operators/SimpleGreaterComparison.java) + to + [EO](src/test/resources/translated_tests/ch_15_expressions/sec_15_20_relational_operators/sec_15_20_1_numerical_comparison_operators/SimpleGreaterComparison.eo) - Assignment operator: - [Java](src/test/resources/test_ready/ch_15_expressions/sec_15_26_assignment_operators/sec_15_26_1_simple_assignment_operator/SimpleAssignmentOperator.java) - to - [EO](src/test/resources/translated_tests/ch_15_expressions/sec_15_26_assignment_operators/sec_15_26_1_simple_assignment_operator/SimpleAssignmentOperator.eo) + [Java](src/test/resources/test_ready/ch_15_expressions/sec_15_26_assignment_operators/sec_15_26_1_simple_assignment_operator/SimpleAssignmentOperator.java) + to + [EO](src/test/resources/translated_tests/ch_15_expressions/sec_15_26_assignment_operators/sec_15_26_1_simple_assignment_operator/SimpleAssignmentOperator.eo) [Ch. 16 - Definite Assignments WIP](src/test/resources/test_ready/ch_16_definite_assignment) @@ -294,9 +363,13 @@ Java 16 language specification: [see .pdf file](https://docs.oracle.com/javase/s ## Examples of translation projections -Bellow there are all designed mappings at the current moment. If you didn't find a construction in the list bellow it is probably unsupported. +Bellow there are all designed mappings at the current moment. If you didn't find +a construction in the list bellow it is probably unsupported. -This list is created accordingly [Java SE 16](https://docs.oracle.com/javase/specs/jls/se16/jls16.pdf). Some chapters are omitted because they related only to internal structure of Java. +This list is created +accordingly [Java SE 16](https://docs.oracle.com/javase/specs/jls/se16/jls16.pdf). +Some chapters are omitted because they related only to internal structure of +Java. Others are omitted due to lack of implementation of translation. ### 4 Types, Values, and Variables @@ -305,73 +378,97 @@ Others are omitted due to lack of implementation of translation. #### 4.2 Primitive Types and Values -Any primitives types are supported. For handling them we use a [primitives](src/main/resources/stdlib/primitives) package. It provides `memory` wrappers for any primitive types. +Any primitives types are supported. For handling them we use +a [primitives](src/main/resources/stdlib/primitives) package. It +provides `memory` wrappers for any primitive types. -Wrappers are more convenient way to simulate primitives types. For, example `memory.write` returns `bool` object instead itself, so for handling `=` operator we should do something like this: -``` +Wrappers are more convenient way to simulate primitives types. For, +example `memory.write` returns `bool` object instead itself, so for handling `=` +operator we should do something like this: + +```eo [a b] > write seq > @ a.write b a ``` -It is more complex than just `a.write b`, where `a` and `b` are wrappers. Moreover, pure `memory` does not support in-place operations and conversions. -Therefore, we decided to generate more beautiful EO code and use wrappers instead generation of unreadable code with pure 'memory'. + +It is more complex than just `a.write b`, where `a` and `b` are wrappers. +Moreover, pure `memory` does not support in-place operations and conversions. +Therefore, we decided to generate more beautiful EO code and use wrappers +instead generation of unreadable code with pure 'memory'. #### 4.2.2 Integer Operations -The Java programming language provides a number of operators that act on integral + +The Java programming language provides a number of operators that act on +integral values. Supported ones: + * The comparison operators, which result in a value of type boolean: - - The numerical comparison operators <, <=, >, and >= - - The numerical equality operators == and != -* The unary plus and minus operators + and - + - The numerical comparison operators <, <=, >, and >= + - The numerical equality operators == and != +* The unary plus and minus operators + and - * The multiplicative operators *, /, and % -* The additive operators + and - +* The additive operators + and - * The increment operator ++, both prefix and postfix * The decrement operator --, both prefix and postfix * The signed and unsigned shift operators <<, >>, and >>> * The cast operator, which can convert from an integral value to a value -of any specified numeric type + of any specified numeric type Common translation scheme: -```Java + +```java expr_1 op expr_2 ``` + --> -``` + +```eo [] > binary expr_1.translated_op > @ expr_2 ``` Unary case: -```Java + +```java expr op // OR -op expr + op expr ``` + --> + ``` [] > unary expr.translated_op > @ ``` Cast case: -```Java -(primitive_type) expr + +```java +(primitive_type)expr ``` + --> -``` + +```eo [] > cast translated_primitive_type.from expr ``` #### 4.2.3 Floating-Point Types, Formats, and Values -Currently, there is only runtime support for `double`. Nevertheless, translator can handle `float` well, but output EO code would not be equivalent to initial one during runtime. +Currently, there is only runtime support for `double`. Nevertheless, translator +can handle `float` well, but output EO code would not be equivalent to initial +one during runtime. #### 4.2.4 Floating-Point Operations + The Java programming language provides a number of operators that act on floating-point values. Supported operators: + * The comparison operators, which result in a value of type boolean: - The numerical comparison operators <, <=, >, and >= - The numerical equality operators == and != @@ -388,7 +485,8 @@ Scheme of translation is the same as in [4.2.2](#4.2.2-integer-operations) #### 4.3 Reference Types and Values -Currently, only classes as reference types are supported. Identifier of class is prepended with `class__` during translation. +Currently, only classes as reference types are supported. Identifier of class is +prepended with `class__` during translation. #### 4.4 Type Variables @@ -396,9 +494,9 @@ Type variables are omitted due to lack of types in EO. #### 4.5 Parameterized Types -The same situation as [4.4](#4.4-type-variables) +The same situation as [4.4](#4.4-type-variables) -#### 4.6 Type Erasure +#### 4.6 Type Erasure The same situation as [4.4](#4.4-type-variables) @@ -408,27 +506,35 @@ The same situation as [4.4](#4.4-type-variables) #### 4.12.1 Variables of Primitive Type -Any primitive type variable is being stored on special handwritten objects (`primitives`). For example, `int` value will be stored in `prim__int` object, `long` in `prim__long` and so on. +Any primitive type variable is being stored on special handwritten +objects (`primitives`). For example, `int` value will be stored in `prim__int` +object, `long` in `prim__long` and so on. Example: -```Java + +```java float a; ``` + --> -``` + +```eo prim__float.constructor_1 > a prim__float.new ``` #### 4.12.2 Variables of Reference Type -Any reference type variable is being stored on `cage`. +Any reference type variable is being stored on `cage`. Example: -```Java + +```java Ref a; ``` + --> + ``` cage > a ``` @@ -439,12 +545,14 @@ cage > a #### 5.1.1 Identity Conversion -This conversion is omitted by the translator. E.g., `(ClassA) class_a_instance` is `class_a_instance` in the translator perspective. +This conversion is omitted by the translator. E.g., `(ClassA) class_a_instance` +is `class_a_instance` in the translator perspective. #### 5.1.2 Widening Primitive Conversion 19 specific conversions on primitive types are called the widening primitive conversions: + * `byte` to `short`, `int`, `long`, `float` or `double` * `short` to `int`, `long`, `float` or `double` * `char` to `int`, `long`, `float` or `double` @@ -455,27 +563,34 @@ conversions: All of them has runtime support. Example: -```Java -(primitive_type) expr + +```java +(primitive_type)expr ``` + --> -``` + +```eo [] > cast translated_type.from > @ expr ``` -`translated_type` is obtained according to [4.12.1](#4.12.1-Variables of Primitive Type) +`translated_type` is obtained according +to [4.12.1](#4.12.1-Variables of Primitive Type) #### 5.1.3 Narrowing Primitive Conversion + 22 specific conversions on primitive types are called the narrowing primitive conversions: + * `short` to `byte` or `char` * `char` to `byte` or `short` * `int` to `byte`, `short` or `char` * `long` to `byte`, `short`, `char` or `int` * `float` to `byte`, `short`, `char`, `int` or `long` -* `double` to `byte`, `short`, `char`, `int`, `long` or `float` (runtime support is not precise) +* `double` to `byte`, `short`, `char`, `int`, `long` or `float` (runtime support + is not precise) All of them has runtime support. @@ -487,16 +602,22 @@ The same situation as [4.4](#4.4-type-variables) #### 5.1.11 String Conversion -Currently, there is no support for this type of conversion. User should manually resolve them. For example: -```Java -"1" + 1 +Currently, there is no support for this type of conversion. User should manually +resolve them. For example: + +```java +"1"+1 ``` + it should be manually rewritten to: -```Java -"1" + String.valueOf(1) + +```java +"1"+String.valueOf(1) ``` + In this case the translator would convert it to: -``` + +```eo [] > binary_1 literal_1.add > @ methodInvocation_1 @@ -516,62 +637,83 @@ In this case the translator would convert it to: ### 6 Names --- + #### 6.1 Declarations -A declaration introduces an entity into a program and includes an identifier. Supported declared entity is one of the following: -* An imported class or interface, declared in a single-type-import declaration or a -type-import-on-demand declaration +A declaration introduces an entity into a program and includes an identifier. +Supported declared entity is one of the following: + +* An imported class or interface, declared in a single-type-import declaration + or a + type-import-on-demand declaration * An imported static member, declared in a single-static-import declaration or a -static-import-on-demand declaration + static-import-on-demand declaration * A class, declared by a normal class declaration * A member of a reference type, one of the following: - - A member class - - A field, one of the following: - - A field declared in a class - - The field length, which is implicitly a member of every array type - - A method, one of the following: - - A method (abstract or otherwise) declared in a class + - A member class + - A field, one of the following: + - A field declared in a class + - The field length, which is implicitly a member of every array type + - A method, one of the following: + - A method (abstract or otherwise) declared in a class * A formal parameter, one of the following: - - A formal parameter of a method of a class - - A formal parameter of a constructor of a class + - A formal parameter of a method of a class + - A formal parameter of a constructor of a class * A local variable, one of the following: - - A local variable declared by a local variable declaration statement in a block + - A local variable declared by a local variable declaration statement in a + block * A local class, one of the following: - - A local class declared by a normal class declaration + - A local class declared by a normal class declaration -Any declaration is translated into EO object or EO copy of specific object. Example: +Any declaration is translated into EO object or EO copy of specific object. +Example: -```Java -class A { body } +```java +class A { + // body +} ``` + -> -``` + +```eo [] > class__A ... body ... ``` + Or, -```Java + +```java int a; ``` + --> + ``` prim__int.constructor_1 > a prim__int.new ``` #### 6.2 Names and Identifiers + A name is used to refer to an entity declared in a program. -A *simple name* is a single identifier. Each simple identifier preserves name except classes. Their names are prepended with `class__`. There is no name mangling for variables. +A *simple name* is a single identifier. Each simple identifier preserves name +except classes. Their names are prepended with `class__`. There is no name +mangling for variables. + +A *qualified name* consists of a name, a "." token, and an identifier. Qualified +names are separated to several objects during translation. Example: -A *qualified name* consists of a name, a "." token, and an identifier. Qualified names are separated to several objects during translation. Example: -```Java +```java a.b.c; ``` + --> -``` + +```eo [] > fieldAcces_1 fieldAcess_2.c > @ [] > fieldAcces_2 @@ -580,7 +722,9 @@ a.b.c; a ``` -Of course, it can be optimized to just one EO object, but at this moment translator does not perform such optimization for keeping translation of dot-separated entities more general. +Of course, it can be optimized to just one EO object, but at this moment +translator does not perform such optimization for keeping translation of +dot-separated entities more general. #### 6.4 Shadowing and Obscuring @@ -588,7 +732,8 @@ For now there is now handling of shadowing and obscuring. #### 6.6 Access Control -EO does not support access modifiers. All objects in an EO is public by default. Therefore, during translation such information is being lost. +EO does not support access modifiers. All objects in an EO is public by default. +Therefore, during translation such information is being lost. ### 7 Packages and Modules @@ -596,27 +741,35 @@ EO does not support access modifiers. All objects in an EO is public by default. #### 7.5 Import Declarations -Currently, translator supports only single type import declaration and single static support declarations. +Currently, translator supports only single type import declaration and single +static support declarations. Example: -```Java + +```java import a.b.c; import static d.e.f; ``` + --> -``` + +```eo +alias a.b.class__c +alias d.class_e.f ``` -Any identifier in import declaration would be prepended with class__ if it's known that it is a class. +Any identifier in import declaration would be prepended with class__ if it's +known that it is a class. Identifier `java` will be replaced with `stdlib`. Example: -```Java + +```java import java.lang.Random; ``` + --> + ``` +alias stdlib.lang.class__Random ``` @@ -627,24 +780,28 @@ import java.lang.Random; #### 8.1.1 Class Modifiers -Any modifiers except `static` are being omitted during translation. `static` is needed to distinguish a inner class from nested one. +Any modifiers except `static` are being omitted during translation. `static` is +needed to distinguish a inner class from nested one. #### 8.3 Field Declarations -Currently, only non-`static` fields are supported. +Currently, only non-`static` fields are supported. #### 8.4 Method Declarations Any method would be translated into EO object. Name in this case would be saved. Example: -```Java -static String m(int p_int, String p_str) { - return p_int + p_str; -} + +```java +static String m(int p_int,String p_str){ + return p_int+p_str; + } ``` + --> -``` + +```eo [p_int p_str] > m seq > @ return_1 @@ -659,19 +816,24 @@ static String m(int p_int, String p_str) { p_str > @ ``` -Any non-`static` method will have additional parameter `this` that refers callee itself. It is necessary to implement overriding methods in EO correctly. +Any non-`static` method will have additional parameter `this` that refers callee +itself. It is necessary to implement overriding methods in EO correctly. #### 8.5 Member Class and Interface Declarations -Now only `static` nested classes are supported. Nested interfaces are unsupported. Example: +Now only `static` nested classes are supported. Nested interfaces are +unsupported. Example: -```Java +```java class Outer { - class Inner {} + class Inner { + } } ``` + --> -``` + +```eo [] > class__Outer ... [] > class Inner @@ -680,18 +842,21 @@ class Outer { #### 8.8 Constructor Declarations -Only non-multiple construction declarations with explicit `super` call are supported. +Only non-multiple construction declarations with explicit `super` call are +supported. Example: ```java -public A() { +public A(){ super(); - ... + //... } ``` + --> -``` + +```eo [this] > constructor seq > @ initialization @@ -716,7 +881,7 @@ If no constructor is provided then translator generate default constructor. #### Class translation structure: -``` +```eo [] > class__ class__ > super # Inheritance simulation super > @ @@ -744,30 +909,37 @@ ___ #### 10.2 Array Variables -Translator supports both types of arrays: primitive and reference. Examples: `int[]` and `String[]` +Translator supports both types of arrays: primitive and reference. +Examples: `int[]` and `String[]` #### 10.3 Array Creation -Look at [15.10.1](#15.10.1-array-creation-expressions) section. +Look at [15.10.1](#15.10.1-array-creation-expressions) section. #### 10.4 Array Access -For access to array elements translator uses `get` provided by EO `array` object. However, as indexes it uses primitive wrappers. +For access to array elements translator uses `get` provided by EO `array` +object. However, as indexes it uses primitive wrappers. Example is provided in [15.10.3](#15.10.3-array-access-expressions) section. #### 10.6 Array Initializers -An array initializer is written as a comma-separated list of expressions, enclosed +An array initializer is written as a comma-separated list of expressions, +enclosed by braces { and }. Example, `{ 1 + 1, 2 }` -Currently, it is the only way to store something in array. Other types of initializers (e.g. `new Type[num]`) are unsupported. +Currently, it is the only way to store something in array. Other types of +initializers (e.g. `new Type[num]`) are unsupported. Example: + ```java -{ 1 + 1, 2 } +{1+1,2} ``` + --> -``` + +```eo [] > initializerArray_1 * > @ initializerSimple_1 @@ -795,7 +967,8 @@ Example: #### 10.7 Array Members -For now only `length` attribute is supported. During translation, it remains unchanged. +For now only `length` attribute is supported. During translation, it remains +unchanged. ### 14 Blocks, Statements, and Patterns @@ -803,32 +976,41 @@ For now only `length` attribute is supported. During translation, it remains unc #### 14.2 Blocks -By Java grammar, blocks are sequence of declarations and statements separated by curly braces. Translator creates new EO object for each block. Example: +By Java grammar, blocks are sequence of declarations and statements separated by +curly braces. Translator creates new EO object for each block. Example: -```Java +```java { declaration; statement; } ``` + --> -``` + +```eo [] > block_1 seq > @ declaration_1 statement_1 ``` -Number after object name is needed just for avoiding name collisions. `declaration_1` and `statement_1` are EO objects. They describe internal structure of itself. Inside a `seq` object they are just dataizing. + +Number after object name is needed just for avoiding name +collisions. `declaration_1` and `statement_1` are EO objects. They describe +internal structure of itself. Inside a `seq` object they are just dataizing. Now let's look to real Java code: -```Java -void foo() { - int a = 1; + +```java +void foo(){ + int a=1; println(a); } ``` + -> -``` + +```eo 1 [this] > foo 2 seq > @ 3 variableDeclaration_1 @@ -852,15 +1034,30 @@ void foo() { 21 a > @ ``` -Any variables in blocks are declared separately from the `seq` object. In this case `int a` was declared at lines 5-6. Also it has an initializer `1`. So translator assign `a` to initializer value at lines 7-9. This initializer is simple one. It is a just literal. Translator mentioned it on lines 10-11. Literals are translated to EO objects itself (lines 12-15). +Any variables in blocks are declared separately from the `seq` object. In this +case `int a` was declared at lines 5-6. Also it has an initializer `1`. So +translator assign `a` to initializer value at lines 7-9. This initializer is +simple one. It is a just literal. Translator mentioned it on lines 10-11. +Literals are translated to EO objects itself (lines 12-15). + +Any statement in blocks are statement expression by default. Their behaviour as +a declarations are described separately. In this case statement `println(a)` is +declared on lines 16-19. By default, any method is considered as class method. +So access to it is performed via `this` (line 17). Moreover, it is necessary to +pass `this` as argument during method invocation (line 18). `println(a)` is call +with single argument `a`. It is a simple reference that was mentioned at line -Any statement in blocks are statement expression by default. Their behaviour as a declarations are described separately. In this case statement `println(a)` is declared on lines 16-19. By default, any method is considered as class method. So access to it is performed via `this` (line 17). Moreover, it is necessary to pass `this` as argument during method invocation (line 18). `println(a)` is call with single argument `a`. It is a simple reference that was mentioned at line 19. Simple reference is itself a distinct object which translator declared on lines 20-21. +19. Simple reference is itself a distinct object which translator declared on + lines 20-21. #### 14.4 Local Variable Declarations -A local variable declaration declares and optionally initializes one or more local -variables. Translator keeps location of declaration unchanged. -E.g. class member declarations stay inside class body, local method variables stays inside a method body and e.t.c. Depending on the type declared entity can be stored in `cage`, primitive wrapper or in separate EO object. +A local variable declaration declares and optionally initializes one or more +local +variables. Translator keeps location of declaration unchanged. +E.g. class member declarations stay inside class body, local method variables +stays inside a method body and e.t.c. Depending on the type declared entity can +be stored in `cage`, primitive wrapper or in separate EO object. Example of class member declaration: @@ -869,8 +1066,10 @@ class A { int member; } ``` + --> -``` + +```eo [] > class__A ... [] > new @@ -881,13 +1080,16 @@ class A { ``` Example of class member with initializer: + ```java class A { int member = 0; } ``` + --> -``` + +```eo [] > class__A ... [] > new @@ -909,16 +1111,20 @@ class A { ... ``` -In this case when instance of class `A` would be created, `init` object would be called for initializing variables. +In this case when instance of class `A` would be created, `init` object would be +called for initializing variables. Example of local method variable with initializer: + ```java -void m() { - int a = 0; -} +void m(){ + int a=0; + } ``` + --> -``` + +```eo [this] > m seq > @ variableDeclaration_1 @@ -935,23 +1141,30 @@ void m() { 0 ``` -Here the same logic is applicable as in previous example. Variable itself is being stored out of `seq` object, but it dataizes its initialization. +Here the same logic is applicable as in previous example. Variable itself is +being stored out of `seq` object, but it dataizes its initialization. -Example with nested class is located in [8.5](#8.5 Member Class and Interface Declarations). +Example with nested class is located +in [8.5](#8.5 Member Class and Interface Declarations). #### 14.5 Statements -All statements of block are being stored inside `seq` object after translation. Each of them is represented by unique name which during dataization simulates behaviour of initial statement. +All statements of block are being stored inside `seq` object after translation. +Each of them is represented by unique name which during dataization simulates +behaviour of initial statement. Example: + ```java { - int a = 1; + int a=1; method(); } ``` + --> -``` + +```eo [] > block_1 seq > @ variableDeclaration_1 # int a = 1; @@ -981,13 +1194,15 @@ Translator ignores it. Example: ```java -if (cond) +if(cond) then_block; -else + else else_block; ``` + --> -``` + +```eo [] > ifThenElse_1 translated_cond.if > @ block_1 @@ -1000,7 +1215,8 @@ else ``` If no else part is provided then translator generate empty block (`empty`): -``` + +```eo [] > empty_1 TRUE > @ ``` @@ -1008,11 +1224,14 @@ If no else part is provided then translator generate empty block (`empty`): #### 14.10 The assert Statement Example: + ```java -assert cond : expr; +assert cond:expr; ``` + --> -``` + +```eo [] > assert_1 translated_cond.if > @ TRUE @@ -1025,12 +1244,15 @@ assert cond : expr; #### 14.12 The while Statement Example: + ```java -while (cond) +while(cond) block; ``` + --> -``` + +```eo [] > while_1 translated_cond.while > @ [while_i] @@ -1043,13 +1265,16 @@ while (cond) #### 14.13 The do Statement Example: + ```java do block; -while (cond); + while(cond); ``` + --> -``` + +```eo [] > do_1 translated_cond.do > @ [do_i] @@ -1067,14 +1292,17 @@ Note: currently there is no runtime support of `do` object. #### 15.8.1 Lexical Literals -Now supported only integer, floating point and string literals. Translator use wrappers to simulate behaviour of Java primitives. -Let's consider an assign operator in Java write value into variable and return its value. `memory` in EO does not provide a such behaviour. +Now supported only integer, floating point and string literals. Translator use +wrappers to simulate behaviour of Java primitives. +Let's consider an assign operator in Java write value into variable and return +its value. `memory` in EO does not provide a such behaviour. Therefore, we need to use a wrapper. Examples: -`1` -> -``` +`1` -> + +```eo [] > literal_1 prim__int.constructor_2 > @ prim__int.new @@ -1082,7 +1310,8 @@ Examples: ``` `1.0` -> -``` + +```eo [] > literal_1 prim__float.constructor_2 > @ prim__float.new @@ -1090,7 +1319,8 @@ Examples: ``` `"string"` -> -``` + +```eo [] > literal_1 class__String.constructor_2 > @ class__String.new @@ -1103,18 +1333,21 @@ It's remaining unchanged. #### 15.8.5 Parenthesized Expressions -`(expresion)` -> -``` +`(expresion)` -> + +```eo [] > parenthesized_1 expresion > @ ``` -It can be simplified, but we keep such translation to maintain more complex cases. +It can be simplified, but we keep such translation to maintain more complex +cases. #### 15.9 Class Instance Creation Expression `new A(arg)` -> -``` + +```eo [] > statementExpression_1 class__A.constructor > @ class__A.new @@ -1123,16 +1356,20 @@ It can be simplified, but we keep such translation to maintain more complex case arg > @ ``` -For referencing variables `simpleReference_1` is used. It can be simplified, but it's used for maintaining complex cases. +For referencing variables `simpleReference_1` is used. It can be simplified, but +it's used for maintaining complex cases. #### 15.10.1 Array Creation Expressions -Currently, only creation with array initializers is supported. Example of array initializers: `{1, 2, 3}`. +Currently, only creation with array initializers is supported. Example of array +initializers: `{1, 2, 3}`. -For storing array translator uses `cage` object. For simulation of array initializers translator uses `array` aka `*` object from EO. +For storing array translator uses `cage` object. For simulation of array +initializers translator uses `array` aka `*` object from EO. `int[] array = {1}` -> -``` + +```eo [] > variableDeclaration_1 array.write > @ initializerArray_1 @@ -1150,7 +1387,8 @@ For storing array translator uses `cage` object. For simulation of array initial #### 15.10.3 Array Access Expressions `array[idx]` -> -``` + +```eo [] > statementExpression_1 simpleReference_1.get > @ simpleReference_2.v @@ -1165,7 +1403,8 @@ For storing array translator uses `cage` object. For simulation of array initial #### 15.11 Field Access Expressions `a.b` -> -``` + +```eo [] > statementExpression_1 simpleReference_1.b > @ [] > simpleReference_1 @@ -1177,7 +1416,8 @@ It can be simplified, but we keep such translation for generalization. #### 15.11.2 Accessing Superclass Members using `super` `a.super.b` -> -``` + +```eo [] > statementExpression_1 simpleReference_1.super.b > @ [] > simpleReference_1 @@ -1187,7 +1427,8 @@ It can be simplified, but we keep such translation for generalization. #### 15.12 Method Invocation Expressions `a.b(arg)` -> -``` + +```eo [] > statementExpression_1 a.b > @ # call of b a # a should be passed @@ -1199,7 +1440,8 @@ It can be simplified, but we keep such translation for generalization. #### 15.14.2 Postfix Increment Operator `++` `expr++` -> -``` + +```eo [] > statementExpression_1 simpleReference_1.inc_post > @ # increment itself [] > simpleReference_1 @@ -1209,7 +1451,8 @@ It can be simplified, but we keep such translation for generalization. #### 15.14.3 Postfix Decrement Operator `--` `expr--` -> -``` + +```eo [] > statementExpression_1 simpleReference_1.dec_post > @ # decrement itself [] > simpleReference_1 @@ -1219,6 +1462,7 @@ It can be simplified, but we keep such translation for generalization. #### 15.15.1 Prefix Increment Operator `++` `++expr` -> + ``` [] > statementExpression_1 simpleReference_1.inc_pre > @ # increment itself @@ -1229,6 +1473,7 @@ It can be simplified, but we keep such translation for generalization. #### 15.15.2 Prefix Decrement Operator `--` `--expr` -> + ``` [] > statementExpression_1 simpleReference_1.dec_pre > @ # decrement itself @@ -1238,7 +1483,8 @@ It can be simplified, but we keep such translation for generalization. #### 15.15.3 Unary Plus Operator `+` -`+expr` -> +`+expr` -> + ``` [] > statementExpression_1 simpleReference_1 > @ @@ -1251,7 +1497,8 @@ It can be simplified, but we keep such translation for generalization. #### 15.15.4 Unary Minus Operator `-` `-expr` -> -``` + +```eo [] > statementExpression_1 simpleReference_1.neg > @ # negation itself [] > simpleReference_1 @@ -1261,7 +1508,8 @@ It can be simplified, but we keep such translation for generalization. #### 15.16 Cast Expressions `(int) 1.0` -> -``` + +```eo [] > statementExpression_1 prim__int.from > @ # cast itself literal_1 @@ -1274,7 +1522,8 @@ It can be simplified, but we keep such translation for generalization. #### 15.17-26 Binary Operators `left operand right` -> -``` + +```eo [] > statementExpression_1 simpleReference_1.t_operand > @ simpleReference_2 @@ -1286,5 +1535,6 @@ It can be simplified, but we keep such translation for generalization. `t_opernad` is translated `operand` -There are only runtime support only for following operands: -`+`, `-`, `*`, `%`, `/`, `&&`, `||`, `>`, `<`, `>=`, `<=`, `==`, `!=`, `<<`, `>>` and `>>>` +There are only runtime support only for following operands: +`+`, `-`, `*`, `%`, `/`, `&&`, `||`, `>`, `<`, `>=`, `<=`, `==`, `!=`, `<<`, `>>` +and `>>>`