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



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/liquidscript/compiler/icr/functions.rb', line 27

def compile_call(subject)
  shift :lparen
  arguments = []

  loop do
    expect :comma  => action.shift,
           :rparen => action.end_loop,
           :_      => action { arguments << compile_expression }
  end

  code :call, subject, *arguments
end

#compile_property(prop) ⇒ Object



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

def compile_property(prop)
  shift :prop

  ref = if prop.type == :identifier
    ref(prop)
  else
    prop
  end

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

  code = expect :identifier => property

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