Diff
Not logged in

Differences From Artifact [5f90478aa23ae726]:

To Artifact [e14df84da140adf3]:


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