Class: AdLint::Cpp::Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/adlint/cpp/subst.rb

Instance Method Summary collapse

Constructor Details

#initialize(ptn_toks) ⇒ Matcher

Returns a new instance of Matcher.



77
78
79
80
81
# File 'lib/adlint/cpp/subst.rb', line 77

def initialize(ptn_toks)
  @state = OuterTokenMatching.new(self)
  @pattern_tokens = ptn_toks
  @pattern_index  = 0
end

Instance Method Details

#accepted?Boolean

Returns:

  • (Boolean)


108
109
110
# File 'lib/adlint/cpp/subst.rb', line 108

def accepted?
  @state.accepted?
end

#match(toks, idx) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/adlint/cpp/subst.rb', line 93

def match(toks, idx)
  return 0 if head = toks[idx] and head.type == :NEW_LINE

  match_len = 0
  while tok = toks[idx]
    unless tok.type == :NEW_LINE
      @state = @state.process(tok)
      break unless @state.matching?
    end
    match_len += 1
    idx += 1
  end
  match_len
end

#matching?Boolean

Returns:

  • (Boolean)


112
113
114
# File 'lib/adlint/cpp/subst.rb', line 112

def matching?
  @state.matching?
end

#next_pattern_tokenObject



87
88
89
90
91
# File 'lib/adlint/cpp/subst.rb', line 87

def next_pattern_token
  ptn_tok = @pattern_tokens[@pattern_index]
  @pattern_index += 1
  ptn_tok
end

#rejected?Boolean

Returns:

  • (Boolean)


116
117
118
# File 'lib/adlint/cpp/subst.rb', line 116

def rejected?
  @state.rejected?
end

#rest_pattern_tokensObject



83
84
85
# File 'lib/adlint/cpp/subst.rb', line 83

def rest_pattern_tokens
  @pattern_tokens.drop(@pattern_index)
end