Diff
Not logged in

Differences From Artifact [de23904b83613a4d]:

To Artifact [06d6eadbdf402360]:


313 { 313 { 314 auto cond = E(0); 314 auto cond = E(0); 315 auto thenPos = currentPosition(); 315 auto thenPos = currentPosition(); 316 if(!tryEat(":")) { 316 if(!tryEat(":")) { 317 eat("then", "after if condition"); 317 eat("then", "after if condition"); 318 tryEat(":"); 318 tryEat(":"); 319 } 319 } 320 AST th = E(0); | 320 AST th = Body(); 321 auto el = doNothingExpression(); 321 auto el = doNothingExpression(); 322 auto elsePos = currentPosition(); 322 auto elsePos = currentPosition(); 323 if( tryEat("else") ) { 323 if( tryEat("else") ) { 324 tryEat(":"); 324 tryEat(":"); 325 el = E(0); | 325 el = Body(); 326 } 326 } 327 return new App(pos, new Var(pos,"if"), cond, new Fun(thenPos,[], 327 return new App(pos, new Var(pos,"if"), cond, new Fun(thenPos,[], 328 } 328 } 329 329 330 AST parsePatternMatch(LexPosition pos) 330 AST parsePatternMatch(LexPosition pos) 331 { 331 { 332 // case pmExpr CASES 332 // case pmExpr CASES ................................................................................................................................................................................ 349 if( tryEat("when") ) 349 if( tryEat("when") ) 350 { 350 { 351 auto pos = currentPosition(); 351 auto pos = currentPosition(); 352 string failBranchVar = freshVarName(); 352 string failBranchVar = freshVarName(); 353 353 354 auto pr = parsePattern(); 354 auto pr = parsePattern(); 355 eat(":", "after when pattern"); 355 eat(":", "after when pattern"); 356 AST cBody = E(0); | 356 AST cBody = Body(); 357 AST judgement = new App(pos, new Var(pos, "if"), 357 AST judgement = new App(pos, new Var(pos, "if"), 358 ppTest(pmVar, pr), new Fun(pos,[],ppBind(pmVar, 358 ppTest(pmVar, pr), new Fun(pos,[],ppBind(pmVar, 359 new Var(pos, failBranchVar)); 359 new Var(pos, failBranchVar)); 360 return parsePatternMatchCases(casePos, pmVar, failBranch 360 return parsePatternMatchCases(casePos, pmVar, failBranch 361 new Let(pos, tryThisBranchVar, [], 361 new Let(pos, tryThisBranchVar, [], 362 new Fun(pos,[],judgement), thenDoThis) 362 new Fun(pos,[],judgement), thenDoThis) 363 ); 363 );