Structs: Add support for structs to the `Lexer`, `Parser`, and `Weeder`
Syntax Example I:
struct Box[r: Region] {
aBool: Bool
}
Syntax Example II:
struct Person[a: Type, r: Region] {
fstName: String,
lstName: String
}
Syntax Example III:
struct Box[a: Type, r: Region] {
value: a
}
Syntax Example IV:
struct Node[a: Type, r: Region] {
value: a
prev: Node[a, r]
next: Node[a, r]
}
We should discuss the data types in WeededAst. I would propose something like:
case class Struct(doc: Ast.Doc, ann: Ast.Annotations, mod: Ast.Modifiers, ident: Name.Ident, tparams: TypeParams, fields: List[Field], loc: SourceLocation) extends Declaration
case class Field(ident: Name.Ident, tpe: Type, loc: SourceLocation)
@dghosef I suggest that the first PR should simply be to add a new struct token to the Lexer.
@dghosef I added some more examples to the ticket.
@magnus-madsen I run into the problem that now since Weeder technically can return a struct, the desugar pattern matching is incomplete. Is there a way to temporarily silence this error? My current solution is to just throw an exception in the desugar phase upon matching with a struct
@dghosef I suggest that the first PR should simply be to add a new
structtoken to the Lexer.
Oh sorry I just saw this. Should I revert the other stuff I've done and make a smaller PR? I have put all the stuff I have done in a bigger draft PR here: https://github.com/flix/flix/pull/7927
@magnus-madsen I run into the problem that now since Weeder technically can return a struct, the desugar pattern matching is incomplete. Is there a way to temporarily silence this error? My current solution is to just throw an exception in the desugar phase upon matching with a struct
@dghosef I suggest that the first PR should simply be to add a new
structtoken to the Lexer.Oh sorry I just saw this. Should I revert the other stuff I've done and make a smaller PR? I have put all the stuff I have done in a bigger draft PR here: #7927
I suggest to work one phase at a time, just so everyone can keep up. The lexer PR should be easy 👍
@magnus-madsen I run into the problem that now since Weeder technically can return a struct, the desugar pattern matching is incomplete. Is there a way to temporarily silence this error? My current solution is to just throw an exception in the desugar phase upon matching with a struct
You have to throw an exception which is OK
Fixed in master.