diff --git a/Contents/Language Modules/Rust.bblm/Contents/MacOS/Rust b/Contents/Language Modules/Rust.bblm/Contents/MacOS/Rust index bfabfec..3c38c81 100755 Binary files a/Contents/Language Modules/Rust.bblm/Contents/MacOS/Rust and b/Contents/Language Modules/Rust.bblm/Contents/MacOS/Rust differ diff --git a/rust.mm b/rust.mm index eddbfbb..024da9c 100644 --- a/rust.mm +++ b/rust.mm @@ -31,7 +31,7 @@ SInt32 skipString(BBLMTextIterator &iter) { SInt32 length = 1; UniChar ch; - + if (iter.strcmp("\"", 1) == 0) { iter += 1; @@ -63,7 +63,7 @@ SInt32 skipRawString(BBLMTextIterator &iter) { SInt32 length = 4; UniChar ch; - + if (iter.strcmp("r##\"", 4) == 0) { iter += 4; @@ -72,7 +72,7 @@ SInt32 skipRawString(BBLMTextIterator &iter) { return 0; } - + while ((ch = iter.GetNextChar())) { length++; @@ -82,14 +82,14 @@ SInt32 skipRawString(BBLMTextIterator &iter) iter += 3; break; } - + if (ch == '\\') { iter++; length++; } } - + return length; } @@ -198,7 +198,7 @@ SInt32 skipAttribute(BBLMTextIterator &iter) { return 0; } - + while ((ch = iter.GetNextChar())) { if (ch == ']') @@ -276,10 +276,10 @@ SInt32 skipNumber(BBLMTextIterator &iter) else if (ch == 'f' || ch == 'u' || ch == 'i') { length++; - if (ch != 'f' && iter.strcmp("s", 1) == 0) + if (ch != 'f' && iter.strcmp("size", 4) == 0) { - // Parse 'us' or 'is' machine-dependent suffixes - length++; + // Parse 'usize' or 'isize' machine-dependent suffixes + length += 4; } else { @@ -402,7 +402,7 @@ SInt32 scanForSymbol(BBLMTextIterator &iter, iter -= keywordLen + whitespaceLen; return 0; } - + SInt32 start_of_name = iter.Offset(); SInt32 start_of_function; while ((ch = iter.GetNextChar())) @@ -423,7 +423,7 @@ SInt32 scanForSymbol(BBLMTextIterator &iter, break; } } - + iter--; start_of_function = iter.Offset(); break; @@ -442,9 +442,9 @@ SInt32 scanForSymbol(BBLMTextIterator &iter, return 0; } } - + UInt32 funLen = skipToEndOfFunction(iter); - + // Skip over trait method definitions and extern functions if (funLen == 0) { @@ -453,7 +453,7 @@ SInt32 scanForSymbol(BBLMTextIterator &iter, UInt32 tokenOffset, funIndex; UInt32 nameLen; - + iter -= (wordLen + funLen); iter -= (keywordLen + whitespaceLen); @@ -482,7 +482,7 @@ SInt32 scanForSymbol(BBLMTextIterator &iter, // But still allow the user to fold them // (the length changes here are to cut off the opening { and closing } from the fold range bblmAddFoldRange(callbacks, start_of_function + 1, funLen - 2, kBBLMFunctionAutoFold); - + iter += (keywordLen + whitespaceLen); return info.fFunctionEnd; } @@ -610,13 +610,13 @@ OSErr calculateRuns(BBLMParamBlock ¶ms, const BBLMCallbackBlock *callbacks) if (!makeCodeRun(iter, runStart, *callbacks)) return noErr; runStart = iter.Offset(); runLen = skipRawString(iter); - + // Use the heredoc colour to highlight raw strings. // It's not exactly a heredoc, but it's the closest! if (!addRun(kBBLMHereDocStringRunKind, runStart, runLen, *callbacks)) return noErr; runStart = iter.Offset(); } - + else if (ch == '"') { iter--; @@ -807,18 +807,18 @@ OSErr calculateRuns(BBLMParamBlock ¶ms, const BBLMCallbackBlock *callbacks) { break; } - + if (iter.strcmp(" as ", 4) == 0) { if (!addRun(kBBLMFileIncludeRunKind, runStart, runLen, *callbacks)) return noErr; runStart = iter.Offset(); iter += 4; if (!addRun(kBBLMCodeRunKind, runStart, 4, *callbacks)) return noErr; - + runStart = iter.Offset(); runLen = skipWord(iter); if (!addRun(moduleColour, runStart, runLen, *callbacks)) return noErr; - + iter++; runLen = 0; break; @@ -882,7 +882,7 @@ OSErr calculateRuns(BBLMParamBlock ¶ms, const BBLMCallbackBlock *callbacks) if (!addRun(kBBLMPreprocessorRunKind, runStart, runLen, *callbacks)) return noErr; runStart = iter.Offset(); } - + else if (ch == '$') { iter--; diff --git a/smoke.rs b/smoke.rs index 4667b2d..a58f5e3 100644 --- a/smoke.rs +++ b/smoke.rs @@ -94,13 +94,14 @@ 123i32, 123u32 // numbers can have literals 123_u32, 0xff_u8 0o70_i16, 0b1111_1111_1001_0000_i32 - 0us, 7is + 0usize, 7isize 123.0f64 0.1f64 0.1f32 12E+99_f64 - 2.f64 // Invalid! + 0us, 7is // Invalid! + 2.f64 // Also invalid! // Attributes // ----------