From 8218007f1c49c230fcedc7f822abe2012845b1ee Mon Sep 17 00:00:00 2001 From: greg Date: Fri, 8 Nov 2019 18:53:38 -0800 Subject: [PATCH] Commit this temporary fix --- TODO.md | 3 +++ schala-lang/language/src/reduced_ast.rs | 21 +++++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/TODO.md b/TODO.md index b735e33..a1b04e8 100644 --- a/TODO.md +++ b/TODO.md @@ -19,6 +19,9 @@ DONE -experiment with storing metadata via ItemIds on AST nodes (cf. https://rus -look at https://gitlab.haskell.org/ghc/ghc/wikis/pattern-synonyms 2) the non-value-returning, default one like in rustc (cf. https://github.com/rust-unofficial/patterns/blob/master/patterns/visitor.md) +-parser error - should report subset of AST parsed *so far* + - what if you used python 'def' syntax to define a function? what error message makes sense here? + ## Reduction - make a good type for actual language builtins to avoid string comparisons diff --git a/schala-lang/language/src/reduced_ast.rs b/schala-lang/language/src/reduced_ast.rs index f90347c..9b6f5c4 100644 --- a/schala-lang/language/src/reduced_ast.rs +++ b/schala-lang/language/src/reduced_ast.rs @@ -188,12 +188,21 @@ impl<'a> Reducer<'a> { //TODO this probably needs to change let FullyQualifiedSymbolName(ref v) = sym_name; let name = v.last().unwrap().name.clone(); - match symbol_table.lookup_by_fqsn(&sym_name) { - Some(Symbol { spec: SymbolSpec::DataConstructor { index, type_args, type_name}, .. }) => Expr::Constructor { - type_name: type_name.clone(), - name: name.clone(), - tag: index.clone(), - arity: type_args.len(), + + let Symbol { local_name, spec, .. } = match symbol_table.lookup_by_fqsn(&sym_name) { + Some(s) => s, + //None => return Expr::ReductionError(format!("Symbol {:?} not found", sym_name)), + None => return Expr::Sym(name.clone()) + }; + + match spec { + SymbolSpec::DataConstructor { index, type_args, type_name} => { + Expr::Constructor { + type_name: type_name.clone(), + name: name.clone(), + tag: index.clone(), + arity: type_args.len(), + } }, _ => Expr::Sym(name.clone()), }