git @ Cat's Eye Technologies Velo / 3058b33
Looks like things don't quite parse right. EOLs... something. Cat's Eye Technologies 11 years ago
1 changed file(s) with 17 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
2020 end
2121
2222 --[[ =========== AST ========== ]]--
23
24 --[[
25 class AST
26 def eval obj, args
27 # abstract
28 end
29 end
30 ]]--
3123
3224 Script = {}
3325 Script.new = function(exprs)
6153 debug "eval #{self} on #{obj} with #{args}"
6254 local val = expr.eval(obj, args)
6355 local receiver = object.eval(obj, args)
64 debug "setting #{@field} on #{receiver}"
56 debug("setting " .. field .. " on " .. receiver.to_s() .. " to " .. val.to_s())
6557 receiver.set(field, val)
6658 return val
6759 end
610602
611603 --# look up an identifier on this object, or any of its delegates
612604 methods.lookup = function(ident)
613 debug "lookup #{ident} on #{self}"
605 debug("lookup " .. ident .. " on " .. methods.to_s())
614606 result = methods.lookup_impl(ident, {})
615607 debug "lookup result: #{result}"
616608 if result == nil then
617 raise_VeloAttributeNotFound("could not locate '#{ident}' on #{self}")
609 raise_VeloAttributeNotFound("could not locate " .. ident ..
610 " on " .. methods.to_s())
618611 end
619612 if result.class == "VeloMethod" then
620613 debug("binding obtained method " .. result.to_s() .. " to object #{self}")
625618
626619 --# look up an identifier on this object, or any of its delegates
627620 methods.lookup_impl = function(ident, trail)
628 debug "lookup_impl #{ident} on #{self}"
621 debug("lookup_impl " .. ident .. " on " .. methods.to_s())
629622 --[[
630623 if trail.include? methods
631624 debug "we've already seen this object, stopping search"
751744
752745 --[[ ================== MAIN =============== ]]--
753746
747 local ast = false
748 if arg[1] == "--ast" then
749 arg[1] = arg[2]
750 ast = true
751 end
752
754753 text = ""
755754 for line in io.lines(arg[1]) do
756755 text = text .. line
758757
759758 local p = Parser.new(text)
760759 local s = p.script()
761 local o = VeloObject.new('main-script')
762 s.eval(o, {}) -- XXX could pass command-line arguments here...
760 if ast then
761 print(s.to_s())
762 else
763 local o = VeloObject.new('main-script')
764 s.eval(o, {}) -- XXX could pass command-line arguments here...
765 end