Temp qualified names work
This commit is contained in:
parent
79635f2f86
commit
ea542192be
@ -153,7 +153,7 @@ pub enum ExpressionKind {
|
||||
TupleLiteral(Vec<Meta<Expression>>),
|
||||
Value(Meta<QualifiedName>),
|
||||
NamedStruct {
|
||||
name: QualifiedName,
|
||||
name: Meta<QualifiedName>,
|
||||
fields: Vec<(Rc<String>, Meta<Expression>)>,
|
||||
},
|
||||
Call {
|
||||
@ -230,9 +230,9 @@ pub enum Pattern {
|
||||
Ignored,
|
||||
TuplePattern(Vec<Pattern>),
|
||||
Literal(PatternLiteral),
|
||||
TupleStruct(QualifiedName, Vec<Pattern>),
|
||||
Record(QualifiedName, Vec<(Rc<String>, Pattern)>),
|
||||
VarOrName(QualifiedName),
|
||||
TupleStruct(Meta<QualifiedName>, Vec<Pattern>),
|
||||
Record(Meta<QualifiedName>, Vec<(Rc<String>, Pattern)>),
|
||||
VarOrName(Meta<QualifiedName>),
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
|
@ -763,7 +763,7 @@ impl Parser {
|
||||
Ok(match self.token_handler.peek_kind() {
|
||||
LCurlyBrace if !self.restrictions.no_struct_literal => {
|
||||
let fields = self.record_block()?;
|
||||
Expression::new(NamedStruct { name: qualified_identifier, fields })
|
||||
Expression::new(NamedStruct { name: Meta::new(qualified_identifier), fields })
|
||||
},
|
||||
_ => Expression::new(Value(Meta::new(qualified_identifier)))
|
||||
})
|
||||
|
@ -153,11 +153,11 @@ fn parsing_identifiers() {
|
||||
|
||||
parse_test!("None", AST(vec![exst!(val!("None"))]));
|
||||
parse_test!("Pandas { a: x + y }", AST(vec![
|
||||
exst!(NamedStruct { name: QualifiedName(vec![rc!(Pandas)]), fields: vec![(rc!(a), ex!(m binexp!("+", val!("x"), val!("y"))))]})
|
||||
exst!(NamedStruct { name: Meta::new(QualifiedName(vec![rc!(Pandas)])), fields: vec![(rc!(a), ex!(m binexp!("+", val!("x"), val!("y"))))]})
|
||||
]));
|
||||
parse_test! { "Pandas { a: n, b: q, }",
|
||||
AST(vec![
|
||||
exst!(NamedStruct { name: QualifiedName(vec![rc!(Pandas)]), fields:
|
||||
exst!(NamedStruct { name: Meta::new(QualifiedName(vec![rc!(Pandas)])), fields:
|
||||
vec![(rc!(a), ex!(m val!("n"))), (rc!(b), ex!(m val!("q")))]
|
||||
}
|
||||
)
|
||||
|
@ -176,7 +176,7 @@ impl Meta<Expression> {
|
||||
TupleLiteral(exprs) => Expr::Tuple(exprs.iter().map(|e| e.reduce(symbol_table)).collect()),
|
||||
IfExpression { discriminator, body } => reduce_if_expression(discriminator, body, symbol_table),
|
||||
Lambda { params, body, .. } => reduce_lambda(params, body, symbol_table),
|
||||
NamedStruct { name, fields } => reduce_named_struct(self.fqsn.as_ref(), name, fields, symbol_table),
|
||||
NamedStruct { name, fields } => reduce_named_struct(self.fqsn.as_ref(), name.node(), fields, symbol_table),
|
||||
Index { .. } => Expr::UnimplementedSigilValue,
|
||||
WhileExpression { .. } => Expr::UnimplementedSigilValue,
|
||||
ForExpression { .. } => Expr::UnimplementedSigilValue,
|
||||
@ -249,7 +249,7 @@ fn reduce_if_expression(discriminator: &Discriminator, body: &IfExpressionBody,
|
||||
};
|
||||
|
||||
let alternatives = vec![
|
||||
pat.to_alternative(then_clause, symbol_table),
|
||||
pat.node().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.to_alternative(item, symbol_table);
|
||||
let alt = p.node().to_alternative(item, symbol_table);
|
||||
alternatives.push(alt);
|
||||
},
|
||||
Guard::HalfExpr(HalfExpr { op: _, expr: _ }) => {
|
||||
|
@ -35,7 +35,7 @@ impl ScopeResolver {
|
||||
expr.fqsn = Some(fqsn);
|
||||
},
|
||||
NamedStruct { name, .. } => {
|
||||
let fqsn = lookup_name_in_scope(&name);
|
||||
let fqsn = lookup_name_in_scope(&name.node());
|
||||
expr.fqsn = Some(fqsn);
|
||||
},
|
||||
BinExp(_, ref mut lhs, ref mut rhs) => {
|
||||
|
Loading…
Reference in New Issue
Block a user