Class: GrammarTransform Abstract

Inherits:
GrammarPlugin show all
Defined in:
lib/ruby_grammar_builder/grammar_plugin.rb

Overview

This class is abstract.

Subclass and override #pre_transform and/or #post_transform to implement a transformation

Instance Method Summary collapse

Methods inherited from GrammarPlugin

display_options, options

Instance Method Details

#post_transform(grammar_hash) ⇒ Hash

Note:

grammar_hash should not be modified

Performs the transformation on the whole grammar

Parameters:

  • grammar_hash (Hash)

    The entire grammar

Returns:

  • (Hash)

    The transformed grammar



87
88
89
# File 'lib/ruby_grammar_builder/grammar_plugin.rb', line 87

def post_transform(grammar_hash)
    grammar_hash
end

#pre_transform(pattern, options) ⇒ PatternBase, ...

Note:

pattern should not be modified

Preforms the transformation on each pattern

Parameters:

  • pattern (PatternBase, Symbol, Hash)

    the pattern to transform

  • options (Hash)

    hash of any of the option keys provided by self.options. options will only be populated when pattern is a PatternBase

Returns:

  • (PatternBase, Symbol, Hash)

    The transformed pattern. The return type should match the type of pattern



74
75
76
# File 'lib/ruby_grammar_builder/grammar_plugin.rb', line 74

def pre_transform(pattern, options) # rubocop:disable Lint/UnusedMethodArgument
    pattern
end