Class: IncludesThenTagAs
- Inherits:
-
GrammarLinter
- Object
- GrammarPlugin
- GrammarLinter
- IncludesThenTagAs
- Defined in:
- lib/ruby_grammar_builder/linters/includes_then_tag_as.rb
Overview
A pattern that has an includes cannot have any tag_as in @match
Instance Method Summary collapse
-
#pre_lint(pattern, options) ⇒ Boolean
Runs the linter on each pattern.
-
#tag_as?(pattern) ⇒ Boolean
Does pattern or any of its children / siblings have a tag_as.
Methods inherited from GrammarLinter
Methods inherited from GrammarPlugin
Instance Method Details
#pre_lint(pattern, options) ⇒ Boolean
Runs the linter on each pattern
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ruby_grammar_builder/linters/includes_then_tag_as.rb', line 30 def pre_lint(pattern, ) return true unless pattern.is_a? PatternBase return true if pattern.is_a? PatternRange return false unless pre_lint(pattern.match, ) return true unless pattern.arguments[:includes].is_a? Array return true unless tag_as?(pattern.match) name = pattern.name puts "The pattern `#{name}' has both an includes argument and a match argument that," puts "it or a sub pattern has a tag_as argument." puts "this is not supported" true # TODO: fix issue end |
#tag_as?(pattern) ⇒ Boolean
Does pattern or any of its children / siblings have a tag_as
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ruby_grammar_builder/linters/includes_then_tag_as.rb', line 16 def tag_as?(pattern) return false unless pattern.is_a? PatternBase pattern.each do |s| puts s.arguments[:tag_as] if s.arguments[:tag_as] return true if s.arguments[:tag_as] end false end |