Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call for Feedback: Updated MLang Syntax #837

Open
marten-voorberg opened this issue Apr 25, 2024 · 1 comment
Open

Call for Feedback: Updated MLang Syntax #837

marten-voorberg opened this issue Apr 25, 2024 · 1 comment

Comments

@marten-voorberg
Copy link
Contributor

marten-voorberg commented Apr 25, 2024

As part of my master thesis, I am planning to make some (minor) alterations and additions to the MLang syntax with two goals:

  1. Add support for product extension
  2. Make the distinction of a syntax or semantic extension vs. a base declaration clearer

We have been using the term Product Extension as a catch-all term for functionality in which we are able to add new fields to existing constructors. Our canonical examples are adding a ty or info field to an existing language. I have been using the term fine-grained product extension to talk about the ability of specifying the fields to add for a single, specific constructor and the term coarse-grained product extension to describe adding fields to all constructors of a syntax. I also suggest introducing a nominal aspect into the product extension syntax by giving each product extension a name. The most important reason for this is that this name can be used in an eventual type system extension to more concisely represent types.

The following program demonstrates my proposed syntax.

lang A = 
    -- Syntax declaration
    syn S = 
    -- Semantic declaration
    sem f =
ed
lang B = A
    -- Sum Extension
    -- We add two constructors 'Foo' and 'Bar' to S
    syn S += 
    | Foo {}
    | Bar {x: Int}
    -- Semantic extension
    -- We add two additional cases to 'f'
    sem f += 
    | Foo _ -> 10
    | Bar {x = x} -> x
end
lang C = A + B
    -- Product Extension
    -- We add a field 'y' to each constructor in S
    -- And add a field 'z' to Foo specifically
    syn S as MyProdExt *= {y : Int}
    | Foo with {z : String}
end
@marten-voorberg
Copy link
Contributor Author

The base definition should not include an = symbol if no constructors or cases are defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant