Skip to content

Commit 45ee6bb

Browse files
committed
---
yaml --- r: 92240 b: refs/heads/auto c: dd042ef h: refs/heads/master v: v3
1 parent 101ce19 commit 45ee6bb

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: d4f5ae0118678a8cea666619303727408e6255aa
16+
refs/heads/auto: dd042efa7e109dee88241358f88a0c8bb57e9269
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/libsyntax/parse/token.rs

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,17 @@ pub fn is_bar(t: &Token) -> bool {
316316
match *t { BINOP(OR) | OROR => true, _ => false }
317317
}
318318

319+
// Get the first "argument"
320+
macro_rules! first {
321+
( $first:expr, $( $remainder:expr, )* ) => ( $first )
322+
}
323+
324+
// Get the last "argument" (has to be done recursively to avoid phoney local ambiguity error)
325+
macro_rules! last {
326+
( $first:expr, $( $remainder:expr, )+ ) => ( last!( $( $remainder, )+ ) );
327+
( $first:expr, ) => ( $first )
328+
}
329+
319330
// In this macro, there is the requirement that the name (the number) must be monotonically
320331
// increasing by one in the special identifiers, starting at 0; the same holds for the keywords,
321332
// except starting from the next number instead of zero, and with the additional exception that
@@ -329,9 +340,17 @@ macro_rules! declare_special_idents_and_keywords {(
329340
}
330341

331342
pub mod keywords {
332-
$( ($k_name:expr, $k_variant:ident, $k_str:expr); )*
343+
'strict:
344+
$( ($sk_name:expr, $sk_variant:ident, $sk_str:expr); )*
345+
'reserved:
346+
$( ($rk_name:expr, $rk_variant:ident, $rk_str:expr); )*
333347
}
334348
) => {
349+
static STRICT_KEYWORD_START: Name = first!($( $sk_name, )*);
350+
static STRICT_KEYWORD_FINAL: Name = last!($( $sk_name, )*);
351+
static RESERVED_KEYWORD_START: Name = first!($( $rk_name, )*);
352+
static RESERVED_KEYWORD_FINAL: Name = last!($( $rk_name, )*);
353+
335354
pub mod special_idents {
336355
use ast::Ident;
337356
$( pub static $si_static: Ident = Ident { name: $si_name, ctxt: 0 }; )*
@@ -348,13 +367,15 @@ macro_rules! declare_special_idents_and_keywords {(
348367
use ast::Ident;
349368

350369
pub enum Keyword {
351-
$( $k_variant, )*
370+
$( $sk_variant, )*
371+
$( $rk_variant, )*
352372
}
353373

354374
impl Keyword {
355375
pub fn to_ident(&self) -> Ident {
356376
match *self {
357-
$( $k_variant => Ident { name: $k_name, ctxt: 0 }, )*
377+
$( $sk_variant => Ident { name: $sk_name, ctxt: 0 }, )*
378+
$( $rk_variant => Ident { name: $rk_name, ctxt: 0 }, )*
358379
}
359380
}
360381
}
@@ -366,20 +387,17 @@ macro_rules! declare_special_idents_and_keywords {(
366387
// constants below.
367388
let init_vec = ~[
368389
$( $si_str, )*
369-
$( $k_str, )*
390+
$( $sk_str, )*
391+
$( $rk_str, )*
370392
];
371393

372394
@interner::StrInterner::prefill(init_vec)
373395
}
374396
}}
375397

376-
// If modifying the numbers below, remember to modify these as appropriate
398+
// If the special idents get renumbered, remember to modify these two as appropriate
377399
static SELF_KEYWORD_NAME: Name = 3;
378400
static STATIC_KEYWORD_NAME: Name = 10;
379-
static STRICT_KEYWORD_START: Name = 14;
380-
static STRICT_KEYWORD_FINAL: Name = 47;
381-
static RESERVED_KEYWORD_START: Name = 48;
382-
static RESERVED_KEYWORD_FINAL: Name = 54;
383401

384402
declare_special_idents_and_keywords! {
385403
pub mod special_idents {
@@ -409,7 +427,7 @@ declare_special_idents_and_keywords! {
409427
pub mod keywords {
410428
// These ones are variants of the Keyword enum
411429

412-
// Strict keywords
430+
'strict:
413431
(14, As, "as");
414432
(15, Break, "break");
415433
(16, Const, "const");
@@ -448,7 +466,7 @@ declare_special_idents_and_keywords! {
448466
(46, Continue, "continue");
449467
(47, Proc, "proc");
450468

451-
// Reserved keywords
469+
'reserved:
452470
(48, Alignof, "alignof");
453471
(49, Be, "be");
454472
(50, Offsetof, "offsetof");

0 commit comments

Comments
 (0)