• Stars
    star
    102
  • Rank 326,748 (Top 7 %)
  • Language
    Kotlin
  • License
    Apache License 2.0
  • Created about 7 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Kotlin Language Support โ€“ AST Library

Kolasu

Maven Central GitHub Actions Workflow Status

Kolasu supplies the infrastructure to build a custom, possibly mutable, Abstract Syntax Tree (AST) using Kotlin. In particular, it can be integrated easily with ANTLR, but it can also be used on its own. Kolasu strives to be usable and idiomatic also in Java projects.

It stands for Kotlin Language Support.

Kolasu is part of the StarLasu set of libraries. The other libraries provide similar support in other languages such as Typescript and Python.

JDK supported

We support JDK 8, 11, and 17. All JDKs in between should work too, but these are explicitly tested.

Documentation

You can take a look at the documentation for StarLasu, as it explain the principles used in the whole set of libraries, including Kolasu: StarLasu documentation.

The documentation of Kolasu's APIs is on Maven Central for consumption by IDEs. It's also possible to consult it online at https://www.javadoc.io/doc/com.strumenta.kolasu.

What do we use Kolasu for?

Kolasu has been used to implement:

  • Parsers
  • Editors
  • Transpilers
  • Code analysis tools

Features

Extend your AST classes from Node to get these features:

  • Navigation: utility methods to traverse, search, and modify the AST
  • Printing: print the AST as XML, as JSON, as a parse tree
  • EMF interoperability: ASTs and their metamodel can be exported to EMF

Classes can have a name, and classes can reference a name. Utilities for resolving these references are supplied.

Kolasu tries to be non-invasive and implements this functionality by introspecting the AST. All properties, and therefore the whole tree structure, will be detected automatically.

Origin

Kolasu was born as a small framework to support building languages using ANTLR and Kotlin. It evolved over the time as it was used at Strumenta as part of open-source and commercial projects for building transpilers, interpreters, compilers, and more.

Using Kolasu in your project

Releases are published on Maven Central:

dependencies {
    compile "com.strumenta.kolasu:kolasu-core:1.5.0-RC5"
}

How to format code

Run:

./gradlew ktlintFormat

Projects using Kolasu

Kolasu is used in several internal and commercial projects developed at Strumenta.

Publishing a new release

If you do not have gpg keys:

  1. Install gpg (brew install gnupg on mac)
  2. Generate the key (gpg --gen-key, no passphrase needed)
  3. Publish the key

Instructions available here: https://selectfrom.dev/publishing-your-first-open-source-library-with-gradle-50bd0b1cd3af

Please note that you may have to export the keys (gpg --keyring secring.gpg --export-secret-keys > ~/.gnupg/secring.gpg)

You will need to store in ~/.gradle/gradle.properties your sonatype credentials under ossrhUsername and ossrhPassword

New release can be made by running:

./gradlew release

Releases must then be manually completed by visiting https://oss.sonatype.org/#stagingRepositories.

More Repositories

1

antlr-kotlin

Support for Kotlin as a target for ANTLR
Kotlin
178
star
2

SmartReader

SmartReader is a library to extract the main content of a web page, based on a port of the Readability library by Mozilla
C#
138
star
3

calc-monaco-editor

A browser based editor for a simple DSL to perform calculations
TypeScript
53
star
4

rpg-to-java-transpiler

An RPG to Java transpiler
Kotlin
35
star
5

article-llvm-rpg

C++
31
star
6

StarLasu

A collection of libraries to work with languages from Java, Kotlin, Python, Javascript, and Typescript
CSS
24
star
7

article-antlr4-c3

The code for the article, Code Completion with antlr4-c3
ANTLR
21
star
8

tylasu

TypeScript
19
star
9

MPSServer

Python
18
star
10

pylasu

Python
14
star
11

webeditkit

A framework to build projectional editors running in the browser
TypeScript
13
star
12

FormatsDSL

A DSL to describe formats and generate loaders
10
star
13

article-antlr4-c3-vscode

Code for the article, Integrating Code Completion in Visual Studio Code With the Language Server Protocol
TypeScript
10
star
14

transformers

Language2Language Transformers: machine learning to build transpilers.
Python
7
star
15

article-lsp-go-to-definition

TypeScript
5
star
16

textx-tutorial

Python
5
star
17

wasi-tutorial

TypeScript
4
star
18

calc-webeditkit-example

JavaScript
4
star
19

sharplasu

CSharp Language Support โ€“ AST Library
C#
4
star
20

financialdsl

Kotlin
3
star
21

kolasu-tutorial

Kotlin
2
star
22

article-python-excel

Code for the article "Working with Excel in Python"
Python
2
star
23

mpsserver-client

TypeScript
2
star
24

kotlin-mps

2
star
25

mpswizard-gradle-plugin

Kotlin
2
star
26

sas-parser-samples

Java
2
star
27

spoofax-tutorial

Java
1
star
28

article-peggy

CSS
1
star
29

article-cross-language-navigation

Kotlin
1
star
30

jar_mps

This is the companion repository of the tutorial that shows how to add JARs to a Jetbrains MPS Project
Java
1
star
31

tylasu-hello-world

Hello World with Tylasu
TypeScript
1
star
32

mpsserverdemo

JavaScript
1
star
33

kolasu-languageserver-library

Kotlin
1
star