Diff
Not logged in

Differences From Artifact [de91c770214a43a1]:

To Artifact [51dd3bd106fd9ecb]:


303 { 303 { 304 auto p = parserFromString(` 304 auto p = parserFromString(` 305 var zzz = 100; # comment 305 var zzz = 100; # comment 306 zzz = zzz + zzz * "fo\no"; # comment 306 zzz = zzz + zzz * "fo\no"; # comment 307 42; 307 42; 308 `); 308 `); 309 309 310 auto s0 = new DeclStatement(null, "zzz", new IntLiteralExpression(null, | 310 mixin EasyAst; > 311 auto s0 = decl("zzz", intl(BigInt(100))); 311 auto s1 = new ExprStatement(null, new AssignExpression(null, | 312 auto s1 = expr( new AssignExpression(null, 312 new VarExpression(null, "zzz"), 313 new VarExpression(null, "zzz"), 313 new FuncallExpression(null, new VarExpression(null,"+"), 314 new FuncallExpression(null, new VarExpression(null,"+"), 314 new VarExpression(null, "zzz"), 315 new VarExpression(null, "zzz"), 315 new FuncallExpression(null, new VarExpression(null,"*"), 316 new FuncallExpression(null, new VarExpression(null,"*"), 316 new VarExpression(null, "zzz"), 317 new VarExpression(null, "zzz"), 317 new StrLiteralExpression(null, "fo\\no") 318 new StrLiteralExpression(null, "fo\\no") 318 )))); 319 )))); ................................................................................................................................................................................ 327 328 328 unittest 329 unittest 329 { 330 { 330 auto p = parserFromString(` 331 auto p = parserFromString(` 331 var f = fun(x,y){x+y;}; 332 var f = fun(x,y){x+y;}; 332 f(1,fun(abc){}(4)); 333 f(1,fun(abc){}(4)); 333 `); 334 `); > 335 mixin EasyAst; 334 Program prog = p.parseProgram(); 336 Program prog = p.parseProgram(); 335 assert( prog.length == 2 ); 337 assert( prog.length == 2 ); 336 assert( prog[0] == new DeclStatement(null, "f", new FunLiteralExpression | 338 assert( prog[0] == decl("f", fun( 337 ["x","y"], [new ExprStatement(null, | 339 ["x","y"], [expr(funcall(var("+"), var("x"), var("y")))] 338 new FuncallExpression(null, new VarExpression(null, "+") < 339 new VarExpression(null, "x"), new VarExpression(null, "y < 340 ))); | 340 ))); 341 assert( prog[1] == new ExprStatement(null, new FuncallExpression(null, | 341 assert( prog[1] == expr(funcall(var("f"), 342 new VarExpression(null, "f"), < 343 new IntLiteralExpression(null, BigInt(1)), | 342 intl(BigInt(1)), 344 new FuncallExpression(null, | 343 funcall( 345 new FunLiteralExpression(null, ["abc"], [ < 346 ]), < > 344 fun(["abc"], cast(Statement[])[]), 347 new IntLiteralExpression(null, BigInt(4)) | 345 intl(BigInt(4)) 348 )))); | 346 )))); 349 } 347 } 350 348 351 unittest 349 unittest 352 { 350 { 353 auto p = parserFromString(`var x = 1; var f = fun(){x=x+1;}; f(); f(); x 351 auto p = parserFromString(`var x = 1; var f = fun(){x=x+1;}; f(); f(); x 354 Program prog = p.parseProgram(); 352 Program prog = p.parseProgram(); 355 } 353 }