glance

Package VersionHex Docs

A Gleam source code parser, in Gleam!

Currently this library will parse the following:

All other Gleam syntax is skipped over.

Usage

Add the package to your Gleam project:

gleam add glance

Then get parsing!

import glance
import gleam/io
const 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:

[
CustomType(
name: "Cardinal",
publicity: Public,
parameters: [],
variants: [
Variant("North", []),
Variant("East", []),
Variant("South", []),
Variant("West", []),
],
),
]

API documentation can be found at https://hexdocs.pm/glance.