converted metalua.lua into a metalua executable script
diff --git a/metalua.lua b/bin/metalua similarity index 94% rename from metalua.lua rename to bin/metalua index eee8e6e..77e0b65 100644 --- a/metalua.lua +++ b/bin/metalua
@@ -1,5 +1,7 @@ -------------------------------------------------------------------------------- --- Copyright (c) 2006-2013 Fabien Fleutot and others. +#!/usr/bin/env lua51 +--*-lua-*---------------------------------------------------------------------- +-- +-- Copyright (c) 2006-2014 Fabien Fleutot and others. -- -- All rights reserved. -- @@ -88,8 +90,6 @@ local argv = {...} local opts, optind, optarg = alt_getopt.get_ordered_opts({...}, alt_getopt_options, long_opts) - --pp.printf("argv=%s; opts=%s, ending at %i, with optarg=%s", - -- argv, opts, optind, optarg) local s2l = { } -- short to long option names conversion table for long, short in pairs(long_opts) do s2l[short]=long end local cfg = { chunks = { } } @@ -108,7 +108,6 @@ ------------------------------------------------------------------- -- Print messages if in verbose mode - ------------------------------------------------------------------- local function verb_print (fmt, ...) if cfg.verbose then return pp.printf ("[ "..fmt.." ]", ...) @@ -125,7 +124,7 @@ if not next(cfg.chunks) and next(cfg.params) then local the_file = table.remove(cfg.params, 1) verb_print("Param %q considered as a source file", the_file) - cfg.file={ the_file } + cfg.chunks={ { tag='file', the_file } } end ------------------------------------------------------------------- @@ -135,7 +134,6 @@ cfg.interactive=true end - ------------------------------------------------------------------- -- Run if asked to, or if no --output has been given -- if cfg.run==false it's been *forced* to false, don't override. @@ -182,8 +180,8 @@ end -- The last file returns the whole chunk's result if last_file_idx then - -- transform +{ (function(...) -{ast} end)(...) } - -- into +{ return (function(...) -{ast} end)(...) } + -- transform `+{ (function(...) -{ast} end)(...) }` + -- into `+{ return (function(...) -{ast} end)(...) }` local prv_ast = code[last_file_idx] local new_ast = { tag='Return', prv_ast } code[last_file_idx] = new_ast