lgen.lua

changeset 7
038275cd92ed
parent 5
7667b101cb1e
child 9
751216807683
equal deleted inserted replaced
6:219d7a7304f8 7:038275cd92ed
1 1
2 module('lgen', package.seeall) 2 local path=string.gsub(arg[0], "(.*)/[^/]*", "%1");
3 -- export src dst hierarchy 3 if path~=nil then
4 package.path=package.path .. ';' .. path .. '/?.lua'
5 end
4 6
5 -- Lua 5.1 setfenv/getfenv compatibility for Lua 5.2 7 -- Lua 5.1 setfenv/getfenv compatibility for Lua 5.2
6 local CE = require('compat_env') 8 local CE = require('compat_env')
7 _G.setfenv = CE.setfenv 9 _G.setfenv = CE.setfenv
8 _G.getfenv = CE.getfenv 10 _G.getfenv = CE.getfenv
9 11
10 require('scan') 12 local scan=require('scan')
11 require('handlers') 13 local handlers=require('handlers')
12 -- globally add missing stuff 14 -- globally add missing stuff
13 require('luaext') 15 local luaext=require('luaext')
16 local lfs=require('lfs')
17 local path=require('path')
14 18
15 -- 19 --
16 -- Main 20 -- Main
17 -- 21 --
18 22
19 if #arg < 3 then 23 if #arg < 3 then
20 error("Usage: lgen src tmpl dst") 24 error("Usage: lgen src tmpl dst")
21 end 25 end
22 26
23 src = arg[1] 27 local src = arg[1]
24 tmpl = arg[2] 28 local tmpl = arg[2]
25 dst = arg[3] 29 local dst = arg[3]
26 30
27 print('Scan...') 31 print('Scan...')
28 hierarchy = scan.scan(src) 32
33 local hierarchy = scan.scan(src)
29 34
30 35
31 local env={ 36 local env={
32 paths={ 37 paths={
33 src=src, 38 src=src,

mercurial