Browse Source

fix bug where defops were not being included by the tokenizer properly, fixed precedence order mixup in prelude.jl

pull/22/head
nisstyre56 10 years ago
parent
commit
c34fd71244
  1. 3
      free_vars.js
  2. 2
      parse.js
  3. 34
      prelude.jl
  4. 7
      tokenize.js

3
free_vars.js

@ -150,10 +150,9 @@ function annotate_fvs_all(stx) {
function test(src) {
var ast = parser.parse(src);
console.log(JSON.stringify(ast.map(annotate_fvs_all), null, 4));
}
console.log(test("if something then if a then if b then c else d else rtrrt else some_other_thing"));
//console.log(test("if something then if a then if b then c else d else rtrrt else some_other_thing"));
module.export = {
test : test,
annotate_fvs: annotate_fvs_all

2
parse.js

@ -811,9 +811,7 @@ function parseFull(tokenized) {
try {
while (tokenized.length > 0) {
ast.push(desugarer.desugar(parse(tokenized), typeBindings));
console.log(ast);
}
console.log(ast);
return [ast, typeBindings];
} catch (e) {
if (e.stxerror !== undefined) {

34
prelude.jl

@ -63,56 +63,56 @@ deftype (Either a b)
;; Operator definitions
defop 3 Left (a + b)
defop 1 Left (a + b)
(add a b)
defop 3 Left (a - b)
defop 1 Left (a - b)
(minus a b)
defop 4 Left (a * b)
defop 2 Left (a * b)
(mul a b)
defop 4 Left (a / b)
defop 2 Left (a / b)
(div a b)
defop 5 Right (a ^ b)
defop 2 Right (a ^ b)
(pow a b)
defop 3 Left (a ++ b)
(listConcat a b)
defop 2 Left (a == b)
defop 3 Left (a == b)
(eq a b)
defop 2 Left (a > b)
defop 3 Left (a > b)
(gt a b)
defop 2 Left (a >= b)
defop 3 Left (a >= b)
(gte a b)
defop 2 Left (a < b)
defop 3 Left (a < b)
(lt a b)
defop 2 Left (a <= b)
defop 3 Left (a <= b)
(lte a b)
defop 2 Left (a && b)
defop 3 Left (a && b)
(and a b)
defop 2 Left (a || b)
defop 3 Left (a || b)
(or a b)
defop 1 Left (x : xs)
defop 4 Left (x : xs)
(cons x xs)
defop 1 Left (f $ x)
defop 5 Left (f $ x)
(fapply f x)
defop 1 Left (f . g)
defop 5 Left (f . g)
(compose f g)
defop 1 Left (a | b)
defop 3 Left (a | b)
(bitwiseOr a b)
defop 1 Left (a & b)
defop 3 Left (a & b)
(bitwiseAnd a b)

7
tokenize.js

@ -14,7 +14,10 @@ function isDigit(c) {
if (isNaN(code)) {
return false;
}
return (47 < code && code < 58);
if ((47 < code) && (code < 58)) {
return true;
}
return false;
}
function isWhitespace(c) {
@ -411,9 +414,9 @@ function checkPattern(x, i) {
function tokenizeFull(input) {
var preludeSrc = fs.readFileSync("./prelude.jl");
var matchop;
input = [preludeSrc, input].join("");
var initialPass = tokenizeHelp(input, _.constant(false), true).reverse();
input = [preludeSrc, input].join("");
for (var i = 0; i < initialPass.length; i++) {
if (initialPass.slice(i, i+8).
map(_.first).

Loading…
Cancel
Save