Browse Source

stuff

pull/21/head
wes 12 years ago
parent
commit
b4d0872774
  1. 9
      parse.js

9
parse.js

@ -136,7 +136,7 @@ function parse(tokens) {
if (fst(tokens)) if (fst(tokens))
var toktype = fst(tokens)[0]; var toktype = fst(tokens)[0];
else { else {
console.log("Unexpected end of source") //console.log("Unexpected end of source")
process.exit(code=1); process.exit(code=1);
} }
var token = fst(tokens)[1]; var token = fst(tokens)[1];
@ -271,7 +271,7 @@ function pprintApp(app) {
} }
function pprintDef(def) { function pprintDef(def) {
return "let " + pprint(def.ident) + " = " + pprint(def.val); return pprint(def.ident) + " = " + pprint(def.val);
} }
function pprintIf(ifexp) { function pprintIf(ifexp) {
@ -310,4 +310,9 @@ function pprint(expr) {
var input = fs.readFileSync('/dev/stdin').toString(); var input = fs.readFileSync('/dev/stdin').toString();
var tokenized = tokenizer.tokenize(input).reverse().filter(function(x) { return x[0] !== "whitespace";}); var tokenized = tokenizer.tokenize(input).reverse().filter(function(x) { return x[0] !== "whitespace";});
//console.log(tokenized); //console.log(tokenized);
while (tokenized !== []) {
console.log(pprint(parse(tokenized))); console.log(pprint(parse(tokenized)));
if (!tokenized)
break;
}

Loading…
Cancel
Save