Differences From Artifact [4856c979362ef435]:
- File        
polemy/parse.d
- 2010-11-07 12:46:23 - part of checkin [3f5dc76a75] on branch trunk - Added funcall expression parser and function literal parser. (user: kinaba) [annotate]
 
To Artifact [1d6de9cb69bbf7d4]:
- File        
polemy/parse.d
- 2010-11-07 14:34:29 - part of checkin [0569f7b8c2] on branch trunk - - Added function literal evaluator (i.e., closure). - Workaround for d2stacktrace's infinite-loop bug. (when std.demangle.demangle use exception inside it, it will go into an infinite loop. to avoid this, I choose to unset TraceHandler during stacktrace generation. This is far from the complete solution, but at least it should work as expected under single-thread environment...) (user: kinaba) [annotate]
 
  188                          return e;                                                    188                          return e;
  189                  }                                                                    189                  }
  190                                                                                       190  
  191                  if( tryEat("fun") )                                                  191                  if( tryEat("fun") )
  192                  {                                                                    192                  {
  193                          eat("(", "after fun");                                       193                          eat("(", "after fun");
  194                          string[] params;                                             194                          string[] params;
  195                          for(;;)                                                  |   195                          while(!tryEat(")"))
  196                          {                                                            196                          {
  197                                  if( lex.empty ) {                                    197                                  if( lex.empty ) {
  198                                          auto e = ParserException.create(lex,"Une     198                                          auto e = ParserException.create(lex,"Une
  199                                          throw e;                                     199                                          throw e;
  200                                  }                                                    200                                  }
  201                                  if( lex.front.kind != Token.Kind.identifier ) {      201                                  if( lex.front.kind != Token.Kind.identifier ) {
  202                                          auto e = ParserException.create(lex,"Ide     202                                          auto e = ParserException.create(lex,"Ide
................................................................................................................................................................................
  306                  new IntLiteralExpression(null, BigInt(1)),                           306                  new IntLiteralExpression(null, BigInt(1)),
  307                  new FuncallExpression(null,                                          307                  new FuncallExpression(null,
  308                          new FunLiteralExpression(null, ["abc"], [                    308                          new FunLiteralExpression(null, ["abc"], [
  309                          ]),                                                          309                          ]),
  310                          new IntLiteralExpression(null, BigInt(4))                    310                          new IntLiteralExpression(null, BigInt(4))
  311                          ))));                                                        311                          ))));
  312  }                                                                                    312  }
                                                                                        >   313  unittest
                                                                                        >   314  {
                                                                                        >   315          auto p = parserFromString(`var x = 1; var f = fun(){x=x+1;}; f(); f(); x
                                                                                        >   316          Program prog = p.parseProgram();
                                                                                        >   317  }