From 6b33a7e318acb7aaf426bf17d20042e23ae3febf Mon Sep 17 00:00:00 2001 From: nisstyre56 Date: Sun, 18 May 2014 03:51:26 -0400 Subject: [PATCH] fix more bugs --- desugar.js | 10 ++++++++++ example.jl | 2 ++ parse.js | 2 +- representation.js | 10 ++++++++-- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/desugar.js b/desugar.js index 6489e6b..eb5f998 100644 --- a/desugar.js +++ b/desugar.js @@ -57,6 +57,14 @@ function sugarTypeApp(stx) { return new typ.TypeApp(expression, type); } +function desugarDefType(stx) { + var result; + result = new typ.DefType(desugar(stx.lhs), desugar(stx.rhs)); + result.linenum = stx.linenum; + result.charnum = stx.charnum; + return result; +} + function desugar(stx) { var typeExpTest; @@ -71,6 +79,8 @@ function desugar(stx) { return desugarDefFunc(stx); case "Definition": return new typ.Def(stx.ident, desugar(stx.val)); + case "TypeDefinition": + return desugarDefType(stx); case "Name": return stx; case "Application": diff --git a/example.jl b/example.jl index 89edaad..bc9ccae 100644 --- a/example.jl +++ b/example.jl @@ -1,6 +1,8 @@ defop 2 Left (a ++ b) (a - b) +deftype Foo (A -> B) + (qat :: A -> b) def tdeftype (lambda a b c -> (a + b)) diff --git a/parse.js b/parse.js index 5e53364..84c1959 100755 --- a/parse.js +++ b/parse.js @@ -400,7 +400,7 @@ function parseDefType(tokens, linenum, charnum) { rhs.charnum, "was expecting an application or type operator on the right-hand side of a type definition"); } - result = new typ.DefType(lhs, rhs); + result = addSrcPos(new typ.DefType(lhs, rhs), tokens, linenum, charnum); return result; } } diff --git a/representation.js b/representation.js index e0734f9..95ca437 100644 --- a/representation.js +++ b/representation.js @@ -291,11 +291,11 @@ function TypeApp(expression, type) { TypeApp.prototype = TypeExpression; -function DefType(rhs, lhs) { +function DefType(lhs, rhs) { /* Both rhs and lhs are expected * to be fully desugared already */ - if (!isTypeExpr(rhs) || + if (!isTypeExprRec(rhs) || !isTypeExpr(lhs)) { throw errors.JSyntaxError( rhs.linenum, @@ -310,6 +310,12 @@ function DefType(rhs, lhs) { DefType.prototype = Expression; +function DataType(params, type) { + /* Params is a list of type variables + * type is a type expression + */ +} + //Applies the function ``name'' to the list of parameters function makeApp(name, parameters) {