https://github.com/lpil/glance
👁️🗨️ A Gleam source code parser, in Gleam!
https://github.com/lpil/glance
Last synced: about 2 months ago
JSON representation
👁️🗨️ A Gleam source code parser, in Gleam!
- Host: GitHub
- URL: https://github.com/lpil/glance
- Owner: lpil
- License: apache-2.0
- Created: 2023-05-12T10:29:28.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-25T15:05:45.000Z (about 1 year ago)
- Last Synced: 2024-05-18T10:22:37.845Z (12 months ago)
- Language: Gleam
- Homepage:
- Size: 98.6 KB
- Stars: 34
- Watchers: 6
- Forks: 7
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
- awesome-gleam - rank - [📚](https://hexdocs.pm/rank/) - Ordinals for numbers, e.g. 1st, 2nd, 3rd (Packages / Text)
README
# glance
[](https://hex.pm/packages/glance)
[](https://hexdocs.pm/glance/)A Gleam source code parser, in Gleam!
Glance attempts to be permissive with regards to what it will parse and so it is
able to parse some code that the Gleam compiler will reject as invalid.## Usage
Add the package to your Gleam project:
```sh
gleam add glance
```Then get parsing!
```gleam
import glance
import gleam/ioconst code = "
pub type Cardinal {
North
East
South
West
}
"pub fn main() {
let assert Ok(parsed) = glance.module(code)
io.debug(parsed.custom_types)
}
```This program print this to the console:
```gleam
[
Definition(
[],
CustomType(
name: "Cardinal",
publicity: Public,
parameters: [],
variants: [
Variant("North", []),
Variant("East", []),
Variant("South", []),
Variant("West", []),
],
),
),
]
```API documentation can be found at .