add function that generates lua files

This commit is contained in:
theFox6 2020-02-14 10:38:46 +01:00
parent 4f5c32ecfe
commit c07ab92d9a
Signed by: theFox6
GPG Key ID: C884FE8D3BCE128A
3 changed files with 12 additions and 7 deletions

View File

@ -184,6 +184,7 @@ It returns the generated lua as string.
`vp.tl_venus_string(str)` returns the lua generated from the given string `vp.tl_venus_string(str)` returns the lua generated from the given string
It returns the generated lua as string. It returns the generated lua as string.
## todo ### generating lua files
- perhaps write generated lua files to disk `vp.convert_venus_file(venus_file_in,lua_file_out)` generates a lua file
- perhaps generate venus from lua It's arguments can be relative or absolute paths.
The venus_file_in will be converted to lua and written to lua_file_out.

View File

@ -461,4 +461,11 @@ function parser.dovenus(file)
return ff() return ff()
end end
function parser.convert_venus_file(venus_file_in,lua_file_out)
local s = parser.tl_venus_file(venus_file_in)
local f = io.open(lua_file_out,"w")
f:write(s)
f:close()
end
return parser return parser

View File

@ -1,9 +1,6 @@
local vp = dofile("init.lua") local vp = dofile("init.lua")
local o = "testout/test.lua" local o = "testout/test.lua"
local s = vp.tl_venus_file("test.venus") vp.convert_venus_file("test.venus",o)
local f = io.open(o,"w")
f:write(s)
f:close()
dofile(o) dofile(o)