Sha256: 15d3f437928cb61e2a736bc7f6b92c3747d63c70b480caf1882fb4b55ecf0f52
Contents?: true
Size: 1.58 KB
Versions: 9
Compression:
Stored size: 1.58 KB
Contents
module Liquidscript module Compiler class ICR < Base module Functions def compile_property(prop) shift :prop property = action do |ident| code :property, prop, (ident.value || ident.type) end # Just in case there is a property named 'class' or 'module' v = expect [:identifier, :class, :module] => property v end def compile_access(body) shift :lbrack key = compile_vexpression shift :rbrack v = code :access, body, key v end def compile_call(subject) shift :lparen if subject.type == :identifier ref(subject) end arguments = collect_compiles :expression, :rparen, :comma => action.shift call = code :call, subject, *arguments call end protected def value_expect(v, &default) out = expect \ :lparen => action { compile_call(v) }, :equal => action { compile_assignment(v) }, :prop => action { compile_property(v) }, :lbrack => action { compile_access(v) }, [:binop, :minus, :plus] => action { compile_binop(v) }, :unop => action { |o| code :op, v, o }, :_ => default || action { v } if out != v value_expect(out) else out end end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems