{"id":15050689,"url":"https://github.com/alschmut/objectivecparser","last_synced_at":"2026-01-02T04:42:14.481Z","repository":{"id":226176829,"uuid":"767967317","full_name":"alschmut/ObjectiveCParser","owner":"alschmut","description":"An Antlr4 Parser for Objective-C, Java and Kotlin code, calculating the lines of code per method","archived":false,"fork":false,"pushed_at":"2024-03-08T16:31:41.000Z","size":1079,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-20T21:50:02.942Z","etag":null,"topics":["antlr4","grammar","java","kotlin","lines-of-code","objc","objective-c","parser","static-analysis"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alschmut.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":"2024-03-06T08:22:45.000Z","updated_at":"2024-03-15T15:27:59.000Z","dependencies_parsed_at":"2024-09-29T02:20:55.588Z","dependency_job_id":"a28b7490-83e7-4f9d-9987-348c54bde50a","html_url":"https://github.com/alschmut/ObjectiveCParser","commit_stats":null,"previous_names":["alschmut/objectivecparser"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alschmut%2FObjectiveCParser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alschmut%2FObjectiveCParser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alschmut%2FObjectiveCParser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alschmut%2FObjectiveCParser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alschmut","download_url":"https://codeload.github.com/alschmut/ObjectiveCParser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234862659,"owners_count":18898393,"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":["antlr4","grammar","java","kotlin","lines-of-code","objc","objective-c","parser","static-analysis"],"created_at":"2024-09-24T21:28:56.011Z","updated_at":"2026-01-02T04:42:14.447Z","avatar_url":"https://github.com/alschmut.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ObjectiveCParser\n\nObjectiveCParser performs a static analysis on Objective-C code to calculate the metric *lines of code per method*. The result is written to a *.csv file. ObjectiveCParser is a python script, which uses a generated [antlr4](https://wwwpyt.antlr.org) parser for the given Objective-C language grammar from [antlr-grammars-v4](https://github.com/antlr/grammars-v4).\n\n\u003e Please star this repository, if you found the project helpful :)\n\n## Installation Requirements\nMake sure python3 (including pip3) is installed. Install [antlr4](https://wwwpyt.antlr.org), which enables parsing source code.\n```sh\npip3 install antlr4-python3-runtime\npip3 install antlr4-tools\n```\n\n## How to analyse your Objective-C code?\n```sh\ngit clone https://github.com/alschmut/ObjectiveCParser.git\npython3 src/main/ProjectParser.py /path/to/MyObjectiveCProject\n```\n\nThis generates a `*.csv` file with the below structure:\n\n|path                               |method_loc\n|---                                |---\n|/path/to/MyFile.m/someMethod       |1\n|/path/to/MyFile.m/anotherMethod    |5\n\n## How to visualise the metrics?\nI can reccommend using the Open-Source tool [CodeCharta](https://github.com/MaibornWolff/codecharta), which visualises metrics with a 3D city. Just follow the below steps:\n1. `npm i -g codecharta-analysis`\n1. `ccsh csvimport -d=\";\" -o MyObjectiveCProject.cc.json MyObjectiveCProject.csv`\n1. Open the [CodeCharta Web Demo](https://maibornwolff.github.io/codecharta/visualization/app/index.html?file=codecharta.cc.json.gz\u0026file=codecharta_analysis.cc.json.gz) and import the generated `MyObjectiveCProject.cc.json` file\n\n## How to add a new programming language to be analysed with antlr4\n\n### Generate Python classes for a new grammar\n- Find the \u003cnew_language\u003e grammar on [antlr-grammars-v4](https://github.com/antlr/grammars-v4)\n- Create a new folder `\u003cnew_language\u003e` inside `src/main/antlrParser/`\n- Copy paste all `.g4` files like Parser, Lexer or UnicodeClasses into the \u003cnew_language\u003e folder\n- Execute `antlr4 -Dlanguage=Python3 *.g4` inside your \u003cnew_language\u003e folder. This generates some Python3 classes and other files\n\n### Override generated listener methods\n- Create a new file `\u003cnew_language\u003eListenerExtended.py` inside `src/main/antlrParser/ExtendedListener/`\n- Create a new class which just looks similar to the other existing classes like `ObjcParserListenerExtended` and extend the BaseListener class\n- Override the language specific `enter...()` functions. To find out which functions to override, have a look at the hierarchical grammar definition inside `\u003cyour_language\u003eParser.g4`. Then store the obtained values inside the predefined BaseListener class.\n\n### Walk through the new grammar\nCreate another function inside the `src/main/antlrParser/LanguageParser.py` like below. Replace the placeholder with your generated/created classes.\n```python\ndef parse_\u003cyour_language\u003e_file(self, input_stream: InputStream):\n    lexer = \u003cyour_generated_lexer\u003e(input_stream)\n    stream = CommonTokenStream(lexer)\n    parser = \u003cyour_generated_parser\u003e(stream)\n    tree = parser.\u003cyour_top_level_grammar_node\u003e()\n    listener = \u003cyour_expanded_listener\u003e()\n    return self.walk(listener, tree)\n```\n### Add your supported language extension\nInside `src/main/antlrParser/Lanague.py` an enum with all supported programming languages is stored. Add your language name with its file-extension\n\n### Add new option to use your parse_\u003cyour_language\u003e_file function\nThe `LanguageParser.parse_file()` function calls the appropriate parsing function for each language. Add yours with another if-statement checking the file extension\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falschmut%2Fobjectivecparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falschmut%2Fobjectivecparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falschmut%2Fobjectivecparser/lists"}