|
@ -1,5 +1,4 @@ |
|
|
#! /usr/bin/node
|
|
|
#! /usr/bin/node
|
|
|
|
|
|
|
|
|
var fs = require("fs"); |
|
|
var fs = require("fs"); |
|
|
var typ = require("./representation.js"); |
|
|
var typ = require("./representation.js"); |
|
|
var $ = require("./tools.js"); |
|
|
var $ = require("./tools.js"); |
|
@ -401,10 +400,11 @@ function parseIf(tokens) { |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
var ifC = parse(tokens); |
|
|
var ifC = parse(tokens); |
|
|
if (!fst(tokens) || fst(tokens)[0] !== "thenexp") |
|
|
if (!fst(tokens) || fst(tokens)[0] !== "thenexp") { |
|
|
throw error.JSyntaxError(fst(tokens)[3], |
|
|
throw error.JSyntaxError(fst(tokens)[3], |
|
|
fst(tokens)[2], |
|
|
fst(tokens)[2], |
|
|
"if ``exp'' must be folowed by ``then'' exp, not "+snd(tokens)[0]); |
|
|
"if ``exp'' must be folowed by ``then'' exp, not "+snd(tokens)[0]); |
|
|
|
|
|
} |
|
|
else { |
|
|
else { |
|
|
tokens.pop(); |
|
|
tokens.pop(); |
|
|
var thenC = parse(tokens); |
|
|
var thenC = parse(tokens); |
|
@ -416,12 +416,15 @@ function parseIf(tokens) { |
|
|
charnum, |
|
|
charnum, |
|
|
"Unexpected end of source"); |
|
|
"Unexpected end of source"); |
|
|
} |
|
|
} |
|
|
|
|
|
else { |
|
|
var elseC = parse(tokens); |
|
|
var elseC = parse(tokens); |
|
|
return new typ.If(ifC, thenC, elseC); |
|
|
return new typ.If(ifC, thenC, elseC); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
return new typ.If(ifC, thenC); |
|
|
throw error.JSyntaxError(linenum, |
|
|
|
|
|
charnum, |
|
|
|
|
|
"If expression must include an else variant"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|