asdl 1.0.1

Parser for ASDL format. Describes the abstract syntax of compiler intermediate representations and other tree-like data structures
Documentation
{%- import "asdl/src/ast/macros.tera" as macros -%}

//This file is auotgenerated by using `cargo gen-syntax`

#![cfg_attr(rustfmt, rustfmt_skip)]

{% for ty_name in sum_types %}
{%- set ty = types[ty_name] -%}
{%- set type_name = ty.id | camel -%}

#[derive(PartialEq, Eq, Hash, Debug)]
pub(crate) enum {{ type_name }}<'a> {
{%- for c in ty.constructors %}
    {{c.id | camel }}({{ c.id | camel }}<'a>),
{%- endfor %}
}
{% for c in ty.constructors -%}
{%- set c_name = c.id | camel -%}
impl<'a> From<{{c_name}}<'a>> for {{ type_name }}<'a> {
    fn from(n: {{c_name}}) -> {{ type_name }} {
        {{ type_name }}::{{c_name}}(n)
    }
}
{% endfor -%}
{% for c in ty.constructors %}
{{ macros::type(ty = c) }}
{%- endfor %}
{% endfor -%}

{% for ty_name in prod_types %}
{%- set ty = types[ty_name] -%}
{%- if ty.id is ending_with("Id") or ty.id == "id" %}
{{ macros::id_type(ty = ty) }}
{%- else %}
{{ macros::type(ty = ty) }}
{%- endif -%}
{% endfor-%}