Rust: Add keywords & bytes, fix identifiers, and other improvements/fixes

Authored by nibags on Jun 12 2018, 7:47 PM.

Description

Rust: Add keywords & bytes, fix identifiers, and other improvements/fixes

Summary:
Changes:

NOTE: The POSIX character class [[::ascii::]] is used. I don't know from which version of KTextEditor (or Qt) the use of POSIX character class is available, or if the use of this is a correct way. It works well, but if it isn't the correct way to do it, I can change it without any problem.

  • Improved and fixes in the highlighting of numbers:
    • Add missing integer suffixes (i128, u128, isize, usize).
    • Add word border (\b) in numbers (Hex, Octal, Binary, Float, Decimal).
    • Improves float detection; floats with suffix 'f' are not allowed (only 'f32' & 'f64').
    • Highlight as 'Error' invalid numbers (Hexadecimal, Octal, Binary).
  • Fix Raw Hashed Strings (r##"text"##). Before, only a maximum of 2 hashes are detected (this is mentioned in a comment). Now any number of #'s are allowed.
  • Add byte characters & byte strings (b'X', b"XX", br"XX", br#"XX"#).
  • Improves character detection and escape characters:
    • Highlight as 'Error' invalid characters.
    • Fixes unicode escapes: only the \u{NNNNNN} type is allowed (Not \uNNNN or \UNNNNNNNN).

NOTES:

  • The style of the itemData 'Scope' is changed from 'dsNormal' to 'dsProcessador', since the detection of identifiers was corrected.

I also added a test file. Any inconvenience or if I need to correct something, do not hesitate to notify!

Sources:

Test Plan: I checked the modifications with the documentation and the compiler of Rust to avoid regressions.

Reviewers: dhaumann, cullmann

Reviewed By: dhaumann

Subscribers: kde-frameworks-devel

Tags: Frameworks, Framework: Syntax Highlighting

Differential Revision: https://phabricator.kde.org/D13498

Details