Skip to content
/ glance Public

๐Ÿ‘๏ธโ€๐Ÿ—จ๏ธ A Gleam source code parser, in Gleam!

License

Notifications You must be signed in to change notification settings

lpil/glance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

glance

Package Version Hex Docs

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:

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:

[
  Definition(
    [],
    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.

About

๐Ÿ‘๏ธโ€๐Ÿ—จ๏ธ A Gleam source code parser, in Gleam!

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages