{"id":15056619,"url":"https://github.com/daniellansun/groovy-parser","last_synced_at":"2025-04-05T21:09:58.301Z","repository":{"id":41451986,"uuid":"65657924","full_name":"daniellansun/groovy-parser","owner":"daniellansun","description":"Yet another new parser for Groovy programming language(project code: Parrot)","archived":false,"fork":false,"pushed_at":"2025-01-18T20:11:55.000Z","size":86474,"stargazers_count":100,"open_issues_count":8,"forks_count":11,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-29T20:08:23.659Z","etag":null,"topics":["abstract-syntax-tree","antlr","antlr4","groovy","parser"],"latest_commit_sha":null,"homepage":"","language":"Groovy","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daniellansun.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2016-08-14T08:50:56.000Z","updated_at":"2025-01-18T20:11:56.000Z","dependencies_parsed_at":"2025-02-12T10:15:32.106Z","dependency_job_id":"a20b300d-294d-4a13-ac7c-16340f1b9160","html_url":"https://github.com/daniellansun/groovy-parser","commit_stats":{"total_commits":970,"total_committers":10,"mean_commits":97.0,"dds":0.2010309278350515,"last_synced_commit":"44e3ffb5e5bc4cf141a7bc7b1e371c86eff0ad7b"},"previous_names":[],"tags_count":52,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daniellansun%2Fgroovy-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daniellansun%2Fgroovy-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daniellansun%2Fgroovy-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daniellansun%2Fgroovy-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daniellansun","download_url":"https://codeload.github.com/daniellansun/groovy-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399885,"owners_count":20932880,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["abstract-syntax-tree","antlr","antlr4","groovy","parser"],"created_at":"2024-09-24T21:54:13.406Z","updated_at":"2025-04-05T21:09:58.260Z","avatar_url":"https://github.com/daniellansun.png","language":"Groovy","funding_links":[],"categories":[],"sub_categories":[],"readme":"# groovy-parser(Parrot)\n[![GithubActions](https://github.com/daniellansun/groovy-parser/actions/workflows/build-test.yml/badge.svg?branch=master)](https://github.com/daniellansun/groovy-parser/actions?query=branch%3Amaster++)\n[![Java 8+](https://img.shields.io/badge/java-8+-4c7e9f.svg)](http://www.oracle.com/technetwork/java/javase/downloads)\n[![Apache License 2](https://img.shields.io/badge/license-APL2-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0.txt)\n[![Join the chat at https://gitter.im/groovy-parser/Lobby](https://badges.gitter.im/groovy-parser/Lobby.svg)](https://gitter.im/groovy-parser/Lobby?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n[![follow on Twitter](https://img.shields.io/twitter/follow/daniel_sun.svg?style=social)](https://twitter.com/intent/follow?screen_name=daniel_sun)\n\nThe new parser(Parrot) can parse Groovy source code and construct the related AST, which is almost identical to the one generated by the old parser(except the corrected node position, e.g. line, column of node). Currently all features of Groovy are available. In addition, **the following new features have been added:**\n\n* do-while loops; enhanced (now supporting commas) classic for loops, e.g. `for(int i = 0, j = 10; i \u003c j; i++, j--) {..}`)\n* lambda expressions, e.g. `stream.map(e -\u003e e + 1)`\n* method references and constructor references\n* try-with-resources, AKA ARM\n* switch-expression\n* sealed type\n* record type\n* code blocks, i.e. `{..}`\n* Java style array initializers, e.g. `new int[] {1, 2, 3}`\n* default methods within interfaces\n* additional places for type annotations\n* new operators: identity operators(`===`, `!==`), elvis assignment(`?=`), `!in`, `!instanceof`\n* safe index, e.g. `nullableVar?[1, 2]`\n* non-static inner class instantiation, e.g. `outer.new Inner()`\n* runtime groovydoc, i.e. groovydoc starting with `/**@`; groovydoc attached to AST node as metadata\n\n**JVM system properties to control parsing:**\n\n| Option | Description | Default                    | Example |\n| ---- | ---- |----------------------------| ---- |\n| groovy.antlr4.cache.threshold | antlr4 relies on DFA cache heavily for better performance, so antlr4 will not clear DFA cache, thus OutOfMemoryError will probably occur. Groovy trades off parsing performance and memory usage, when the count of Groovy source files parsed hits the cache threshold, the DFA cache will be cleared. *Note:* `0` means managing the DFA cache automatically, `-1` means never clearing DFA cache, so requiring bigger JVM heap size. Or set a greater value, e.g. 200 to clear DFA cache if threshold hits. **Note: ** the threshold specified is the count of groovy source files | `0`                        | -Dgroovy.antlr4.cache.threshold=200 |\n| groovy.antlr4.sll.threshold | Parrot parser will try SLL mode and then try LL mode if SLL failed. But the more tokens to parse, the more likely SLL will fail. If SLL threshold hits, SLL will be skipped. Setting the threshold to `0` means never trying SLL mode, which is not recommended at most cases because SLL is the fastest mode though SLL is less powerful than LL. **Note: ** the threshold specified is the token count | `-1` (disabled by default) | -Dgroovy.antlr4.sll.threshold=1000 |\n| groovy.antlr4.clear.lexer.dfa.cache | Clear the DFA cache for lexer. The DFA cache for lexer is always small and important for parsing performance, so it's strongly recommended to leave it as it is util OutOfMemoryError will truely occur | `false`                    | -Dgroovy.antlr4.clear.lexer.dfa.cache=true |\n\n\n\n**Parrot is based on the highly optimized version of antlr4(com.tunnelvisionlabs:antlr4), which is licensed under BSD. On 20161103 Parrot was contributed to Apache Groovy, but the project will be maintained as a lab to experiment new features for Groovy. You can find it at [apache/groovy](https://github.com/apache/groovy/tree/master/subprojects/parser-antlr4).**\n\n### Sample Code\n* [Sample code from Apache Groovy 3.0 release note](http://groovy-lang.org/releasenotes/groovy-3.0.html)\n\n### FAQ\n\n##### Question(from Slack):\n```\nCan someone explain to me the importance of the Parrot compiler? Basically explain like I am 5?\n```\n##### Answer(by Guillaume Laforge, Project Lead of Apache Groovy):\n```\nthe syntax of Groovy hasn’t evolved in a long time\nthe current / old parser is a bit complicated to evolve\nand is using a very old version of the parsing library\nso any change we’d want to make to the language (a new operator, for example) becomes very complicated\nSo we’ve been wanting to upgrade the underlying parser library for a while, but since the library evolved a lot, that also required a rewrite of the grammar of the language\nBut there’s another thing to consider\nGroovy’s always been adopted by Java developers easily because of how close to the Java syntax it’s always been\nso most Java programs are also valid Groovy programs\nit’s been important to Groovy’s success to have this source compatibility\nJava 8's been out for a while already\nand we’ve been asked countless times if we’d support this or that particular syntax enhancement from Java 8\nfor “copy’n paste compatibility”, if you will\nWe decided to upgrade to a newer version of our parsing library (from v2 to v4 of Antlr)\nto allow Groovy’s syntax to continue to evolve\nto also support new operators and things like that\nbut to also support Java 8 constructs, for continued compatibility\nAnd that’s about it\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaniellansun%2Fgroovy-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaniellansun%2Fgroovy-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaniellansun%2Fgroovy-parser/lists"}