Differences From Artifact [50e0836a1ece20de]:
- File
polemy/parse.d
- 2010-11-23 13:55:15 - part of checkin [2134cd44cc] on branch trunk - further clean-up for polemy2d (user: kinaba) [annotate]
To Artifact [bacc00f3f91907a9]:
- File
polemy/parse.d
- 2010-11-23 18:28:47 - part of checkin [ba11f1d551] on branch trunk - fixed the macro scoping rules concerning non-macro let (user: kinaba) [annotate]
114 114 if( layer.empty && !tryEat(kwd="let") && !tryEat(kwd="var") && !tryEat(kwd="def") )
115 115 return null; // none of {@lay, let, var, def} occurred, it's not a declaration
116 116
117 117 auto varpos = currentPosition();
118 118 string var = eatId("after "~kwd, AllowQuoted); // name of the declared variable
119 119
120 120 auto e = tryEat("(")
121 - ? parseLambdaAfterOpenParen(varpos) // let var ( ...
122 - : (eat("=", "after "~kwd), E(0)); // let var = ...
121 + ? parseLambdaAfterOpenParen(pos) // let var ( ...
122 + : (eat("=", "after "~kwd), E(0)); // let var = ...
123 123 if( moreDeclarationExists() )
124 124 return new Let(pos, var, layer, e, Body());
125 125 else
126 126 return new Let(pos, var, layer, e, new Var(varpos, var));
127 127 }
128 128 }
129 129
................................................................................
480 480
481 481 AST parseId()
482 482 {
483 483 scope(exit) lex.popFront;
484 484 return new Str(currentPosition(), lex.front.str);
485 485 }
486 486
487 - AST parseLambdaAfterOpenParen(immutable LexPosition pos)
487 + AST parseLambdaAfterOpenParen(LexPosition pos)
488 488 {
489 489 Parameter[] params;
490 490 while( !tryEat(")") )
491 491 {
492 492 params ~= parseParam();
493 493 if( !tryEat(",") ) {
494 494 eat(")", "after function parameters");
................................................................................
559 559 }
560 560
561 561 AST doNothingExpression()
562 562 {
563 563 return new Str(currentPosition(), "(empty function body)");
564 564 }
565 565
566 - immutable(LexPosition) currentPosition()
566 + LexPosition currentPosition()
567 567 {
568 568 return lex.empty ? null : lex.front.pos;
569 569 }
570 570 }
571 571
572 572 unittest
573 573 {