Looks like things don't quite parse right. EOLs... something.
Cat's Eye Technologies
11 years ago
20 | 20 | end |
21 | 21 | |
22 | 22 | --[[ =========== AST ========== ]]-- |
23 | ||
24 | --[[ | |
25 | class AST | |
26 | def eval obj, args | |
27 | # abstract | |
28 | end | |
29 | end | |
30 | ]]-- | |
31 | 23 | |
32 | 24 | Script = {} |
33 | 25 | Script.new = function(exprs) |
61 | 53 | debug "eval #{self} on #{obj} with #{args}" |
62 | 54 | local val = expr.eval(obj, args) |
63 | 55 | local receiver = object.eval(obj, args) |
64 | debug "setting #{@field} on #{receiver}" | |
56 | debug("setting " .. field .. " on " .. receiver.to_s() .. " to " .. val.to_s()) | |
65 | 57 | receiver.set(field, val) |
66 | 58 | return val |
67 | 59 | end |
610 | 602 | |
611 | 603 | --# look up an identifier on this object, or any of its delegates |
612 | 604 | methods.lookup = function(ident) |
613 | debug "lookup #{ident} on #{self}" | |
605 | debug("lookup " .. ident .. " on " .. methods.to_s()) | |
614 | 606 | result = methods.lookup_impl(ident, {}) |
615 | 607 | debug "lookup result: #{result}" |
616 | 608 | 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()) | |
618 | 611 | end |
619 | 612 | if result.class == "VeloMethod" then |
620 | 613 | debug("binding obtained method " .. result.to_s() .. " to object #{self}") |
625 | 618 | |
626 | 619 | --# look up an identifier on this object, or any of its delegates |
627 | 620 | methods.lookup_impl = function(ident, trail) |
628 | debug "lookup_impl #{ident} on #{self}" | |
621 | debug("lookup_impl " .. ident .. " on " .. methods.to_s()) | |
629 | 622 | --[[ |
630 | 623 | if trail.include? methods |
631 | 624 | debug "we've already seen this object, stopping search" |
751 | 744 | |
752 | 745 | --[[ ================== MAIN =============== ]]-- |
753 | 746 | |
747 | local ast = false | |
748 | if arg[1] == "--ast" then | |
749 | arg[1] = arg[2] | |
750 | ast = true | |
751 | end | |
752 | ||
754 | 753 | text = "" |
755 | 754 | for line in io.lines(arg[1]) do |
756 | 755 | text = text .. line |
758 | 757 | |
759 | 758 | local p = Parser.new(text) |
760 | 759 | 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 |