fkling / fkling/astexplorer

[ Not an Issue] - generate AST with ANTLR4 grammars

Open
#413 2 comments 3 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
6.5k
Forks
772
PR merge metrics
No merged PRs in 30d

Description

Your project is awesome, and I wonder if you are aware of this:

https://github.com/antlr/grammars-v4

It's a huge collection of language grammars which can generate JavaScript parsers.

I was playing a with those and made my own ast-explorer:

Playground: https://cancerberosgx.github.io/demos/univac/playground/

Project page: https://github.com/cancerberoSgx/univac

Tried to focus on languages that this project doesn't support, like Java, C++, go, ruby, smalltalk, python, erlang, dart, C, fortran, vb6, less, sass, webassembly, and others.

The big catch is that antlr4 is not designed to build ASTs but to visit nodes as they are declared in the grammar. So I needed to remove some node kinds in certain conditions in certain languages. Also the generated tree structure is defined by the grammar, and and doesn't have to match the format language AST.

Nevertheless, most of the grammars are easily portable to JS/browser so I wanted to heads up the authors of this project about this.

Also wonder if you would accept a PR with a proposal of such a AST generator, for example Java / C / C++ / python which seems to be kind of official grammars ? And if you already know about this, I wonder what's you opinion on using this approach to build ASTs ?

Thanks, keep it up!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.