Skip to content

6. Compile flags

Felice D'Angelo edited this page May 24, 2023 · 2 revisions

These flags can be toggled when compiling, most of the flags alter the output, but some have different uses:

--bitwise

Changes the way bitwise operators are compiled, cen be 3 different modes:

  1. Clue: Assumes the outputted Lua implementation uses the same operators as Clue, and leaves them as is.
  2. library: Automatically adds local bit = require("bit") in every file that uses bitwise operators, and then converts the operators into function calls.
  3. vanilla: For Lua 5.3 and 5.4 (or any implementation derived from them), works similarly to Clue mode, but converts XORs (^^) to ~.

--base

Short version: -b Uses a custom file as the base for the output of the compiled directory.
This file can be any Lua file that should have:

  • local _modules = {§}: where the output of all files will be located.
  • --STATICS: where the static variables will be located.

Note: the base file is only used when a directory is compiled.

--continue

Short version: -c
This flag has three modes to choose from:

  1. Simple: This mode uses the native continue keyword and can only be used in implementations which support it.
  2. goto: Clue will use goto continue; and a ::continue:: label when compiling continue keywords instead of assuming the version of Lua you're compiling to has a proper continue keyword. This will work with most versions of Lua.
  3. Moonscript: This approach is guaranteed to work with any version of Lua although it has a performance impact because it uses a loop.
  4. LuaJIT: Deprecated, use goto instead,

--debug

Short version: -d

When this flag is enabled Clue will include additional debugging information to the output.
With this additional information, if an error happens the error message will include the line and the original .clue file's name from where the error came, which can ease debugging.

Note: all the additional code added to the output will easily reduce performance, thus this flag should only used when debugging.

--dontsave

Short version: -D

When this flag is enabled Clue will still compile the given Clue code, but it will not save it to the output file (which won't even be created).

This flag can be used combined with --output to quickly test Clue code without saving it to a file.

--execute

Short version: -e When this flag is enabled Clue will execute the compiled code once it finished compiling and display any output it prints in the console.
The Lua interpreter that Clue uses is LuaJIT.

This flag can be combined with --dontsave to test Clue code without saving it.

--expand

Short version: -E When this flag is enabled Clue will print the given files after they have been processed by the preprocessor.

--help

Short version: -h

When this flag is enabled Clue will not start compiling and will instead print a message with general information on how to use Clue.

--jitbit (DEPRECATED)

Short version: -j

Note: this flag is deprecated, use --bitwise instead.

When this flag is enabled Clue will assume the version of Lua you're compiling to is LuaJIT and will use the bit library for bitwise operations.

When enabling this flag you also have to choose the name of the variable that will store the bit library (example: --jitbit=bit will name the variable bit).

--output

When this flag is enabled, after compiling a file, Clue will print the output in the console.

This flag can be used combined with --dontsave to quickly test Clue code without saving it to a file.

--pathiscode

Short version: -p

When this flag is enabled Clue will not treat the given path as a path but as Clue code directly.

This can be used to quickly test Clue code.

--rawsetglobals

Short version: -r

When this flag is enabled Clue will use Lua's rawset function when compiling globals

This flag can be helpful when the version of Lua you're compiling to does not allow globals without rawset.

--struct

When this flag is enabled Clue will print the syntax structure/tree after parsing the file.

--tokens

When this flag is enabled Clue will print the list of tokens after scanning.

--version

Short version: -V

When this flag is enabled Clue will not start compiling and will instead print the version of Clue you're using.

--license

Short version: -L

When this flag is enabled Clue will not start compiling and will instead print Clue's license information.