-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The previous commit introducing the new AST used the "old" type representation from mainline Nickel. Now that `typ::Type` has been made more generic, we can use a better representation that can be arena allocated as well and can contain contracts that are themselves represented in the new AST. This commit integrates this new type representation and add corresponding translation functions from the mainline implementation.
- Loading branch information
Showing
3 changed files
with
150 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//! Representation of Nickel types in the AST. | ||
|
||
use super::{Ast, TermPos}; | ||
use crate::typ as mainline_typ; | ||
pub use mainline_typ::{EnumRowF, EnumRowsF, RecordRowF, RecordRowsF, TypeF}; | ||
|
||
/// The recursive unrolling of a type, that is when we "peel off" the top-level layer to find the actual | ||
/// structure represented by an instantiation of `TypeF`. | ||
pub type TypeUnr<'ast> = TypeF<&'ast Type<'ast>, RecordRows<'ast>, EnumRows<'ast>, Ast<'ast>>; | ||
|
||
/// The recursive unrolling of a enum rows. | ||
pub type EnumRowsUnr<'ast> = EnumRowsF<&'ast Type<'ast>, &'ast EnumRows<'ast>>; | ||
|
||
/// The recursive unrolling of record rows. | ||
pub type RecordRowsUnr<'ast> = RecordRowsF<&'ast Type<'ast>, &'ast RecordRows<'ast>>; | ||
|
||
/// Concrete, recursive definition for an enum row. | ||
pub type EnumRow<'ast> = EnumRowF<&'ast Type<'ast>>; | ||
/// Concrete, recursive definition for enum rows. | ||
#[derive(Clone, PartialEq, Debug)] | ||
pub struct EnumRows<'ast>(pub EnumRowsUnr<'ast>); | ||
/// Concrete, recursive definition for a record row. | ||
pub type RecordRow<'ast> = RecordRowF<&'ast Type<'ast>>; | ||
#[derive(Clone, PartialEq, Debug)] | ||
/// Concrete, recursive definition for record rows. | ||
pub struct RecordRows<'ast>(pub RecordRowsUnr<'ast>); | ||
|
||
/// Concrete, recursive type for a Nickel type. | ||
#[derive(Clone, PartialEq, Debug)] | ||
pub struct Type<'ast> { | ||
pub typ: TypeUnr<'ast>, | ||
pub pos: TermPos, | ||
} |