Module: Liquidscript::Compiler::ICR::Functions

Included in:
Liquidscript::Compiler::ICR
Defined in:
lib/liquidscript/compiler/icr/functions.rb

Instance Method Summary collapse

Instance Method Details

#compile_call(subject) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/liquidscript/compiler/icr/functions.rb', line 22

def compile_call(subject)
  shift :lparen

  arguments = collect_compiles :expression, :rparen,
    :comma => action.shift

  code :call, subject, *arguments
end

#compile_property(prop) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/liquidscript/compiler/icr/functions.rb', line 6

def compile_property(prop)
  shift :prop

  property = action do |ident|
    code :property, prop, ident
  end

  # Just in case there is a property named 'class' or 'module'
  code = expect [:identifier, :class, :module] => property

  expect :lparen => action { compile_call(code)       },
         :equal  => action { compile_assignment(code) },
         :prop   => action { compile_property(code)   },
         :_      => action { code                     }
end