Differences From Artifact [9aca36046bea5df8]:
- File
polemy/parse.d
- 2010-11-26 05:03:10 - part of checkin [207cea338a] on branch trunk - changed hiding mechanizem of x in let x = ... for @macro layer. Old: set(x,ValueLayer,undefined) Nee: set(x,NoopLayer,null) (user: kinaba) [annotate]
To Artifact [3ad9850246d5111f]:
- File
polemy/parse.d
- 2010-11-26 05:29:24 - part of checkin [f8684f4d69] on branch trunk - changed the desugaring of >>@macro x=e from >>@macro x=e in x to >>@macro x=e in "(macro definition)" for convenience during REPL interaction (user: kinaba) [annotate]
118 string var = eatId("after "~kwd, AllowQuoted); // name o 118 string var = eatId("after "~kwd, AllowQuoted); // name o
119 119
120 auto e = tryEat("(") 120 auto e = tryEat("(")
121 ? parseLambdaAfterOpenParen(pos) // let var ( . 121 ? parseLambdaAfterOpenParen(pos) // let var ( .
122 : (eat("=", "after "~kwd), E(0)); // let var = . 122 : (eat("=", "after "~kwd), E(0)); // let var = .
123 if( moreDeclarationExists() ) 123 if( moreDeclarationExists() )
124 return new Let(pos, var, layer, e, Body()); 124 return new Let(pos, var, layer, e, Body());
125 else | 125 else {
> 126 if( layer.empty )
126 return new Let(pos, var, layer, e, new Var(varpo | 127 return new Let(pos, var, layer, e, new V
> 128 else if( isMacroLayer(layer) )
> 129 return new Let(pos, var, layer, e, new S
> 130 else
> 131 return new Let(pos, var, layer, e, new L
> 132 }
127 } 133 }
128 } 134 }
129 135
130 AST TopLevelExpression() 136 AST TopLevelExpression()
131 { 137 {
132 /// TopLevelExpression ::= Expression ([";"|"in"] Body?)? 138 /// TopLevelExpression ::= Expression ([";"|"in"] Body?)?
133 139
................................................................................................................................................................................
567 mixin EasyAST; 573 mixin EasyAST;
568 574
569 assert_eq(parseString(`123`), intl(123)); 575 assert_eq(parseString(`123`), intl(123));
570 assert_eq(parseString(`"foo"`), strl("foo")); 576 assert_eq(parseString(`"foo"`), strl("foo"));
571 assert_eq(parseString(`fun(){1}`), fun([],intl(1))); 577 assert_eq(parseString(`fun(){1}`), fun([],intl(1)));
572 assert_eq(parseString(`fun(x){1}`), fun(["x"],intl(1))); 578 assert_eq(parseString(`fun(x){1}`), fun(["x"],intl(1)));
573 assert_eq(parseString("\u03BB(){1}"), fun([],intl(1))); 579 assert_eq(parseString("\u03BB(){1}"), fun([],intl(1)));
574 assert_eq(parseString("\u03BB(x){1}"), fun(["x"],intl(1))); | 580 assert_eq(parseString("\u03BB(x,y){1}"), fun(["x","y"],intl(1)));
575 assert_eq(parseString(`1;2`), let("_","",intl(1),intl(2))); 581 assert_eq(parseString(`1;2`), let("_","",intl(1),intl(2)));
576 assert_eq(parseString(`1;2;`), let("_","",intl(1),intl(2))); 582 assert_eq(parseString(`1;2;`), let("_","",intl(1),intl(2)));
577 assert_eq(parseString(`let x=1 in 2`), let("x","",intl(1),intl(2))); 583 assert_eq(parseString(`let x=1 in 2`), let("x","",intl(1),intl(2)));
578 assert_eq(parseString(`var x=1;2;`), let("x","",intl(1),intl(2))); 584 assert_eq(parseString(`var x=1;2;`), let("x","",intl(1),intl(2)));
579 assert_eq(parseString(`def x=1`), let("x","",intl(1),var("x"))); 585 assert_eq(parseString(`def x=1`), let("x","",intl(1),var("x")));
580 assert_eq(parseString(`@val x=1;`), let("x","@val",intl(1),var("x"))); | 586 assert_eq(parseString(`@val x=1;`), let("x","@val",intl(1),lay("@val",va
581 assert_eq(parseString(`@typ x="#int";`), let("x","@typ",strl("#int"),var | 587 assert_eq(parseString(`@typ x="#int";`), let("x","@typ",strl("#int"),lay
> 588 assert_eq(parseString(`@macro x=1`), let("x","@macro",intl(1),strl("(mac
582 assert_eq(parseString(`f(1,2)`), call(var("f"),intl(1),intl(2))); 589 assert_eq(parseString(`f(1,2)`), call(var("f"),intl(1),intl(2)));
583 assert_eq(parseString(`if 1 then 2`), call(var("if"),intl(1),fun([],intl 590 assert_eq(parseString(`if 1 then 2`), call(var("if"),intl(1),fun([],intl
584 assert_eq(parseString(`if 1 then: 2 else(3)`), call(var("if"),intl(1),fu 591 assert_eq(parseString(`if 1 then: 2 else(3)`), call(var("if"),intl(1),fu
585 assert_eq(parseString(`(if 1 then () else 3)()()`), 592 assert_eq(parseString(`(if 1 then () else 3)()()`),
586 call(call(call(var("if"),intl(1),fun([],strl("(empty function bo 593 call(call(call(var("if"),intl(1),fun([],strl("(empty function bo
587 assert_eq(parseString(`1+2*3`), call(var("+"),intl(1),call(var("*"),intl 594 assert_eq(parseString(`1+2*3`), call(var("+"),intl(1),call(var("*"),intl
588 assert_eq(parseString(`(1+2)*3`), call(var("*"),call(var("+"),intl(1),in 595 assert_eq(parseString(`(1+2)*3`), call(var("*"),call(var("+"),intl(1),in