Sign in

    moonrockz/gleam-parser/targets does not have a README file

    RegistrationError

    pub(all) suberror RegistrationError {
    InvalidName(String)
    Conflict(String)
    } derive(Eq,
    Debug
    )

    An invalid name or a registration that conflicts with an existing target. Conflict names the canonical target. Registration never replaces a value.

    Name

    pub struct Name {
    value : String
    } derive(Eq, Hash,
    Debug
    )

    A target name that the scanner reads as one ordinary name. Standard identities and their aliases cannot be extension names. Construct this value with Name::Name or Name::from_string.

    Name::Name

    fn Name::Name(value : String) -> Name raise RegistrationError

    Validate an extension name. Raise InvalidName for keywords, standard target names, aliases, whitespace, or punctuation.

    test {
    assert_eq(@targets.Name("orbit").to_string(), "orbit")
    assert_eq(@targets.Name::from_string("js"), None)
    }

    Name::from_string

    fn Name::from_string(value : String) -> Name?

    Validate a name without raising an error. Return None for invalid names.

    Name::to_string

    fn Name::to_string(self : Name) -> String

    Return the validated source spelling.

    Registry

    pub struct Registry {
    targets : ArrayView[Target]
    } derive(Eq,
    Debug
    )

    An immutable set of canonical target identities. Standard identities and aliases are reserved. Use standard, then register for each extension.

    Registry::all

    fn Registry::all(self : Registry) -> Array[Target]

    Return a copy of the registered identities in deterministic order, with standard targets first.

    Registry::register

    fn Registry::register(self : Registry, target : Target) -> Registry raise RegistrationError

    Return a new registry with this extension. Raise Conflict if the canonical name already exists, including either standard identity. The original registry is unchanged on success and failure.

    test {
    let base = @targets.Registry::standard()
    let orbit = @targets.Target::extension("orbit")
    let extended = base.register(orbit)
    assert_eq(base.resolve("orbit"), None)
    assert_eq(extended.resolve("orbit"), Some(orbit))
    }

    Registry::resolve

    fn Registry::resolve(self : Registry, name : String, aliases? : Bool) -> Target?

    Resolve a registered canonical name. With aliases=true, also resolve the compiler's deprecated erl and js shorthands. The parser uses these shorthands only for @target, matching standard Gleam.

    Registry::standard

    fn Registry::standard() -> Registry

    The strict standard registry: Erlang and JavaScript.

    Target

    pub(all) enum Target {
    Erlang
    JavaScript
    Extension(Name)
    } derive(Eq, Hash,
    Debug
    )

    An execution or translation destination. Registration enables syntax and representation; it does not supply a backend or resolve foreign symbols. Extension identities contain a validated name and require no new enum case.

    Target::extension

    fn Target::extension(name : String) -> Target raise RegistrationError

    Construct an extension identity. Raise InvalidName for reserved or malformed names. Register the identity in a dialect before parsing it.

    Target::name

    fn Target::name(self : Target) -> String

    Return the canonical source and JSON spelling.

    Target::of

    fn Target::of(name : String) -> Target?

    Read a standard compiler target name. Extensions require registry lookup.

    Source Files

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io