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::TrackExtractor

Defined Under Namespace

Classes: At

Constant Summary

Constants inherited from Lexer

Lexer::MAX_BUFFER_SIZE, Lexer::MAX_STACK_DEPTH, Lexer::STOP_TOKEN

Instance Attribute Summary

Attributes inherited from Lexer

#sentinel, #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) ⇒ Object


20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/import/shake_grammar/catcher.rb', line 20

def push(atom)
  
  # Send everything but funcalls to parent
  return super unless atom.is_a?(Array) && atom[0] == :funcall
  
  meth_for_shake_func, args = atom[1].downcase, atom[2..-1]
  if can_handle_meth?(meth_for_shake_func)
    super([:retval, exec_funcall(meth_for_shake_func, args)])
  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
end