Lua and lpeg

Jun 6, 2009
19
0
I was very happy when Lua support was added to TC. On a whim I compiled a Lua addon (lpeg) and placed the resulting dll into the TC folder. To my pleasant surprise this worked and I can now run all of my Lua scripts that require the lpeg addon.

I have two questions:

1. Does TC's support for Lua work because Lua was embedded into the TC run time. Apologies if I am not using these programming terms correctly.

2. Why does dropping lpeg.dll into the TC directory work. That is, why can I now run any script that requires lpeg work?

thanks
rick
 
Aug 23, 2010
589
7
1. From help file:
Lua support

Lua is a powerful, fast, lightweight, embeddable scripting language. TCC includes internal support for Lua, both for executing Lua scripts and for executing individual Lua expressions. The version supplied with TCC is Lua 5.3. For more information on Lua, go to The Programming Language Lua.

You must enable Lua support in the OPTION / Startup page. If it is enabled, TCC will automatically load LUA.DLL on your system. TCC checks to see if you are running a .LUA file. If so, TCC passes the file to the Lua interpreter for processing.
For p.2, that's because you told it to do so.
`require "lpeg"` will look for appropriate .lua script in LUA_PATH (or `package.path`) or a DLL in LUA_CPATH (or in `package.cpath`). I suppose `package.cpath` equals to TCC installation directory by default.

See f.e. how to use / include lpeg luapeg re module answer.