Module: AdLint::Cpp::Scanner

Included in:
Language::Cpp
Defined in:
lib/adlint/cpp/scanner.rb

Overview

DESCRIPTION

Utility module for scanning the C preprocessor language code.

Instance Method Summary collapse

Instance Method Details

#scan_keyword(cont) ⇒ Object

DESCRIPTION

Scans CPP keyword.

PARAMETER

cont

StringContent – Scanning source.

RETURN VALUE

String – Returns CPP keyword string if found at head of the content.



46
47
48
# File 'lib/adlint/cpp/scanner.rb', line 46

def scan_keyword(cont)
  cont.scan(/defined\b/)
end

#scan_punctuator(cont) ⇒ Object

DESCRIPTION

Scans CPP punctuator.

PARAMETER

cont

StringContent – Scanning source.

RETURN VALUE

String – Returns CPP punctuator string if found at head of the content.



58
59
60
# File 'lib/adlint/cpp/scanner.rb', line 58

def scan_punctuator(cont)
  Language::C.scan_punctuator(cont) or cont.scan(/##?/)
end

#scan_system_header_name(cont) ⇒ Object

DESCRIPTION

Scans CPP system header name.

PARAMETER

cont

StringContent – Scanning source.

RETURN VALUE

String – Returns CPP system header name string if found at head of the content.



84
85
86
# File 'lib/adlint/cpp/scanner.rb', line 84

def scan_system_header_name(cont)
  cont.scan(/<[^>]*>/)
end

#scan_user_header_name(cont) ⇒ Object

DESCRIPTION

Scans CPP user header name.

PARAMETER

cont

StringContent – Scanning source.

RETURN VALUE

String – Returns CPP user header name string if found at head of the content.



71
72
73
# File 'lib/adlint/cpp/scanner.rb', line 71

def scan_user_header_name(cont)
  cont.scan(/"[^"]*"/)
end