lib/liquidscript/compiler/icr/literals.rb in liquidscript-0.0.1 vs lib/liquidscript/compiler/icr/literals.rb in liquidscript-0.1.0
- old
+ new
@@ -24,43 +24,35 @@
def compile_sstring
code :sstring, pop.value[1..-1]
end
+ def compile_operator
+ code :operator, shift(:operator), compile_vexpression
+ end
+
def compile_keyword
- code :keyword, shift(:keyword), compile_expression
+ code :keyword, shift(:keyword)
end
def compile_object
shift :lbrack
- objects = []
- compile_object = action do
- objects << [compile_object_key, compile_expression]
+ objects = collect_compiles :rbrack,
+ :comma => action.shift do
+ [compile_object_key, compile_vexpression]
end
- loop do
- expect :rbrack => action.end_loop,
- :comma => action.shift,
- [:identifier, :dstring] => compile_object
- end
-
code :object, objects
end
def compile_array
shift :lbrace
- parts = []
- compile_part = action { parts << compile_expression }
+ parts = collect_compiles(:vexpression, :rbrace,
+ :comma => action.shift)
- loop do
- expect :rbrace => action.end_loop,
- :comma => action.shift,
- :_ => compile_part
- end
-
code :array, parts
end
def compile_object_key
key = shift :identifier, :dstring
@@ -71,20 +63,20 @@
def compile_function
compile_function_with_parameters([])
end
- def compile_function_with_parameters(parameter)
+ 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] = parameter
+ expressions[:arguments] = parameters
@set << expressions
- parameter.each do |parameter|
+ parameters.each do |parameter|
set(parameter).parameter!
end
expression = action do