{"id":24016107,"url":"https://github.com/fulminazzo/mojito","last_synced_at":"2026-06-17T11:31:08.270Z","repository":{"id":270908104,"uuid":"903010280","full_name":"fulminazzo/mojito","owner":"fulminazzo","description":"A parser that reads and executes a simplified version of Java","archived":false,"fork":false,"pushed_at":"2025-09-10T18:32:54.000Z","size":3162,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-10T22:47:13.573Z","etag":null,"topics":["gradle","groovy","java","library","parser","spock","tokenizer","typechecker"],"latest_commit_sha":null,"homepage":"","language":"Groovy","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fulminazzo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-12-13T18:26:42.000Z","updated_at":"2025-05-02T17:30:01.000Z","dependencies_parsed_at":"2025-05-01T19:22:54.907Z","dependency_job_id":"191db848-5e3b-4be5-aaf9-96b89306eed8","html_url":"https://github.com/fulminazzo/mojito","commit_stats":null,"previous_names":["fulminazzo/javaparser","fulminazzo/mojito"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/fulminazzo/mojito","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fulminazzo%2Fmojito","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fulminazzo%2Fmojito/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fulminazzo%2Fmojito/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fulminazzo%2Fmojito/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fulminazzo","download_url":"https://codeload.github.com/fulminazzo/mojito/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fulminazzo%2Fmojito/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34447264,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-17T02:00:05.408Z","response_time":127,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gradle","groovy","java","library","parser","spock","tokenizer","typechecker"],"created_at":"2025-01-08T08:39:43.142Z","updated_at":"2026-06-17T11:31:08.256Z","avatar_url":"https://github.com/fulminazzo.png","language":"Groovy","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://app.codacy.com/gh/Fulminazzo/mojito/\"\u003e\u003cimg src=\"https://fulminazzo.it/badge/code/Fulminazzo/mojito?type=code\" alt=\"Lines of Code\" /\u003e\u003c/a\u003e\n    \u003ca href=\"../../releases/latest\"\u003e\u003cimg src=\"https://img.shields.io/github/v/release/Fulminazzo/mojito?display_name=tag\u0026color=red\" alt=\"Latest version\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://app.codacy.com/gh/Fulminazzo/mojito/\"\u003e\u003cimg src=\"https://fulminazzo.it/badge/code/Fulminazzo/mojito?type=test\" alt=\"Lines of Code\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://fulminazzo.it/badge/coverage/Fulminazzo/mojito/gradle.yml\" alt=\"Tests coverage\" /\u003e\n    \u003ca href=\"https://app.codacy.com/gh/Fulminazzo/mojito/dashboard?utm_source=gh\u0026utm_medium=referral\u0026utm_content=\u0026utm_campaign=Badge_grade\"\u003e\u003cimg src=\"https://app.codacy.com/project/badge/Grade/c9b24e43cb7c4658975624cc9862a8d3\" alt=\"Codacy Grade\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Yes%2C%20I%20love-writing%20tests-00aa00?style=for-the-badge\u0026labelColor=1FE417\" alt=\"\" /\u003e\n\u003c/p\u003e\n\n**My Own Java Is Totally Overtested** (**mojito** for short) is a combination of **parser**, **typechecker** and **executor**\ncapable of **run** a **simplified version of Java 1.8**.\n\nTo verify all the capabilities available, please check the [grammar](#grammar), but in summary:\n- **classes are NOT supported**. Only one file at a time might be read, and it will **not require** (nor it should be added)\n  a **class declaration**;\n- **functions are NOT supported**, however it is still possible to invoke methods and access fields from other classes;\n- **imports are NOT supported**, but one could use the canonical declaration to access non-default classes.\n  **Non-default classes** are, among the **primitive** and **wrapper** types, all those classes whose **package**\n  starts with either `java.lang`, `java.util` or `java.io`. Therefore, it is **not required** to specify the full\n  package for classes like [Map](https://docs.oracle.com/javase/8/docs/api/java/util/Map.html),\n  [IOException](https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html) or\n  [Class](https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html).\n  For others, the full **canonical name** will be needed.\n- the `this` keyword will have a special meaning: it will refer to the **object currently executing the program**,\n  which might be user defined. **WARNING**: when invoking implicit methods or obtaining implicit fields (without declaring\n  a variable before them), `this` will be **inferred** automatically.\n  This means that, if a script uses, for example, `System.out.println(toString())`, the `toString` method will be\n  applied to the executing object;\n- constants (`final`) are **not** supported.\n\n## Usage\n\n**Mojito** can be used in two ways:\n\n### Command Line\n\nTo utilize the parser from command line, simply navigate to the folder containing the latest `.jar` file.\nThen, use the following command:\n\n```\njava -jar mojito-LATEST.jar file_to_read.java\n```\n\nAt the moment, the program does not support any command line argument.\n\n### Import\n\n**Mojito** can be imported using one of the most common **three methods** ([Gradle](https://gradle.org/),\n[Maven](https://maven.apache.org/) or **JAR**) using `it.fulminazzo` as **group id** and `mojito` as **artifact**.\n\nThe [Fulminazzo repository (https://repo.fulminazzo.it/releases)](https://repo.fulminazzo.it/releases)\nis **mandatory** for these dependencies to work.\n\n- **Gradle**:\n\n  ```groovy\n  repositories {\n      maven { url = 'https://repo.fulminazzo.it/releases' }\n  }\n\n  dependencies {\n      implementation 'it.fulminazzo:mojito:latest.release'\n  }\n  ```\n\n- **Maven**:\n\n  ```xml\n  \u003crepository\u003e\n      \u003cid\u003efulminazzo\u003c/id\u003e\n      \u003curl\u003ehttps://repo.fulminazzo.it/releases\u003c/url\u003e\n  \u003c/repository\u003e\n  ```\n\n  ```xml\n  \u003cdependency\u003e\n      \u003cgroupId\u003eit.fulminazzo\u003c/groupId\u003e\n      \u003cartifact\u003emojito\u003c/artifact\u003e\n      \u003cversion\u003eLATEST\u003c/version\u003e\n  \u003c/dependency\u003e\n  ```\n\nThen, it is possible to start reading and executing code thanks to the \n[Mojito](./src/main/java/it/fulminazzo/mojito/Mojito.java) class, which provides two important functions:\n\n- `newRunner()`: allows creating a new runner with an empty object;\n- `newRunner(Object)`: allows creating a new runner and setting the given object as the result of the `this` keyword.\n\nA [Runner](./src/main/java/it/fulminazzo/mojito/Runner.java) is a special entity capable of handling Java code\nfrom **files**, **strings** or **input streams** thanks to the many versions of the `run` function.\n\nIt is also possible to pass default variables which will be initialized before executing the main program.\n\nAs an example, the code:\n\n```java\nString code = \"return name;\";\nMap\u003cString, Object\u003e variables = new HashMap\u003c\u003e();\nvariables.put(\"name\", \"fulminazzo\");\n\nRunner runner = Mojito.newRunner();\nrunner.run(code, variables);\n\nOptional\u003c?\u003e returnedValue = runner.latestResult();\n```\n\nwill return the parsed variable `name` (`fulminazzo`) in the _returnedValue_ \n[Optional](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html).\n\n## Roadmap\n\n- [ ] ternary operator (`a ? b : c`);\n- [ ] diamond operator (generics);\n- [ ] advanced wildcard handling (`super` and `extends`);\n- [ ] `final` keyword;\n- [ ] `instanceof` keyword (also Java 17 pattern matching);\n- [ ] lambda expressions.\n\n## Grammar\n\nThe following is the grammar respected by the parser:\n\n```\nJAVA_PROGRAM := SINGLE_STMT*\n\nBLOCK := CODE_BLOCK | SINGLE_STMT\nCODE_BLOCK := \\{ SINGLE_STMT* \\}\nSINGLE_STMT := STMT | ;\n\nSTMT := return EXPR; | throw EXPR; break; | continue; | \n        TRY_STMT | SWITCH_STMT | FOR_STMT | DO_STMT | WHILE_STMT | IF_STMT\n        ASSIGNMENT;\n\nTRY_STMT := try ( \\( ASSIGNMENT_BLOCK \\) )? CODE_BLOCK CATCH+ ( finally CODE_BLOCK )?\nASSIGNMENT_BLOCK := (ARRAY_LITERAL LITERAL ( = EXPR? ); )+\nCATCH := catch \\( ( LITERAL \\| )* LITERAL LITERAL \\) CODE_BLOCK\n\nSWITCH_STMT := switch \\( EXPR \\) \\{ (CASE_BLOCK)* (DEFAULT_BLOCK)? \\}\nCASE_BLOCK := case EXPR: ( CODE_BLOCK | SINGLE_STMT* )\nDEFAULT_BLOCK := default: ( CODE_BLOCK | SINGLE_STMT* )\n\nFOR_STMT := for \\( ASSIGNMENT?; EXPR?; EXPR? \\) BLOCK | ENHANCED_FOR_STMT\nENHANCED_FOR_STMT := for \\( ARRAY_LITERAL LITERAL : EXPR \\) BLOCK\n\nDO_STMT := do BLOCK while PAR_EXPR\nWHILE_STMT := while PAR_EXPR BLOCK\nIF_STMT := if PAR_EXPR BLOCK ( else IF_STMT )* ( else BLOCK )?\n\nASSIGNMENT := ARRAY_LITERAL LITERAL ( = EXPR? ) | LITERAL = EXPR | EXPR\n\nEXPR := NEW_OBJECT | INCREMENT | DECREMENT | AND\nNEW_OBJECT := new LITERAL METHOD_INVOCATION |\n              new ARRAY_LITERAL{ ( EXPR )? ( , EXPR )* \\} |\n              new LITERAL ( \\[ NUMBER_VALUE \\] )+\nARRAY_LITERAL := LITERAL ( \\[\\] )* | LITERAL ( \\[ [0-9]+ \\] )+\n\nINCREMENT := ++ATOM\nDECREMENT := --ATOM | MINUS\n\nAND := OR (\u0026\u0026 OR)*\nOR := EQUAL (|| EQUAL)*\nEQUAL := NOT_EQUAL (== NOT_EQUAL)* \nNOT_EQUAL := LESS_THAN (!= LESS_THAN)* \nLESS_THAN := LESS_THAN_EQUAL (\u003c LESS_THAN_EQUAL)* \nLESS_THAN_EQUAL := GREATER_THAN (\u003c= GREATER_THAN)* \nGREATER_THAN := GREATER_THAN_EQUAL (\u003e GREATER_THAN_EQUAL)* \nGREATER_THAN_EQUAL := BIT_AND (\u003e= BIT_AND)*\n\nBIT_AND := BIT_OR ( (\u0026 BIT_OR)* | (\u0026= BIT_OR) )\nBIT_OR := BIT_XOR ( (| BIT_XOR)* | (|= BIT_XOR) )\nBIT_XOR := LSHIFT ( (^ LSHIFT)* | (^= LSHIFT) )\n\nLSHIFT := RSHIFT ( (\u003c\u003c RSHIFT)* | (\u003c\u003c= RSHIFT) )\nRSHIFT := URSHIFT ( (\u003e\u003e URSHIFT)* | (\u003e\u003e= URSHIFT) )\nURSHIFT := ADD ( (\u003e\u003e\u003e ADD)* | (\u003e\u003e\u003e= ADD) )\n\nADD := SUB ( (+ SUB)* | (+= SUB) | ++ )\nSUB := MUL ( (- MUL)* | (-= MUL) | -- )\nMUL := DIV ( (* DIV)* | (*= DIV) )\nDIV := MOD ( (/ MOD)* | (/= MOD) )\nMOD := UNARY_OPERATION ( (% UNARY_OPERATION)* | (%= UNARY_OPERATION) )\n\nUNARY_OPERATION := CAST | NOT | METHOD_CALL\n\nCAST := (PAR_EXPR)* ( EXPR | PAR_EXPR )\nPAR_EXPR := \\( EXPR \\)\n\nMINUS := - EXPR\nNOT := ! EXPR\n\nMETHOD_CALL := ATOM ( .LITERAL METHOD_INVOCATION? )*\nMETHOD_INVOCATION := \\( (EXPR)? (, EXPR)* \\)\n\nATOM := NULL | THIS | ARRAY_LITERAL | TYPE_VALUE\nNULL := null\nTHIS := this\nLITERAL := [a-zA-Z_](?:[a-zA-Z0-9._]*[a-zA-Z0-9_])*\n\nTYPE_VALUE := NUMBER_VALUE | LONG_VALUE | DOUBLE_VALUE | FLOAT_VALUE |\n              BOOLEAN_VALUE | CHAR_VALUE | STRING_VALUE\n\nNUMBER_VALUE := [0-9]+\nLONG_VALUE := ([0-9]+)[Ll]?\nDOUBLE_VALUE := [0-9]+(?:.[0-9]+)?(?:E[-0-9]+)?[Dd]?\nFLOAT_VALUE := [0-9]+(?:.[0-9]+)?(?:E[-0-9]+)?[Ff]?\nBOOLEAN_VALUE := true|false\nSTRING_VALUE := \\\"((?:[^\\\"]|\\\\\\\")*)\\\nCHAR_VALUE := '([^\\r\\n\\t \\]|\\\\[rbnft\\\\\\\"\\'])'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffulminazzo%2Fmojito","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffulminazzo%2Fmojito","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffulminazzo%2Fmojito/lists"}