class AdLint::Cpp::PPTokens
Constants
- PUNCTUATORS
Attributes
tokens[R]
Public Class Methods
new()
click to toggle source
Calls superclass method
# File lib/adlint/cpp/syntax.rb, line 572 def initialize super @tokens = [] end
Public Instance Methods
inspect(indent = 0)
click to toggle source
# File lib/adlint/cpp/syntax.rb, line 704 def inspect(indent = 0) " " * indent + self.to_s end
location()
click to toggle source
# File lib/adlint/cpp/syntax.rb, line 584 def location @tokens.first.location end
may_represent_block?()
click to toggle source
# File lib/adlint/cpp/syntax.rb, line 628 def may_represent_block? return false if @tokens.size < 2 if @tokens.first.value == "{" && @tokens.last.value == "}" @tokens.any? { |pp_tok| pp_tok.value == ";" } else false end end
may_represent_controlling_keyword?()
click to toggle source
# File lib/adlint/cpp/syntax.rb, line 688 def may_represent_controlling_keyword? return false if @tokens.size > 1 case @tokens.first.value when "while", "do", "for", "if", "else", "switch", "case", "default", "goto", "return", "break", "continue" true else false end end
may_represent_declaration_specifiers_head?()
click to toggle source
# File lib/adlint/cpp/syntax.rb, line 662 def may_represent_declaration_specifiers_head? @tokens.all? do |pp_tok| case pp_tok.value when "typedef", "extern", "static", "auto", "register" true when "const", "volatile", "restrict" true else false end end end
may_represent_do_while_zero_idiom?()
click to toggle source
# File lib/adlint/cpp/syntax.rb, line 638 def may_represent_do_while_zero_idiom? return false if @tokens.size < 4 @tokens[0].value == "do" && @tokens[-4].value == "while" && @tokens[-3].value == "(" && @tokens[-2].value == "0" && @tokens[-1].value == ")" end
may_represent_expression?()
click to toggle source
# File lib/adlint/cpp/syntax.rb, line 588 def may_represent_expression? return false if @tokens.size < 2 @tokens.all? do |pp_tok| case pp_tok.value when "{", "}" false when ";" false when "while", "do", "for", "if", "else", "switch", "case", "default", "goto", "return", "break", "continue" false when "typedef", "extern", "static", "auto", "regisiter" false else true end end end
may_represent_initializer?()
click to toggle source
# File lib/adlint/cpp/syntax.rb, line 608 def may_represent_initializer? return false if @tokens.size < 2 if @tokens.first.value == "{" && @tokens.last.value == "}" @tokens.all? do |pp_tok| case pp_tok.value when "while", "do", "for", "if", "else", "switch", "case", "default", "goto", "return", "break", "continue" false when ";" false else true end end else false end end
may_represent_punctuator?()
click to toggle source
# File lib/adlint/cpp/syntax.rb, line 684 def may_represent_punctuator? @tokens.size == 1 && PUNCTUATORS.include?(@tokens.first.value) end
may_represent_specifier_qualifier_list?()
click to toggle source
# File lib/adlint/cpp/syntax.rb, line 646 def may_represent_specifier_qualifier_list? @tokens.select { |pp_tok| case pp_tok.value when "const", "volatile", "restrict" true when "*" true when "void", "signed", "unsigned", "char", "short", "int", "long", "float", "double" true else false end }.size > 1 end
push(tok)
click to toggle source
# File lib/adlint/cpp/syntax.rb, line 579 def push(tok) @tokens.push(tok) self end
to_s()
click to toggle source
# File lib/adlint/cpp/syntax.rb, line 700 def to_s @tokens.map { |tok| tok.value }.join(" ") end