{"id":24708764,"url":"https://github.com/ruisoftware/antlr4-file-generator","last_synced_at":"2026-05-18T17:05:57.547Z","repository":{"id":78665696,"uuid":"99426274","full_name":"ruisoftware/antlr4-file-generator","owner":"ruisoftware","description":"Automatically generates Java and JavaScript files based on information retrieved from a plain text file.","archived":false,"fork":false,"pushed_at":"2017-08-12T22:35:38.000Z","size":29,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-22T06:28:39.461Z","etag":null,"topics":["antlr4","antlr4-grammar","file","generator","java","javascript","maven-plugin","parser"],"latest_commit_sha":null,"homepage":null,"language":"Java","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/ruisoftware.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}},"created_at":"2017-08-05T14:03:04.000Z","updated_at":"2017-10-31T20:20:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"873cda45-97b1-4073-8ac1-1e2cba25c5cc","html_url":"https://github.com/ruisoftware/antlr4-file-generator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ruisoftware/antlr4-file-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruisoftware%2Fantlr4-file-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruisoftware%2Fantlr4-file-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruisoftware%2Fantlr4-file-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruisoftware%2Fantlr4-file-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ruisoftware","download_url":"https://codeload.github.com/ruisoftware/antlr4-file-generator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ruisoftware%2Fantlr4-file-generator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33184769,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-18T09:27:30.708Z","status":"ssl_error","status_checked_at":"2026-05-18T09:27:28.300Z","response_time":71,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["antlr4","antlr4-grammar","file","generator","java","javascript","maven-plugin","parser"],"created_at":"2025-01-27T06:47:27.052Z","updated_at":"2026-05-18T17:05:57.536Z","avatar_url":"https://github.com/ruisoftware.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# antlr4-file-generator\nAutomatically generates Java and JavaScript files based on information retrieved from a plain text file.\n\nThis is a simple Java application that uses ANTLR4 to read a raw text file and generate Java and Javascript files that basically contain the same data.  \n\nANTLR4 is included as a maven plugin. You might choose to direcly download the [jar file](http://www.antlr.org/download.html).\n````xml\n\u003cartifactId\u003eantlr4-maven-plugin\u003c/artifactId\u003e\n````\n## When can this be useful?\nThe classic example is to make sure your Java POJOs map correcly to JSon objects.   \n\nAnother example is that when the frontend sends an http request, the server responds with data that both the backend and the frontend unambiguously interpret in the same way.\n\n## Before you start\nRun maven clean and install.  \n````bash\nmvn clean install\n````\nThis will let ANTLR4 generate Java sources used to perform the lexing and parsing phrases on your text file, i.e.\nif your grammar is named `Mapping.g4` then a `MappingLexer.java`, `MappingParser.java` and `MappingBaseListener.java` are created.  \nAnalogously, if your grammar is `math.g4`, then a `mathLexer.java`, `mathParser.java` and `mathBaseListener.java` are created. The later goes\nagainst the Java convention of capitalizing class names, so make sure your grammar is also capitalized.\n\n\n## How it works?\n- Edit `resources/datasource.txt` with the information you wish to place in your Java and JavaScript files.  \nThis information has to respect the rules defined in the `antlr4/Mapping.g4` grammar;\n- Run `Generate.main()` to generate the Java and JavaScript files into the `output` directory.\n\n## Examples\nHere is a very simple example, where the `resourses/datasource.txt` contents is\n````txt\nSampleFile\n================\nfoo = 3\n````\n\nThe first line sets the name for the Java and Javascript files. The second line is simply a separator and finally the data section that contains only one assignment.  \n\nWhen you run `Generate.main()` the output is\n````txt\nGenerating Java and Javascript files from resources/datasource.txt ...\nCreated /Users/ruisoftware/work/antlr4-file-generator/output/SampleFile.java\nCreated /Users/ruisoftware/work/antlr4-file-generator/output/sampleFile.js\n\nProcess finished with exit code 0\n````\n\nThe generated Java file is placed at `output/SampleFile.java`\n````java\npublic class SampleFile {\n\n    private static final int foo = 3;\n    \n}\n````\nand the correspondent JavaScript file at `output/sampleFile.js`\n````javascript\nvar foo = 3;\n````\n\nNow, let's add a more complex `bar`\n````txt\nSampleFile\n================\nfoo = 3\n\nbar = map (\n        a = -1.2\n        b = 0\n        c = [2, hello, [3]]\n        d = map (\n              d1 = 2\n              d2 = 200\n           )\n        e = []\n    )\n````\nYou can use integers, floating-point numbers, strings, maps and arrays in any combination. Arrays and maps can include other data of any type at any deepness level.  \nThis time, the generated `output/SampleFile.java` is\n\n````java\nimport java.lang.Integer;\nimport java.util.LinkedHashMap;\nimport java.util.LinkedList;\nimport java.util.List;\nimport java.util.Map;\n\npublic class SampleFile {\n\n    private static final int foo = 3;\n    \n    private static final Map\u003cString, Object\u003e bar = new LinkedHashMap\u003cString, Object\u003e() {{\n        put(\"a\", new Float(-1.2f));\n        put(\"b\", new Integer(0));\n        put(\"c\", new LinkedList\u003cObject\u003e() {{\n            add(new Integer(2));\n            add(\"hello\");\n            add(new LinkedList\u003cInteger\u003e() {{\n                add(new Integer(3));\n            }});\n        }});\n        put(\"d\", new LinkedHashMap\u003cString, Integer\u003e() {{\n            put(\"d1\", new Integer(2));\n            put(\"d2\", new Integer(200));\n        }});\n        put(\"e\", new LinkedList\u003cObject\u003e());\n    }};\n    \n}\n````\nand the `output/sampleFile.js`\n````javascript\nvar foo = 3;\n\nvar bar = {\n    \"a\": -1.2,\n    \"b\": 0,\n    \"c\": [\n        2,\n        \"hello\", [3]\n    ],\n    \"d\": {\n        \"d1\": 2,\n        \"d2\": 200\n    },\n    \"e\": []\n};\n````\n\n## License\nThis project is licensed under the terms of the [MIT license](https://opensource.org/licenses/mit-license.php)\n\n## Bug Reports \u0026 Feature Requests\nPlease use the [issue tracker](https://github.com/ruisoftware/antlr4-file-generator/issues) to report any bugs or file feature requests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruisoftware%2Fantlr4-file-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fruisoftware%2Fantlr4-file-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fruisoftware%2Fantlr4-file-generator/lists"}