conlang: Docs!
This commit is contained in:
parent
3534be5fbc
commit
0c2b0002ce
@ -8,6 +8,7 @@
|
|||||||
//! - [Assign], [Modify], [Binary], and [Unary] expressions
|
//! - [Assign], [Modify], [Binary], and [Unary] expressions
|
||||||
//! - [ModifyKind], [BinaryKind], and [UnaryKind] operators
|
//! - [ModifyKind], [BinaryKind], and [UnaryKind] operators
|
||||||
//! - [Ty] and [TyKind]: Type qualifiers
|
//! - [Ty] and [TyKind]: Type qualifiers
|
||||||
|
//! - [Pattern]: Pattern matching operators
|
||||||
//! - [Path]: Path expressions
|
//! - [Path]: Path expressions
|
||||||
use cl_structures::{intern::interned::Interned, span::*};
|
use cl_structures::{intern::interned::Interned, span::*};
|
||||||
|
|
||||||
@ -351,7 +352,7 @@ pub enum ExprKind {
|
|||||||
Quote(Quote),
|
Quote(Quote),
|
||||||
/// A local bind instruction, `let` [`Sym`] `=` [`Expr`]
|
/// A local bind instruction, `let` [`Sym`] `=` [`Expr`]
|
||||||
Let(Let),
|
Let(Let),
|
||||||
/// A [Match] expression, `match` [Expr] `{` ([MatchArm] `,`)* [MatchArm]? `}`
|
/// A [Match] expression: `match` [Expr] `{` ([MatchArm] `,`)* [MatchArm]? `}`
|
||||||
Match(Match),
|
Match(Match),
|
||||||
/// An [Assign]ment expression: [`Expr`] (`=` [`Expr`])\+
|
/// An [Assign]ment expression: [`Expr`] (`=` [`Expr`])\+
|
||||||
Assign(Assign),
|
Assign(Assign),
|
||||||
@ -426,16 +427,17 @@ pub enum Pattern {
|
|||||||
Struct(Path, Vec<(Path, Option<Pattern>)>),
|
Struct(Path, Vec<(Path, Option<Pattern>)>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A `match` expression: `match` `{` ([MatchArm] `,`)* [MatchArm]? `}`
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
pub struct Match {
|
pub struct Match {
|
||||||
pub scrutinee: Box<Expr>,
|
pub scrutinee: Box<Expr>,
|
||||||
pub arms: Vec<MatchArm>,
|
pub arms: Vec<MatchArm>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A single arm of a [Match] expression: [`Pattern`] `=>` [`Expr`]
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
pub struct MatchArm(pub Pattern, pub Expr);
|
pub struct MatchArm(pub Pattern, pub Expr);
|
||||||
|
|
||||||
|
|
||||||
/// An [Assign]ment expression: [`Expr`] ([`ModifyKind`] [`Expr`])\+
|
/// An [Assign]ment expression: [`Expr`] ([`ModifyKind`] [`Expr`])\+
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
pub struct Assign {
|
pub struct Assign {
|
||||||
@ -518,6 +520,7 @@ pub enum UnaryKind {
|
|||||||
Tilde,
|
Tilde,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A cast expression: [`Expr`] `as` [`Ty`]
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
pub struct Cast {
|
pub struct Cast {
|
||||||
pub head: Box<ExprKind>,
|
pub head: Box<ExprKind>,
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
//! - [Assign], [Binary], and [Unary] expressions
|
//! - [Assign], [Binary], and [Unary] expressions
|
||||||
//! - [ModifyKind], [BinaryKind], and [UnaryKind] operators
|
//! - [ModifyKind], [BinaryKind], and [UnaryKind] operators
|
||||||
//! - [Ty] and [TyKind]: Type qualifiers
|
//! - [Ty] and [TyKind]: Type qualifiers
|
||||||
|
//! - [Pattern]: Pattern matching operators
|
||||||
//! - [Path]: Path expressions
|
//! - [Path]: Path expressions
|
||||||
#![warn(clippy::all)]
|
#![warn(clippy::all)]
|
||||||
#![feature(decl_macro)]
|
#![feature(decl_macro)]
|
||||||
|
@ -44,7 +44,8 @@ builtins! {
|
|||||||
Ok(ConValue::Empty)
|
Ok(ConValue::Empty)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Prints the [Debug](std::fmt::Debug) version of the input values
|
/// Prints the [Debug](std::fmt::Debug) version of the input values,
|
||||||
|
/// and passes them back as a tuple.
|
||||||
pub fn dbg<_, args> () -> IResult<ConValue> {
|
pub fn dbg<_, args> () -> IResult<ConValue> {
|
||||||
let mut out = stdout().lock();
|
let mut out = stdout().lock();
|
||||||
for arg in args {
|
for arg in args {
|
||||||
@ -53,6 +54,7 @@ builtins! {
|
|||||||
Ok(args.into())
|
Ok(args.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Prints the pretty [Debug](std::fmt::Debug) version of the input values.
|
||||||
pub fn dbgp<_, args> () -> IResult<ConValue> {
|
pub fn dbgp<_, args> () -> IResult<ConValue> {
|
||||||
let mut out = stdout().lock();
|
let mut out = stdout().lock();
|
||||||
for arg in args {
|
for arg in args {
|
||||||
@ -279,6 +281,7 @@ builtins! {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Does the opposite of `&`
|
||||||
pub fn deref(tail) -> IResult<ConValue> {
|
pub fn deref(tail) -> IResult<ConValue> {
|
||||||
Ok(match tail {
|
Ok(match tail {
|
||||||
ConValue::Ref(v) => Rc::as_ref(v).clone(),
|
ConValue::Ref(v) => Rc::as_ref(v).clone(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user