comparison dmd/parse.c @ 658:50383e476c7e

Upgraded frontend to DMD 1.035
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Mon, 06 Oct 2008 16:22:11 +0200
parents aaade6ded589
children 20a5180f2e80
comparison
equal deleted inserted replaced
657:c42173b3557b 658:50383e476c7e
2372 Initializer *value; 2372 Initializer *value;
2373 int comma; 2373 int comma;
2374 Loc loc = this->loc; 2374 Loc loc = this->loc;
2375 Token *t; 2375 Token *t;
2376 int braces; 2376 int braces;
2377 int brackets;
2377 2378
2378 switch (token.value) 2379 switch (token.value)
2379 { 2380 {
2380 case TOKlcurly: 2381 case TOKlcurly:
2381 /* Scan ahead to see if it is a struct initializer or 2382 /* Scan ahead to see if it is a struct initializer or
2459 break; 2460 break;
2460 } 2461 }
2461 return is; 2462 return is;
2462 2463
2463 case TOKlbracket: 2464 case TOKlbracket:
2465 /* Scan ahead to see if it is an array initializer or
2466 * an expression.
2467 * If it ends with a ';', it is an array initializer.
2468 */
2469 brackets = 1;
2470 for (t = peek(&token); 1; t = peek(t))
2471 {
2472 switch (t->value)
2473 {
2474 case TOKlbracket:
2475 brackets++;
2476 continue;
2477
2478 case TOKrbracket:
2479 if (--brackets == 0)
2480 { t = peek(t);
2481 if (t->value != TOKsemicolon &&
2482 t->value != TOKcomma &&
2483 t->value != TOKrcurly)
2484 goto Lexpression;
2485 break;
2486 }
2487 continue;
2488
2489 case TOKeof:
2490 break;
2491
2492 default:
2493 continue;
2494 }
2495 break;
2496 }
2497
2464 ia = new ArrayInitializer(loc); 2498 ia = new ArrayInitializer(loc);
2465 nextToken(); 2499 nextToken();
2466 comma = 0; 2500 comma = 0;
2467 while (1) 2501 while (1)
2468 { 2502 {
4245 Expressions *keys = NULL; 4279 Expressions *keys = NULL;
4246 4280
4247 nextToken(); 4281 nextToken();
4248 if (token.value != TOKrbracket) 4282 if (token.value != TOKrbracket)
4249 { 4283 {
4250 while (1) 4284 while (token.value != TOKeof)
4251 { 4285 {
4252 Expression *e = parseAssignExp(); 4286 Expression *e = parseAssignExp();
4253 if (token.value == TOKcolon && (keys || values->dim == 0)) 4287 if (token.value == TOKcolon && (keys || values->dim == 0))
4254 { nextToken(); 4288 { nextToken();
4255 if (!keys) 4289 if (!keys)
4523 if (isDeclaration(tk, 0, TOKrparen, &tk)) 4557 if (isDeclaration(tk, 0, TOKrparen, &tk))
4524 { 4558 {
4525 tk = peek(tk); // skip over right parenthesis 4559 tk = peek(tk); // skip over right parenthesis
4526 switch (tk->value) 4560 switch (tk->value)
4527 { 4561 {
4562 case TOKnot:
4563 tk = peek(tk);
4564 if (tk->value == TOKis) // !is
4565 break;
4528 case TOKdot: 4566 case TOKdot:
4529 case TOKplusplus: 4567 case TOKplusplus:
4530 case TOKminusminus: 4568 case TOKminusminus:
4531 case TOKnot:
4532 case TOKdelete: 4569 case TOKdelete:
4533 case TOKnew: 4570 case TOKnew:
4534 case TOKlparen: 4571 case TOKlparen:
4535 case TOKidentifier: 4572 case TOKidentifier:
4536 case TOKthis: 4573 case TOKthis:
5147 */ 5184 */
5148 5185
5149 void Parser::addComment(Dsymbol *s, unsigned char *blockComment) 5186 void Parser::addComment(Dsymbol *s, unsigned char *blockComment)
5150 { 5187 {
5151 s->addComment(combineComments(blockComment, token.lineComment)); 5188 s->addComment(combineComments(blockComment, token.lineComment));
5189 token.lineComment = NULL;
5152 } 5190 }
5153 5191
5154 5192
5155 /********************************* ***************************/ 5193 /********************************* ***************************/
5156 5194