Module: Liquidscript::Compiler::ICR::Literals
- Included in:
- Liquidscript::Compiler::ICR
- Defined in:
- lib/liquidscript/compiler/icr/literals.rb
Instance Method Summary collapse
- #compile_array ⇒ Object
- #compile_dstring ⇒ Object
- #compile_function ⇒ Object
- #compile_function_with_parameters(parameters) ⇒ Object
- #compile_identifier(identifier) ⇒ Object
- #compile_keyword ⇒ Object
- #compile_number ⇒ Object
- #compile_object ⇒ Object
- #compile_object_key ⇒ Object
- #compile_operator ⇒ Object
- #compile_sstring ⇒ Object
Instance Method Details
#compile_array ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/liquidscript/compiler/icr/literals.rb', line 48 def compile_array shift :lbrace parts = collect_compiles(:vexpression, :rbrace, :comma => action.shift) code :array, parts end |
#compile_dstring ⇒ Object
21 22 23 |
# File 'lib/liquidscript/compiler/icr/literals.rb', line 21 def compile_dstring code :dstring, pop.value[1..-2] end |
#compile_function ⇒ Object
64 65 66 |
# File 'lib/liquidscript/compiler/icr/literals.rb', line 64 def compile_function compile_function_with_parameters([]) end |
#compile_function_with_parameters(parameters) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/liquidscript/compiler/icr/literals.rb', line 68 def compile_function_with_parameters(parameters) shift :arrow shift :lbrack expressions = Liquidscript::ICR::Set.new expressions.context = Liquidscript::ICR::Context.new expressions.context.parent = top.context expressions[:arguments] = parameters @set << expressions parameters.each do |parameter| set(parameter).parameter! end expression = action do expressions << compile_expression end loop do expect :rbrack => action.end_loop, :_ => expression end code :function, @set.pop end |
#compile_identifier(identifier) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/liquidscript/compiler/icr/literals.rb', line 10 def compile_identifier(identifier) default = action do code :get, ref(identifier) end expect :equal => action { compile_assignment(identifier) }, :prop => action { compile_property(identifier) }, :lparen => action { compile_call(identifier) }, :_ => default end |
#compile_keyword ⇒ Object
33 34 35 |
# File 'lib/liquidscript/compiler/icr/literals.rb', line 33 def compile_keyword code :keyword, shift(:keyword) end |
#compile_number ⇒ Object
6 7 8 |
# File 'lib/liquidscript/compiler/icr/literals.rb', line 6 def compile_number code :number, pop.value end |
#compile_object ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/liquidscript/compiler/icr/literals.rb', line 37 def compile_object shift :lbrack objects = collect_compiles :rbrack, :comma => action.shift do [compile_object_key, compile_vexpression] end code :object, objects end |
#compile_object_key ⇒ Object
57 58 59 60 61 62 |
# File 'lib/liquidscript/compiler/icr/literals.rb', line 57 def compile_object_key key = shift :identifier, :dstring shift :colon key end |
#compile_operator ⇒ Object
29 30 31 |
# File 'lib/liquidscript/compiler/icr/literals.rb', line 29 def compile_operator code :operator, shift(:operator), compile_vexpression end |
#compile_sstring ⇒ Object
25 26 27 |
# File 'lib/liquidscript/compiler/icr/literals.rb', line 25 def compile_sstring code :sstring, pop.value[1..-1] end |