Class: Tracksperanto::ShakeGrammar::Catcher

Inherits:
Lexer
  • Object
show all
Defined in:
lib/import/shake_grammar/catcher.rb

Overview

Will replay funcalls through to methods if such methods exist in the public insntance

Direct Known Subclasses

Import::ShakeScript::Traxtractor

Instance Attribute Summary

Attributes inherited from Lexer

#stack

Instance Method Summary collapse

Methods inherited from Lexer

#initialize

Constructor Details

This class inherits a constructor from Tracksperanto::ShakeGrammar::Lexer

Instance Method Details

#push(atom_array) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/import/shake_grammar/catcher.rb', line 5

def push(atom_array)
  atom_name = atom_array[0]
  if atom_name == :funcall
    func, funcargs = atom_array[1], atom_array[2..-1]
    meth_for_shake_func = func.downcase
    if can_handle_meth?(meth_for_shake_func)
      super([:retval, exec_funcall(meth_for_shake_func, funcargs)])
    else
      # This is a funcall we cannot perform, replace the return result of the funcall
      # with a token to signify that some unknown function's result would have been here
      super(:unknown_func)
    end
  elsif atom_name == :comment
    # Skip comments
  else
    super
  end
end