Browse Source

fix more bugs

pull/15/head
nisstyre56 11 years ago
parent
commit
6b33a7e318
  1. 10
      desugar.js
  2. 2
      example.jl
  3. 2
      parse.js
  4. 10
      representation.js

10
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":

2
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))

2
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;
}
}

10
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) {

Loading…
Cancel
Save