Differences From Artifact [38516f68b159d6bd]:
- File
polemy/parse.d
- 2010-11-24 13:22:04 - part of checkin [f9c31f3cd8] on branch trunk - Fixed the null dereference bug when directly wrote "case 1 when 2: 3" in REPL. It was due to null LexPosition in the AST. Now AST.pos !is null is an invariant of AST. (user: kinaba) [annotate]
To 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]
98 string kwd = "@" ~ layer; 98 string kwd = "@" ~ layer;
99 string var = layer; 99 string var = layer;
100 100
101 auto e = tryEat("(") 101 auto e = tryEat("(")
102 ? parseLambdaAfterOpenParen(pos) // let var ( . 102 ? parseLambdaAfterOpenParen(pos) // let var ( .
103 : (eat("=", "after "~kwd), E(0)); // let var = . 103 : (eat("=", "after "~kwd), E(0)); // let var = .
104 if( moreDeclarationExists() ) 104 if( moreDeclarationExists() )
105 return new Let(pos, var, SystemLayer, e, Body()) | 105 return new Let(pos, var, LiftLayer, e, Body());
106 else 106 else
107 return new Let(pos, var, SystemLayer, e, | 107 return new Let(pos, var, LiftLayer, e,
108 new Lay(pos, SystemLayer, new Var(pos, v | 108 new Lay(pos, LiftLayer, new Var(pos, var
109 ); 109 );
110 } 110 }
111 else 111 else
112 { 112 {
113 string kwd = layer; 113 string kwd = layer;
114 if( layer.empty && !tryEat(kwd="let") && !tryEat(kwd="va 114 if( layer.empty && !tryEat(kwd="let") && !tryEat(kwd="va
115 return null; // none of {@lay, let, var, def} oc 115 return null; // none of {@lay, let, var, def} oc
................................................................................................................................................................................
632 assert_eq(parseString(`def foo(x) { x+1 }; foo`), 632 assert_eq(parseString(`def foo(x) { x+1 }; foo`),
633 let("foo", "", 633 let("foo", "",
634 fun(["x"], call(var("+"), var("x"), intl(1))), 634 fun(["x"], call(var("+"), var("x"), intl(1))),
635 var("foo")) 635 var("foo"))
636 ); 636 );
637 637
638 assert_eq(parseString(`@@type ( x ) { x }`), 638 assert_eq(parseString(`@@type ( x ) { x }`),
639 let("@type", SystemLayer, fun(["x"], var("x")), lay(SystemLayer, | 639 let("@type", LiftLayer, fun(["x"], var("x")), lay(LiftLayer, var
640 640
641 assert_eq(parseString(`{}`), call(var("{}"))); 641 assert_eq(parseString(`{}`), call(var("{}")));
642 assert_eq(parseString(`{foo:1,"bar":2}`), 642 assert_eq(parseString(`{foo:1,"bar":2}`),
643 call(var(".="), call(var(".="), call(var("{}")), strl("foo"), in 643 call(var(".="), call(var(".="), call(var("{}")), strl("foo"), in
644 assert_eq(parseString(`{}.foo`), call(var("."),call(var("{}")),strl("foo 644 assert_eq(parseString(`{}.foo`), call(var("."),call(var("{}")),strl("foo
645 assert_eq(parseString(`{}.?foo`), call(var(".?"),call(var("{}")),strl("f 645 assert_eq(parseString(`{}.?foo`), call(var(".?"),call(var("{}")),strl("f
646 assert_eq(parseString(`x{y:1}`), call(var(".="),var("x"),strl("y"),intl( 646 assert_eq(parseString(`x{y:1}`), call(var(".="),var("x"),strl("y"),intl(