Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mfelsche/pony-ast
:horse: :deciduous_tree: Library for accessing AST generated by ponyc
https://github.com/mfelsche/pony-ast
compiler ffi-bindings parser pony pony-language ponylang
Last synced: 26 days ago
JSON representation
:horse: :deciduous_tree: Library for accessing AST generated by ponyc
- Host: GitHub
- URL: https://github.com/mfelsche/pony-ast
- Owner: mfelsche
- Created: 2023-01-12T20:55:38.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-29T18:05:41.000Z (3 months ago)
- Last Synced: 2024-07-30T19:57:20.381Z (3 months ago)
- Topics: compiler, ffi-bindings, parser, pony, pony-language, ponylang
- Language: Pony
- Homepage:
- Size: 132 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Pony-AST :horse: :deciduous_tree:
Pony library wrapping `libponyc` via C-FFI, so Pony programs can finally compile themselves. :horse: :point_right: :horse:
## Current Status
This software is:
* Untested
* Dangerous
* Hacky
* hopelessly brokenIt will:
* Leak memory
* Eat all the memory on your machine
* Segfault
* Steal all of your bitcoins**Use only if you know what you are doing!**
## Requirements
In order to make the current compiler work, and have it pick up the Pony standard library one needs to point the `PONYPATH` environment variable to the pony stdlib. If you have a pony installation you compiled yourself, it will most likely live in: `ponyc-repository/packages`. If you have a pre-compiled installation obtained via ponyup it might live in something like: `$HOME/.local/share/ponyup/ponyc-release---/packages`.
## Usage
The main entrypoint is the Compiler, that is running the pony compiler passes until (including) the `expr` pass and is emitting the produced `ast_t` structure in the `Program` class. It can be used to access packages, modules and entities, rerieve AST nodes at certain positions, go to definitions etc. etc.
```pony
use ast = "ast"actor Main
new create(env: Env) =>
try
let path = FilePath(FileAuth(env.root), env.args(env.args.size() - 1)?)
match ast.Compiler.compile(env, path)
| let program: ast.Program =>
// do something with the parsed program AST
env.out.print("OK")
| let errors: Array[ast.Error] =>
// do something with the compilation errors
for e in errors.values() do
env.err.print(e.msg)
end
end
end
```