From c07ab92d9aa4bb50ec2881139624efa5ec6bd7bd Mon Sep 17 00:00:00 2001 From: theFox6 Date: Fri, 14 Feb 2020 10:38:46 +0100 Subject: [PATCH] add function that generates lua files --- README.md | 7 ++++--- init.lua | 7 +++++++ translateTest.lua | 5 +---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 85c4e33..5ee1d1b 100644 --- a/README.md +++ b/README.md @@ -184,6 +184,7 @@ It returns the generated lua as string. `vp.tl_venus_string(str)` returns the lua generated from the given string It returns the generated lua as string. -## todo -- perhaps write generated lua files to disk -- perhaps generate venus from lua +### generating lua files +`vp.convert_venus_file(venus_file_in,lua_file_out)` generates a lua file +It's arguments can be relative or absolute paths. +The venus_file_in will be converted to lua and written to lua_file_out. diff --git a/init.lua b/init.lua index 6ad9380..a5b3840 100644 --- a/init.lua +++ b/init.lua @@ -461,4 +461,11 @@ function parser.dovenus(file) return ff() 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 diff --git a/translateTest.lua b/translateTest.lua index fb4494c..a3f826a 100644 --- a/translateTest.lua +++ b/translateTest.lua @@ -1,9 +1,6 @@ local vp = dofile("init.lua") local o = "testout/test.lua" -local s = vp.tl_venus_file("test.venus") -local f = io.open(o,"w") -f:write(s) -f:close() +vp.convert_venus_file("test.venus",o) dofile(o)