Diff
Not logged in

Differences From Artifact [5f90478aa23ae726]:

To Artifact [e14df84da140adf3]:


64 if( tryEat("let") || tryEat("var") || tryEat("def") || tryEat("@ 64 if( tryEat("let") || tryEat("var") || tryEat("def") || tryEat("@ 65 { 65 { 66 if( kwd == "@" ) 66 if( kwd == "@" ) 67 kwd ~= eatId("after @"); 67 kwd ~= eatId("after @"); 68 immutable LexPosition varpos = (lex.empty ? null : lex.f 68 immutable LexPosition varpos = (lex.empty ? null : lex.f 69 string var = eatId("after "~kwd); 69 string var = eatId("after "~kwd); 70 eat("=", "after "~kwd); 70 eat("=", "after "~kwd); 71 kwd = (kwd[0]=='@' ? kwd : "@val"); | 71 kwd = (kwd[0]=='@' ? kwd : ""); // "let, var, def ==> ne 72 auto e = E(0); 72 auto e = E(0); 73 if( tryEat(";") && !lex.empty && (lex.front.quoted || (l 73 if( tryEat(";") && !lex.empty && (lex.front.quoted || (l 74 return new LetExpression(pos, var, kwd, e, Body( 74 return new LetExpression(pos, var, kwd, e, Body( 75 else 75 else 76 return new LetExpression(pos, var, kwd, e, new V 76 return new LetExpression(pos, var, kwd, e, new V 77 } 77 } 78 else 78 else ................................................................................................................................................................................ 259 assert_eq(parseString(`"foo"`), strl("foo")); 259 assert_eq(parseString(`"foo"`), strl("foo")); 260 assert_eq(parseString(`fun(){1}`), fun([],intl(1))); 260 assert_eq(parseString(`fun(){1}`), fun([],intl(1))); 261 assert_eq(parseString(`fun(x){1}`), fun(["x"],intl(1))); 261 assert_eq(parseString(`fun(x){1}`), fun(["x"],intl(1))); 262 assert_eq(parseString("\u03BB(){1}"), fun([],intl(1))); 262 assert_eq(parseString("\u03BB(){1}"), fun([],intl(1))); 263 assert_eq(parseString("\u03BB(x){1}"), fun(["x"],intl(1))); 263 assert_eq(parseString("\u03BB(x){1}"), fun(["x"],intl(1))); 264 assert_eq(parseString(`1;2`), let("_","@val",intl(1),intl(2))); 264 assert_eq(parseString(`1;2`), let("_","@val",intl(1),intl(2))); 265 assert_eq(parseString(`1;2;`), let("_","@val",intl(1),intl(2))); 265 assert_eq(parseString(`1;2;`), let("_","@val",intl(1),intl(2))); 266 assert_eq(parseString(`let x=1;2`), let("x","@val",intl(1),intl(2))); | 266 assert_eq(parseString(`let x=1;2`), let("x","",intl(1),intl(2))); 267 assert_eq(parseString(`var x=1;2;`), let("x","@val",intl(1),intl(2))); | 267 assert_eq(parseString(`var x=1;2;`), let("x","",intl(1),intl(2))); 268 assert_eq(parseString(`def x=1`), let("x","@val",intl(1),var("x"))); | 268 assert_eq(parseString(`def x=1`), let("x","",intl(1),var("x"))); 269 assert_eq(parseString(`@val x=1;`), let("x","@val",intl(1),var("x"))); 269 assert_eq(parseString(`@val x=1;`), let("x","@val",intl(1),var("x"))); 270 assert_eq(parseString(`@typ x="#int";`), let("x","@typ",strl("#int"),var 270 assert_eq(parseString(`@typ x="#int";`), let("x","@typ",strl("#int"),var 271 assert_eq(parseString(`f(1,2)`), call(var("f"),intl(1),intl(2))); 271 assert_eq(parseString(`f(1,2)`), call(var("f"),intl(1),intl(2))); 272 assert_eq(parseString(`if(1){2}`), call(var("if"),intl(1),fun([],intl(2) 272 assert_eq(parseString(`if(1){2}`), call(var("if"),intl(1),fun([],intl(2) 273 assert_eq(parseString(`if(1){2}else{3}`), call(var("if"),intl(1),fun([], 273 assert_eq(parseString(`if(1){2}else{3}`), call(var("if"),intl(1),fun([], 274 assert_eq(parseString(`if(1){}else{3}()()`), 274 assert_eq(parseString(`if(1){}else{3}()()`), 275 call(call(call(var("if"),intl(1),fun([],intl(178)),fun([],intl(3 275 call(call(call(var("if"),intl(1),fun([],intl(178)),fun([],intl(3 ................................................................................................................................................................................ 279 assert_eq(parseString(`1*2+3`), call(var("+"),call(var("*"),intl(1),intl 279 assert_eq(parseString(`1*2+3`), call(var("+"),call(var("*"),intl(1),intl 280 280 281 assert_eq(parseString(` 281 assert_eq(parseString(` 282 let x = 100; #comment 282 let x = 100; #comment 283 let y = 200; #comment!!!!! 283 let y = 200; #comment!!!!! 284 x+y 284 x+y 285 `), 285 `), 286 let("x", "@val", intl(100), let("y", "@val", intl(200), call(var | 286 let("x", "", intl(100), let("y", "", intl(200), call(var("+"), v 287 ); 287 ); 288 288 289 assert_eq(parseString(` 289 assert_eq(parseString(` 290 var fac = fun(x){ if(x <= 1) {1} else {x*fac(x-1)} }; 290 var fac = fun(x){ if(x <= 1) {1} else {x*fac(x-1)} }; 291 fac(10) 291 fac(10) 292 `), 292 `), 293 let("fac", "@val", fun(["x"], | 293 let("fac", "", fun(["x"], 294 call(var("if"), 294 call(var("if"), 295 call(var("<="), var("x"), intl(1)), 295 call(var("<="), var("x"), intl(1)), 296 fun([], intl(1)), 296 fun([], intl(1)), 297 fun([], call(var("*"), var("x"), call(var("fac") 297 fun([], call(var("*"), var("x"), call(var("fac") 298 )), 298 )), 299 call(var("fac"),intl(10)) 299 call(var("fac"),intl(10)) 300 ) 300 )