kotlin-parser-antlr

1.0.0 • Public • Published

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
  2. Download ANTLR tool itself
  3. Install Java 8 JRE or JDK

With everything setup, run the following BASH script to generate classes KotilnLexer & KotlinParser.

#! /bin/bash

out_dir=./src/kotlin

# cleanup previous built files
rm -r $out_dir

# build files
java -jar <PATH TO ANTLR JAR> \
  -Dlanguage=JavaScript \
  -no-listener \
  -Xexact-output-dir \
  -o $out_dir/ \
  <PATH TO GRAMMAR>

# cleanup
rm $out_dir/*.interp
rm $out_dir/*.tokens

Readme

Keywords

Package Sidebar

Install

npm i kotlin-parser-antlr

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

1.1 MB

Total Files

8

Last publish

Collaborators

  • zhirzh