Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added inline type declarations exp :: Type

  • Loading branch information...
commit e42858d25fa0f9f3ba7479fb4eef0a44b8de09c1 1 parent 36276e7
@phyrex1an phyrex1an authored
Showing with 24 additions and 9 deletions.
  1. +1 −1  haskell.ast.js
  2. +23 −8 haskell.parser.js
View
2  haskell.ast.js
@@ -239,7 +239,7 @@
this.expr = expr;
this.type = type;
this.eval = function(env) {
- return this.expr;
+ return this.expr.eval(env);
};
this.stringify = function() {
View
31 haskell.parser.js
@@ -645,8 +645,26 @@
};
return translate(ast.exp);
+ };
+
+ // redefined later
+ var atype = function(state) { return atype(state); };
+ var type = function(state) { return type(state); };
+ var context = function(state) { return context(state); };
+
+ var exp_type_action = function(p) {
+ return action(p, function(ast) {
+ var expr = ast[0];
+ var contexts = ast[1] ? ast[1][0] : [];
+ var type = ast[2];
+ var tc = new haskell.ast.TypeConstraint(contexts, type);
+ if (expr.info != undefined && expr.info.need_resolve) {
+ expr = resolve_op(ast);
+ }
+ return new haskell.ast.ExpressionTypeConstraint(expr, tc);
+ });
};
-
+
var exp_infix_action = function(p) {
return action(p, function(ast) {
if (ast.info != undefined && ast.info.need_resolve) {
@@ -656,8 +674,8 @@
}
});
};
-
- var exp = choice(sequence(ws(infixexp), ws("::"), optional(ws(context), ws("=>")), ws(type)),
+
+ var exp = choice( exp_type_action(sequence(ws(infixexp), expectws("::"), optional(ws(context), expectws("=>")), ws(type))),
exp_infix_action(ws(infixexp)));
var gd_action = function(p) {
@@ -771,10 +789,6 @@
return ast;
});
};
-
- // redefined later
- var atype = function(state) { return atype(state); };
- var type = function(state) { return type(state); };
var newconstr = choice( newconstr_con_action(sequence(con, atype)),
newconstr_var_action(sequence(con, expectws('{'), var_, expectws("::"), type, expectws('}')))
@@ -970,7 +984,8 @@
return ast[0];
});
};
-
+
+ // redefinition
context = choice( context_single_action(ws(class_)),
context_multi_action(sequence(expectws('('), list(ws(class_), ws(',')) , expectws(')')))
);
Please sign in to comment.
Something went wrong with that request. Please try again.