https://github.com/zhirzh/kotlin-parser-antlr
https://github.com/zhirzh/kotlin-parser-antlr
antlr4 kotlin parser
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/zhirzh/kotlin-parser-antlr
- Owner: zhirzh
- Created: 2021-05-08T19:34:18.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-05-08T22:01:51.000Z (about 5 years ago)
- Last Synced: 2025-02-18T05:16:06.215Z (over 1 year ago)
- Topics: antlr4, kotlin, parser
- Language: JavaScript
- Homepage: https://npm.im/kotlin-parser-antlr
- Size: 114 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Kotlin parser
Kotiln parser that generates a concrete syntax tree using, parser class generated by [ANTLR v4][] and kotlin grammar taken from [kotlinx/ast][].
# Build grammar
Follow these steps to build grammar classes:
1. Download [antlr4 grammar][] for Kotlin
1. Download [ANTLR tool itself][]
1. Install Java 8 JRE or JDK
With everything setup, run the following BASH script to generate classes `KotilnLexer` & `KotlinParser`.
```bash
#! /bin/bash
out_dir=./src/kotlin
# cleanup previous built files
rm -r $out_dir
# build files
java -jar \
-Dlanguage=JavaScript \
-no-listener \
-Xexact-output-dir \
-o $out_dir/ \
# cleanup
rm $out_dir/*.interp
rm $out_dir/*.tokens
```
[antlr v4]: https://github.com/antlr/antlr4#antlr-v4
[kotlinx/ast]: https://github.com/kotlinx/ast#kotlinxast
[antlr4 grammar]: https://github.com/kotlinx/ast/tree/master/grammar-kotlin-parser-common/src/commonAntlr/antlr
[antlr tool itself]: https://www.antlr.org/download/antlr-4.9.2-complete.jar