argv_parser.h#
Command-line arguments parser.
Authors#
TheSilvered
Structs#
Nst_CLArgs#
Synopsis:
typedef struct _Nst_CLArgs {
bool print_tokens, print_ast, print_instructions, print_bytecode;
bool force_execution;
bool no_default;
u8 opt_level;
Nst_EncodingID encoding;
i32 args_start;
i32 argc;
char **argv;
char *command, *filename;
} Nst_CLArgs
Description:
A structure representing the command-line arguments of Nest.
Note
command and filename cannot both be set.
Fields:
print_tokens: whether the tokens of the program should be printedprint_ast: whether the AST of the program should be printedprint_instructions: whether the instructions of the program should be printedprint_bytecode: whether the bytecode of the program should be printedforce_execution: whether to execute the program whenprint_tokens,print_astorprint_bytecodeare trueencoding: the encoding of the file to open, ignored if it is passed through the commandno_default: whether to initialize the program with default variables such astrue,false,Int,Stretc...opt_level: the optimization level of the program 0 through 3command: the code to execute passed as a command line argumentfilename: the file to executeargs_start: the index where the arguments for the Nest program start
Functions#
Nst_cl_args_init#
Synopsis:
void Nst_cl_args_init(Nst_CLArgs *args, int argc, char **argv)
Description:
Initialize a Nst_CLArgs struct with default
values.
Parameters:
args: the struct to initializeargc: the number of arguments passed to mainargv: the array of arguments passed to main
Nst_cl_args_parse#
Synopsis:
i32 Nst_cl_args_parse(Nst_CLArgs *cl_args)
Description:
Parse command-line arguments.
Parameters:
cl_args: the struct where to put the parsed arguments, it must be initialized withNst_cl_args_init
Returns:
-1 on failure, 0 on success where the program can continue, 1 on success
when the program should stop because an info message was printed.
Nst_supports_color#
Synopsis:
bool Nst_supports_color(void)
Returns:
true if ANSI escapes are supported on the current console and false
otherwise.
_Nst_supports_color_override#
Synopsis:
void _Nst_supports_color_override(bool value)
Description:
Overrides the value returned by
Nst_supports_color.
_Nst_wargv_to_argv#
Synopsis:
bool _Nst_wargv_to_argv(int argc, wchar_t **wargv, char ***argv)
Description:
WINDOWS ONLY Re-encode Unicode (UTF-16) arguments to UTF-8.
Parameters:
argc: the length ofwargvwargv: the arguments givenargv: the pointer where the re-encoded arguments are put
Returns:
true on success and false on failure. No error is set.
_Nst_console_mode_init#
Synopsis:
void _Nst_console_mode_init(void)
Description:
WINDOWS ONLY Initialize the console.