Class: AdLint::Cpp::Matcher
- Inherits:
-
Object
- Object
- AdLint::Cpp::Matcher
- Defined in:
- lib/adlint/cpp/subst.rb
Instance Method Summary collapse
- #accepted? ⇒ Boolean
-
#initialize(ptn_toks) ⇒ Matcher
constructor
A new instance of Matcher.
- #match(toks, idx) ⇒ Object
- #matching? ⇒ Boolean
- #next_pattern_token ⇒ Object
- #rejected? ⇒ Boolean
- #rest_pattern_tokens ⇒ Object
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
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
112 113 114 |
# File 'lib/adlint/cpp/subst.rb', line 112 def matching? @state.matching? end |
#next_pattern_token ⇒ Object
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
116 117 118 |
# File 'lib/adlint/cpp/subst.rb', line 116 def rejected? @state.rejected? end |
#rest_pattern_tokens ⇒ Object
83 84 85 |
# File 'lib/adlint/cpp/subst.rb', line 83 def rest_pattern_tokens @pattern_tokens.drop(@pattern_index) end |