Doccomment pattern matching AST nodes
This commit is contained in:
parent
4d2b6b98b5
commit
c7e79fedc5
|
@ -2,6 +2,7 @@ use super::Expression;
|
||||||
use crate::{Span, VarId};
|
use crate::{Span, VarId};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
/// AST Node for match arm with optional match guard
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct MatchPattern {
|
pub struct MatchPattern {
|
||||||
pub pattern: Pattern,
|
pub pattern: Pattern,
|
||||||
|
@ -15,16 +16,26 @@ impl MatchPattern {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// AST Node for pattern matching rules
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
pub enum Pattern {
|
pub enum Pattern {
|
||||||
|
/// Destructuring of records
|
||||||
Record(Vec<(String, MatchPattern)>),
|
Record(Vec<(String, MatchPattern)>),
|
||||||
|
/// List destructuring
|
||||||
List(Vec<MatchPattern>),
|
List(Vec<MatchPattern>),
|
||||||
|
/// Matching against a literal
|
||||||
Value(Expression),
|
Value(Expression),
|
||||||
|
/// binding to a variable
|
||||||
Variable(VarId),
|
Variable(VarId),
|
||||||
|
/// the `pattern1 \ pattern2` or-pattern
|
||||||
Or(Vec<MatchPattern>),
|
Or(Vec<MatchPattern>),
|
||||||
Rest(VarId), // the ..$foo pattern
|
/// the `..$foo` pattern
|
||||||
IgnoreRest, // the .. pattern
|
Rest(VarId),
|
||||||
IgnoreValue, // the _ pattern
|
/// the `..` pattern
|
||||||
|
IgnoreRest,
|
||||||
|
/// the `_` pattern
|
||||||
|
IgnoreValue,
|
||||||
|
/// Failed parsing of a pattern
|
||||||
Garbage,
|
Garbage,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user