From e6c0074733100d2f1f7f5df293f46784de40647b Mon Sep 17 00:00:00 2001 From: Ben S Date: Sun, 15 Feb 2015 13:07:24 +0000 Subject: [PATCH] Smarten up attribute highlighting --- rust.mm | 30 +++++++++++++++++++++++++++--- smoke.rs | 13 ++++++++++++- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/rust.mm b/rust.mm index 2ee617a..4b055f8 100644 --- a/rust.mm +++ b/rust.mm @@ -134,13 +134,37 @@ SInt32 skipWord(BBLMTextIterator &iter) SInt32 skipAttribute(BBLMTextIterator &iter) { - SInt32 length = 1; + SInt32 length = 0; UniChar ch; - iter++; + if (iter.strcmp("#[", 2) == 0) + { + length += 2; + iter += 2; + } + else if (iter.strcmp("#![", 3) == 0) + { + length += 3; + iter += 3; + } + else if (iter.strcmp("#", 1) == 0) + { + iter++; + return 1; + } + else + { + return 0; + } + while ((ch = iter.GetNextChar())) { - if (ch == '\n' || ch == '\r') + if (ch == ']') + { + length++; + break; + } + else if (ch == '\n' || ch == '\r') { break; } diff --git a/smoke.rs b/smoke.rs index 2353c3e..f135274 100644 --- a/smoke.rs +++ b/smoke.rs @@ -50,6 +50,8 @@ r##"there's a " in this string"## // the string shouldn't end until ## r##"there's a # in this string"## // even if there's a # in the middle + // " // in case the above failed :) + // Decimal Numbers // --------------- @@ -84,7 +86,7 @@ 7.348e+22 // uppercase E and plus let tuple = ((8, 4), 48); - let a = tuple.1.1 + let a = tuple.0.0; // Numeric Suffixes // ---------------- @@ -99,3 +101,12 @@ 0.1f32 12E+99_f64 2.f64 // Invalid! + +// Attributes +// ---------- + + #[attribute] + #![top_level_attribute] + #not_an_attribute + + #[macro_use] use this_is_not_an_attribute;