Class: Rouge::Lexers::Rust

Inherits:
RegexLexer show all
Defined in:
lib/rouge/lexers/rust.rb

Constant Summary

Constants inherited from RegexLexer

RegexLexer::MAX_NULL_SCANS

Constants included from Token::Tokens

Token::Tokens::Num, Token::Tokens::Str

Instance Attribute Summary

Attributes inherited from Rouge::Lexer

#options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from RegexLexer

append, #delegate, get_state, #get_state, #goto, #group, #groups, #in_state?, #pop!, prepend, #push, #recurse, replace_state, #reset!, #reset_stack, #stack, start, start_procs, state, #state, #state?, state_definitions, states, #step, #stream_tokens, #token

Methods inherited from Rouge::Lexer

aliases, all, #as_bool, #as_lexer, #as_list, #as_string, #as_token, assert_utf8!, #bool_option, debug_enabled?, demo, demo_file, desc, disable_debug!, enable_debug!, filenames, find, find_fancy, guess, guess_by_filename, guess_by_mimetype, guess_by_source, guesses, #hash_option, #initialize, lex, #lex, #lexer_option, #list_option, mimetypes, option, option_docs, #reset!, #stream_tokens, #string_option, #tag, tag, title, #token_option

Methods included from Token::Tokens

token

Constructor Details

This class inherits a constructor from Rouge::Lexer

Class Method Details

.analyze_text(text) ⇒ Object


13
14
15
# File 'lib/rouge/lexers/rust.rb', line 13

def self.analyze_text(text)
  return 1 if text.shebang? 'rustc'
end

.builtinsObject


26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rouge/lexers/rust.rb', line 26

def self.builtins
  @builtins ||= Set.new %w(
    Add BitAnd BitOr BitXor bool c_char c_double c_float char
    c_int clock_t c_long c_longlong Cons Const Copy c_schar c_short
    c_uchar c_uint c_ulong c_ulonglong c_ushort c_void dev_t DIR
    dirent Div Either Eq Err f32 f64 Failure FILE float fpos_t
    i16 i32 i64 i8 isize Index ino_t int intptr_t Left mode_t Modulo Mul
    Neg Nil None Num off_t Ok Option Ord Owned pid_t Ptr ptrdiff_t
    Right Send Shl Shr size_t Some ssize_t str Sub Success time_t
    u16 u32 u64 u8 usize uint uintptr_t
    Box Vec String Gc Rc Arc
  )
end

.keywordsObject


17
18
19
20
21
22
23
24
# File 'lib/rouge/lexers/rust.rb', line 17

def self.keywords
  @keywords ||= %w(
    as assert break const copy do drop else enum extern fail false
    fn for if impl let log loop match mod move mut priv pub pure
    ref return self static struct true trait type unsafe use while
    box
  )
end

Instance Method Details

#macro_closed?Boolean

Returns:

  • (Boolean)

40
41
42
# File 'lib/rouge/lexers/rust.rb', line 40

def macro_closed?
  @macro_delims.values.all?(&:zero?)
end