@@ -14,13 +14,6 @@ tag restriction { UNRESTRICTED; RESTRICT_NO_CALL_EXPRS; RESTRICT_NO_BAR_OP; }
14
14
15
15
tag file_type { CRATE_FILE ; SOURCE_FILE ; }
16
16
17
- tag fn_kw {
18
- fn_kw_fn;
19
- fn_kw_fn_at;
20
- fn_kw_lambda;
21
- fn_kw_block;
22
- }
23
-
24
17
type parse_sess = @{ cm: codemap:: codemap, mutable next_id: node_id} ;
25
18
26
19
fn next_node_id ( sess : parse_sess ) -> node_id {
@@ -544,13 +537,9 @@ fn parse_ty(p: parser, colons_before_params: bool) -> @ast::ty {
544
537
} else if eat_word ( p, "block" ) {
545
538
t = parse_ty_fn ( ast:: proto_block, p) ;
546
539
} else if eat_word ( p, "lambda" ) {
547
- if eat ( p, token:: LBRACKET ) { // lambda[send](...)
548
- expect_word ( p, "send" ) ;
549
- expect ( p, token:: RBRACKET ) ;
550
- t = parse_ty_fn ( ast:: proto_send, p) ;
551
- } else { // lambda(...)
552
- t = parse_ty_fn ( ast:: proto_shared ( ast:: sugar_sexy) , p) ;
553
- }
540
+ t = parse_ty_fn ( ast:: proto_shared ( ast:: sugar_sexy) , p) ;
541
+ } else if eat_word ( p, "sendfn" ) {
542
+ t = parse_ty_fn ( ast:: proto_send, p) ;
554
543
} else if eat_word ( p, "obj" ) {
555
544
t = parse_ty_obj ( p) ;
556
545
} else if p. peek ( ) == token:: MOD_SEP || is_ident ( p. peek ( ) ) {
@@ -844,12 +833,14 @@ fn parse_bottom_expr(p: parser) -> @ast::expr {
844
833
ret parse_spawn_expr(p);
845
834
*/
846
835
} else if eat_word ( p, "fn" ) {
847
- let kw = parse_fn_anon_kw ( p) ;
848
- ret parse_fn_expr ( p, kw ) ;
836
+ let proto = parse_fn_ty_proto ( p) ;
837
+ ret parse_fn_expr ( p, proto ) ;
849
838
} else if eat_word ( p, "block" ) {
850
- ret parse_fn_expr ( p, fn_kw_block ) ;
839
+ ret parse_fn_expr ( p, ast :: proto_block ) ;
851
840
} else if eat_word ( p, "lambda" ) {
852
- ret parse_fn_expr ( p, fn_kw_lambda) ;
841
+ ret parse_fn_expr ( p, ast:: proto_shared ( ast:: sugar_sexy) ) ;
842
+ } else if eat_word ( p, "sendfn" ) {
843
+ ret parse_fn_expr ( p, ast:: proto_send) ;
853
844
} else if eat_word ( p, "unchecked" ) {
854
845
ret parse_block_expr ( p, lo, ast:: unchecked_blk) ;
855
846
} else if eat_word ( p, "unsafe" ) {
@@ -1290,7 +1281,7 @@ fn parse_if_expr(p: parser) -> @ast::expr {
1290
1281
1291
1282
// Parses:
1292
1283
//
1293
- // CC := [send; copy ID*; move ID*]
1284
+ // CC := [copy ID*; move ID*]
1294
1285
//
1295
1286
// where any part is optional and trailing ; is permitted.
1296
1287
fn parse_capture_clause ( p : parser ) -> @ast:: capture {
@@ -1322,17 +1313,13 @@ fn parse_capture_clause(p: parser) -> @ast::capture {
1322
1313
std:: util:: unreachable ( ) ;
1323
1314
}
1324
1315
1325
- let is_send = false ;
1326
1316
let copies = [ ] ;
1327
1317
let moves = [ ] ;
1328
1318
1329
1319
let lo = p. get_lo_pos ( ) ;
1330
1320
if eat ( p, token:: LBRACKET ) {
1331
1321
while !eat ( p, token:: RBRACKET ) {
1332
- if eat_word ( p, "send" ) {
1333
- is_send = true ;
1334
- expect_opt_trailing_semi ( p) ;
1335
- } else if eat_word ( p, "copy" ) {
1322
+ if eat_word ( p, "copy" ) {
1336
1323
copies += eat_ident_list ( p) ;
1337
1324
expect_opt_trailing_semi ( p) ;
1338
1325
} else if eat_word ( p, "move" ) {
@@ -1346,68 +1333,25 @@ fn parse_capture_clause(p: parser) -> @ast::capture {
1346
1333
}
1347
1334
let hi = p. get_last_hi_pos ( ) ;
1348
1335
1349
- ret @spanned ( lo, hi, { is_send : is_send , copies: copies, moves: moves} ) ;
1336
+ ret @spanned ( lo, hi, { copies: copies, moves: moves} ) ;
1350
1337
}
1351
1338
1352
- fn select_proto ( p : parser , kw : fn_kw , is_send : bool ) -> ast:: proto {
1353
- ret alt ( kw, is_send) {
1354
- ( fn_kw_fn. , true ) { ast:: proto_bare }
1355
- ( fn_kw_fn_at. , true ) { ast:: proto_send }
1356
- ( fn_kw_lambda. , true ) { ast:: proto_send }
1357
- ( fn_kw_block. , true ) { p. fatal ( "block cannot be declared sendable" ) }
1358
- ( fn_kw_fn. , false ) { ast:: proto_bare }
1359
- ( fn_kw_fn_at. , false ) { ast:: proto_shared ( ast:: sugar_normal) }
1360
- ( fn_kw_lambda. , false ) { ast:: proto_shared ( ast:: sugar_sexy) }
1361
- ( fn_kw_block. , false ) { ast:: proto_block }
1362
- } ;
1363
- }
1364
-
1365
- fn parse_fn_expr ( p : parser , kw : fn_kw ) -> @ast:: expr {
1339
+ fn parse_fn_expr ( p : parser , proto : ast:: proto ) -> @ast:: expr {
1366
1340
let lo = p. get_last_lo_pos ( ) ;
1367
1341
let captures = parse_capture_clause ( p) ;
1368
- let is_send = captures. node . is_send ;
1369
- let proto = select_proto ( p, kw, is_send) ;
1370
1342
let decl = parse_fn_decl ( p, ast:: impure_fn, ast:: il_normal) ;
1371
1343
let body = parse_block ( p) ;
1372
1344
let _fn = { decl: decl, proto: proto, body: body} ;
1373
1345
ret mk_expr( p, lo, body. span . hi , ast:: expr_fn ( _fn, captures) ) ;
1374
1346
}
1375
1347
1376
- /*
1377
- ** This version triggers an LLVM bug: **
1378
-
1379
- fn parse_fn_expr(p: parser, kw: fn_kw) -> @ast::expr {
1380
- let lo = p.get_last_lo_pos();
1381
- let captures = parse_capture_clause(p);
1382
- let is_send = captures.node.is_send;
1383
- //let proto = select_proto(p, kw, is_send);
1384
- log_err (kw, captures, is_send);
1385
- let proto = alt (kw, is_send) {
1386
- (fn_kw_fn., true) { ast::proto_bare }
1387
- (fn_kw_fn_at., true) { ast::proto_send }
1388
- (fn_kw_lambda., true) { ast::proto_send }
1389
- (fn_kw_block., true) { p.fatal("block cannot be declared sendable") }
1390
- (fn_kw_fn., false) { ast::proto_bare }
1391
- (fn_kw_fn_at., false) { ast::proto_shared(ast::sugar_normal) }
1392
- (fn_kw_lambda., false) { ast::proto_shared(ast::sugar_sexy) }
1393
- (fn_kw_block., false) { ast::proto_block }
1394
- };
1395
- fail "foo";
1396
- //let decl = parse_fn_decl(p, ast::impure_fn, ast::il_normal);
1397
- //let body = parse_block(p);
1398
- //let _fn = {decl: decl, proto: proto, body: body};
1399
- //ret mk_expr(p, lo, body.span.hi, ast::expr_fn(_fn, captures));
1400
- }
1401
- */
1402
-
1403
-
1404
1348
fn parse_fn_block_expr ( p : parser ) -> @ast:: expr {
1405
1349
let lo = p. get_last_lo_pos ( ) ;
1406
1350
let decl = parse_fn_block_decl ( p) ;
1407
1351
let mid = p. get_last_hi_pos ( ) ;
1408
1352
let body = parse_block_tail ( p, lo, ast:: default_blk) ;
1409
1353
let _fn = { decl: decl, proto: ast:: proto_block, body: body} ;
1410
- let captures = @spanned ( lo, mid, { is_send : false , copies: [ ] , moves: [ ] } ) ;
1354
+ let captures = @spanned ( lo, mid, { copies: [ ] , moves: [ ] } ) ;
1411
1355
ret mk_expr( p, lo, body. span . hi , ast:: expr_fn ( _fn, captures) ) ;
1412
1356
}
1413
1357
@@ -2191,15 +2135,6 @@ fn parse_fn_ty_proto(p: parser) -> ast::proto {
2191
2135
}
2192
2136
}
2193
2137
2194
- fn parse_fn_anon_kw ( p : parser ) -> fn_kw {
2195
- if p. peek ( ) == token:: AT {
2196
- p. bump ( ) ;
2197
- fn_kw_fn_at
2198
- } else {
2199
- fn_kw_fn
2200
- }
2201
- }
2202
-
2203
2138
fn parse_method_proto ( p : parser ) -> ast:: proto {
2204
2139
if eat_word ( p, "fn" ) {
2205
2140
ret ast:: proto_bare;
0 commit comments