lib/liquidscript/compiler/icr/classes.rb in liquidscript-0.4.1 vs lib/liquidscript/compiler/icr/classes.rb in liquidscript-0.5.0
- old
+ new
@@ -4,14 +4,22 @@
module Classes
def compile_class
shift :class
name = shift :identifier
+ inherit = nil
set name
+ # Inheritance ftw!
+ if peek?(:colon)
+ shift :colon
+ inherit = shift :identifier
+ ref inherit
+ end
+
body = _compile_class_body(false)
- code :class, name, body
+ code :class, name, inherit, body
end
def compile_module
shift :module
name = shift :identifier
@@ -20,11 +28,11 @@
code :module, name, body
end
def _compile_class_body(mod = false)
- shift :lbrack
+ shift :lbrace
components = []
compile_object = action do
components << [
@@ -32,10 +40,10 @@
compile_vexpression
]
end
loop do
- expect :newline, :rbrack => action.end_loop,
+ expect :newline, :rbrace => action.end_loop,
:comma => action.shift,
:module => action { components << compile_module },
:class => action { components << compile_class },
[:identifier, :dstring] => compile_object
end