diff --git a/schala-lang/language/src/ast.rs b/schala-lang/language/src/ast.rs index b591568..d54e961 100644 --- a/schala-lang/language/src/ast.rs +++ b/schala-lang/language/src/ast.rs @@ -9,7 +9,7 @@ pub use operators::*; #[derive(Clone, Debug, PartialEq)] pub struct Meta { - n: T, + pub n: T, source_map: SourceMap, type_data: TypeData, pub fqsn: Option diff --git a/schala-lang/language/src/parsing.rs b/schala-lang/language/src/parsing.rs index 2a30e18..cfd3d98 100644 --- a/schala-lang/language/src/parsing.rs +++ b/schala-lang/language/src/parsing.rs @@ -937,14 +937,14 @@ impl Parser { match self.token_handler.peek_kind() { LCurlyBrace => { let members = delimited!(self, LCurlyBrace, record_pattern_entry, Comma, RCurlyBrace); - Pattern::Record(qualified_name, members) + Pattern::Record(Meta::new(qualified_name), members) }, LParen => { let members = delimited!(self, LParen, pattern, Comma, RParen); - Pattern::TupleStruct(qualified_name, members) + Pattern::TupleStruct(Meta::new(qualified_name), members) }, _ => { - Pattern::VarOrName(qualified_name) + Pattern::VarOrName(Meta::new(qualified_name)) }, } }, diff --git a/schala-lang/language/src/parsing/test.rs b/schala-lang/language/src/parsing/test.rs index 12203fe..7da48a7 100644 --- a/schala-lang/language/src/parsing/test.rs +++ b/schala-lang/language/src/parsing/test.rs @@ -596,8 +596,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(QualifiedName(vec![rc!(Some)]), - vec![Pattern::VarOrName(QualifiedName(vec![rc!(a)]))]), vec![exst!(s "4")], Some(vec![exst!(s "9")]))) } + body: bx!(IfExpressionBody::SimplePatternMatch(Pattern::TupleStruct(Meta::new(QualifiedName(vec![rc!(Some)])), + vec![Pattern::VarOrName(Meta::new(QualifiedName(vec![rc!(a)])))]), vec![exst!(s "4")], Some(vec![exst!(s "9")]))) } ) } @@ -605,8 +605,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(QualifiedName(vec![rc!(Some)]), - vec![Pattern::VarOrName(QualifiedName(vec![rc!(a)]))]), vec![exst!(s "4")], Some(vec![exst!(s "9")]))) } + body: bx!(IfExpressionBody::SimplePatternMatch(Pattern::TupleStruct(Meta::new(QualifiedName(vec![rc!(Some)])), + vec![Pattern::VarOrName(Meta::new(QualifiedName(vec![rc!(a)])))]), vec![exst!(s "4")], Some(vec![exst!(s "9")]))) } ) } @@ -615,9 +615,9 @@ fn patterns() { IfExpression { discriminator: bx!(Discriminator::Simple(Meta::new(ex!(s "x")))), body: bx!(IfExpressionBody::SimplePatternMatch( - Pattern::Record(QualifiedName(vec![rc!(Something)]), vec![ + Pattern::Record(Meta::new(QualifiedName(vec![rc!(Something)])), vec![ (rc!(a),Pattern::Literal(PatternLiteral::StringPattern(rc!(a)))), - (rc!(b),Pattern::VarOrName(QualifiedName(vec![rc!(x)]))) + (rc!(b),Pattern::VarOrName(Meta::new(QualifiedName(vec![rc!(x)])))) ]), vec![exst!(s "4")], Some(vec![exst!(s "9")]))) } diff --git a/schala-lang/language/src/reduced_ast.rs b/schala-lang/language/src/reduced_ast.rs index 39658e6..0e66dc8 100644 --- a/schala-lang/language/src/reduced_ast.rs +++ b/schala-lang/language/src/reduced_ast.rs @@ -249,7 +249,7 @@ fn reduce_if_expression(discriminator: &Discriminator, body: &IfExpressionBody, }; let alternatives = vec![ - pat.node().to_alternative(then_clause, symbol_table), + pat.to_alternative(then_clause, symbol_table), Alternative { matchable: Subpattern { tag: None, @@ -272,7 +272,7 @@ fn reduce_if_expression(discriminator: &Discriminator, body: &IfExpressionBody, match arm.guard { Guard::Pat(ref p) => { let item = reduce_block(&arm.body, symbol_table); - let alt = p.node().to_alternative(item, symbol_table); + let alt = p.to_alternative(item, symbol_table); alternatives.push(alt); }, Guard::HalfExpr(HalfExpr { op: _, expr: _ }) => { @@ -346,7 +346,7 @@ impl Pattern { fn to_subpattern(&self, symbol_table: &SymbolTable) -> Subpattern { use self::Pattern::*; match self { - TupleStruct(QualifiedName(vec), inner_patterns) => { + TupleStruct( Meta { n: QualifiedName(vec), .. }, inner_patterns) => { let name = if vec.len() == 1 { vec[0].clone() } else { @@ -361,7 +361,7 @@ impl Pattern { }, Ignored => Subpattern { tag: None, subpatterns: vec![], guard: None, bound_vars: vec![] }, Literal(lit) => lit.to_subpattern(symbol_table), - VarOrName(QualifiedName(vec)) => { + VarOrName(Meta { n: QualifiedName(vec), .. }) => { //TODO this name needs to be resolved from metadata with context let name = if vec.len() == 1 { vec[0].clone()