Browse Source

-> should be in the list of operators

pull/8/head
nisstyre56 11 years ago
parent
commit
3f7b2af82f
  1. 3
      closure_conversion.js
  2. 5
      parse.js
  3. 8
      representation.js

3
closure_conversion.js

@ -151,8 +151,7 @@ function test(src) {
console.log(JSON.stringify(closure_convert_all(ast), null, 4)); console.log(JSON.stringify(closure_convert_all(ast), null, 4));
} }
//console.log(test(pprint.pprint(parser.parse(pprint.pprint(parser.parse("if something then if a then if b then c else d else rtrrt else some_other_thing")[0]))[0]))); //console.log(test("if something then if a then if b then c else d else rtrrt else some_other_thing"));
console.log(pprint.pprint(parser.parse("(34 :: A)")[0]));
module.export = { module.export = {
test : test, test : test,
closureConvert : closure_convert_all closureConvert : closure_convert_all

5
parse.js

@ -458,6 +458,7 @@ function parseLambda(tokens) {
tokens, tokens,
charnum, charnum,
linenum); linenum);
console.log(tokens);
if (fst(tokens)[1] !== "->") { if (fst(tokens)[1] !== "->") {
throw error.JSyntaxError(fst(tokens)[3], throw error.JSyntaxError(fst(tokens)[3],
fst(tokens)[2], fst(tokens)[2],
@ -639,5 +640,5 @@ module.exports = { parse : function(str) {
}, },
tokenize : tokenizer.tokenize tokenize : tokenizer.tokenize
}; };
//var istr = fs.readFileSync('/dev/stdin').toString(); var istr = fs.readFileSync('/dev/stdin').toString();
//console.log(parseFull(tokenizer.tokenize(istr)).map(pprint.pprint)); console.log(parseFull(tokenizer.tokenize(istr)).map(pprint.pprint));

8
representation.js

@ -196,6 +196,11 @@ function TypeApp(expression, type) {
"Left-hand-side of type application must not be in the type language" "Left-hand-side of type application must not be in the type language"
); );
} }
if (!type.prototype.isTypeExpr) {
throw errors.JInternalError(
"Right-hand-side of type application must be a type expression"
);
}
this.expr = expression; this.expr = expression;
this.type = type; this.type = type;
this.exprType = "TypeApplication"; this.exprType = "TypeApplication";
@ -247,7 +252,8 @@ OPInfo = {"+" : [3, "Left"],
">>=" : [1, "Left"], ">>=" : [1, "Left"],
"<$>" : [1, "Left"], "<$>" : [1, "Left"],
"." : [1, "Left"], "." : [1, "Left"],
"," : [1, "Left"]}; "," : [1, "Left"],
"->" : [1, "Right"]};
module.exports = module.exports =
{ {

Loading…
Cancel
Save