Kill more Meta's
This commit is contained in:
parent
8d1e0ebdea
commit
f5d1c89574
@ -282,9 +282,9 @@ pub enum Pattern {
|
||||
Ignored,
|
||||
TuplePattern(Vec<Pattern>),
|
||||
Literal(PatternLiteral),
|
||||
TupleStruct(Meta<QualifiedName>, Vec<Pattern>),
|
||||
Record(Meta<QualifiedName>, Vec<(Rc<String>, Pattern)>),
|
||||
VarOrName(Meta<QualifiedName>),
|
||||
TupleStruct(QualifiedName, Vec<Pattern>),
|
||||
Record(QualifiedName, Vec<(Rc<String>, Pattern)>),
|
||||
VarOrName(QualifiedName),
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
|
@ -941,14 +941,14 @@ impl Parser {
|
||||
match self.token_handler.peek_kind() {
|
||||
LCurlyBrace => {
|
||||
let members = delimited!(self, LCurlyBrace, record_pattern_entry, Comma, RCurlyBrace);
|
||||
Pattern::Record(Meta::new(qualified_name), members)
|
||||
Pattern::Record(qualified_name, members)
|
||||
},
|
||||
LParen => {
|
||||
let members = delimited!(self, LParen, pattern, Comma, RParen);
|
||||
Pattern::TupleStruct(Meta::new(qualified_name), members)
|
||||
Pattern::TupleStruct(qualified_name, members)
|
||||
},
|
||||
_ => {
|
||||
Pattern::VarOrName(Meta::new(qualified_name))
|
||||
Pattern::VarOrName(qualified_name)
|
||||
},
|
||||
}
|
||||
},
|
||||
|
@ -620,8 +620,8 @@ fn patterns() {
|
||||
"if x is Some(a) then { 4 } else { 9 }", exst!(
|
||||
IfExpression {
|
||||
discriminator: bx!(Discriminator::Simple(Meta::new(ex!(s "x")))),
|
||||
body: bx!(IfExpressionBody::SimplePatternMatch(Pattern::TupleStruct(Meta::new(qname!(Some)),
|
||||
vec![Pattern::VarOrName(Meta::new(qname!(a)))]), vec![exst!(s "4")], Some(vec![exst!(s "9")]))) }
|
||||
body: bx!(IfExpressionBody::SimplePatternMatch(Pattern::TupleStruct(qname!(Some),
|
||||
vec![Pattern::VarOrName(qname!(a))]), vec![exst!(s "4")], Some(vec![exst!(s "9")]))) }
|
||||
)
|
||||
}
|
||||
|
||||
@ -629,8 +629,8 @@ fn patterns() {
|
||||
"if x is Some(a) then 4 else 9", exst!(
|
||||
IfExpression {
|
||||
discriminator: bx!(Discriminator::Simple(Meta::new(ex!(s "x")))),
|
||||
body: bx!(IfExpressionBody::SimplePatternMatch(Pattern::TupleStruct(Meta::new(qname!(Some)),
|
||||
vec![Pattern::VarOrName(Meta::new(qname!(a)))]), vec![exst!(s "4")], Some(vec![exst!(s "9")]))) }
|
||||
body: bx!(IfExpressionBody::SimplePatternMatch(Pattern::TupleStruct(qname!(Some),
|
||||
vec![Pattern::VarOrName(qname!(a))]), vec![exst!(s "4")], Some(vec![exst!(s "9")]))) }
|
||||
)
|
||||
}
|
||||
|
||||
@ -639,9 +639,9 @@ fn patterns() {
|
||||
IfExpression {
|
||||
discriminator: bx!(Discriminator::Simple(Meta::new(ex!(s "x")))),
|
||||
body: bx!(IfExpressionBody::SimplePatternMatch(
|
||||
Pattern::Record(Meta::new(qname!(Something)), vec![
|
||||
Pattern::Record(qname!(Something), vec![
|
||||
(rc!(a),Pattern::Literal(PatternLiteral::StringPattern(rc!(a)))),
|
||||
(rc!(b),Pattern::VarOrName(Meta::new(qname!(x))))
|
||||
(rc!(b),Pattern::VarOrName(qname!(x)))
|
||||
]),
|
||||
vec![exst!(s "4")], Some(vec![exst!(s "9")])))
|
||||
}
|
||||
|
@ -357,8 +357,7 @@ fn handle_symbol(symbol: Option<&Symbol>, inner_patterns: &Vec<Pattern>, symbol_
|
||||
_ => panic!("Symbol is not a data constructor - this should've been caught in type-checking"),
|
||||
});
|
||||
let bound_vars = inner_patterns.iter().map(|p| match p {
|
||||
VarOrName(meta_name) => {
|
||||
let qualified_name = meta_name.node();
|
||||
VarOrName(qualified_name) => {
|
||||
let fqsn = symbol_table.get_fqsn_from_id(&qualified_name.id);
|
||||
let symbol_exists = fqsn.and_then(|fqsn| symbol_table.lookup_by_fqsn(&fqsn)).is_some();
|
||||
if symbol_exists {
|
||||
@ -419,7 +418,7 @@ impl Pattern {
|
||||
fn to_subpattern(&self, symbol_table: &SymbolTable) -> Subpattern {
|
||||
use self::Pattern::*;
|
||||
match self {
|
||||
TupleStruct( Meta { n: QualifiedName{ components, id }, .. }, inner_patterns) => {
|
||||
TupleStruct(QualifiedName{ components, id }, inner_patterns) => {
|
||||
let fqsn = symbol_table.get_fqsn_from_id(&id);
|
||||
match fqsn.and_then(|fqsn| symbol_table.lookup_by_fqsn(&fqsn)) {
|
||||
Some(symbol) => handle_symbol(Some(symbol), inner_patterns, symbol_table),
|
||||
@ -434,7 +433,7 @@ impl Pattern {
|
||||
},
|
||||
Ignored => Subpattern { tag: None, subpatterns: vec![], guard: None, bound_vars: vec![] },
|
||||
Literal(lit) => lit.to_subpattern(symbol_table),
|
||||
VarOrName(Meta { n: QualifiedName { components, id }, .. }) => {
|
||||
VarOrName(QualifiedName { components, id }) => {
|
||||
// if fqsn is Some, treat this as a symbol pattern. If it's None, treat it
|
||||
// as a variable.
|
||||
println!("Calling VarOrName reduction with : {:?}", components);
|
||||
|
@ -145,10 +145,9 @@ impl<'a> ScopeResolver<'a> {
|
||||
}
|
||||
|
||||
/// this might be a variable or a pattern. if a variable, set to none
|
||||
fn qualified_name_in_pattern(&mut self, meta_qualified_name: &mut Meta<QualifiedName>, ) {
|
||||
let inner_name = meta_qualified_name.node();
|
||||
let ref id = inner_name.id;
|
||||
let fqsn = lookup_name_in_scope(inner_name);
|
||||
fn qualified_name_in_pattern(&mut self, qualified_name: &mut QualifiedName) {
|
||||
let ref id = qualified_name.id;
|
||||
let fqsn = lookup_name_in_scope(qualified_name);
|
||||
if self.symbol_table.lookup_by_fqsn(&fqsn).is_some() {
|
||||
self.symbol_table.map_id_to_fqsn(&id, fqsn);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user