module AdLint::Cc1::Scanner
DESCRIPTION¶ ↑
Utility module for scanning the C source code.
Constants
- FLOATING1_RE
- FLOATING2_RE
- KEYWORDS_RE
- PUNCTUATORS_RE
Public Instance Methods
scan_char_constant(cont)
click to toggle source
DESCRIPTION¶ ↑
Scans C character constant.
PARAMETER¶ ↑
- cont
-
StringContent
– Scanning source.
RETURN VALUE¶ ↑
String
– Returns C character constant string if found at head of the content.
# File lib/adlint/cc1/scanner.rb, line 187 def scan_char_constant(cont) unless scanned = cont.scan(/L?'/i) return nil end until cont.empty? if str = cont.scan(/.*?(?=\\|')/m) scanned << str end next if cont.scan(/\\[ \t]*\n/) case when cont.check(/\\/) scanned << cont.eat!(2) when quote = cont.scan(/'/) scanned << quote break end end scanned end
scan_floating_constant(cont)
click to toggle source
DESCRIPTION¶ ↑
Scans C floating constant.
PARAMETER¶ ↑
- cont
-
StringContent
– Scanning source.
RETURN VALUE¶ ↑
String
– Returns C floating constant string if found at head of the content.
# File lib/adlint/cc1/scanner.rb, line 174 def scan_floating_constant(cont) cont.scan(FLOATING1_RE) || cont.scan(FLOATING2_RE) end
scan_identifier(cont)
click to toggle source
scan_integer_constant(cont)
click to toggle source
DESCRIPTION¶ ↑
Scans C integer constant.
PARAMETER¶ ↑
- cont
-
StringContent
– Scanning source.
RETURN VALUE¶ ↑
String
– Returns C integer constant string if found at head of the content.
# File lib/adlint/cc1/scanner.rb, line 157 def scan_integer_constant(cont) cont.scan(/(?:0x[0-9a-f]*|0b[01]*|[0-9]+)[UL]*/i) end
scan_keyword(cont)
click to toggle source
scan_null_constant(cont)
click to toggle source
scan_punctuator(cont)
click to toggle source
scan_string_literal(cont)
click to toggle source
DESCRIPTION¶ ↑
Scans C string literal.
PARAMETER¶ ↑
- cont
-
StringContent
– Scanning source.
RETURN VALUE¶ ↑
String
– Returns C string literal string if found at head of the content.
# File lib/adlint/cc1/scanner.rb, line 219 def scan_string_literal(cont) unless scanned = cont.scan(/L?"/i) return nil end until cont.empty? if str = cont.scan(/.*?(?=\\|")/m) scanned << str end next if cont.scan(/\\[ \t]*\n/) case when cont.check(/\\/) scanned << cont.eat!(2) when quote = cont.scan(/"/) scanned << quote break end end scanned end