argv_parser.h
#
Command-line arguments parser.
Authors#
TheSilvered
Structs#
Nst_CLArgs
#
Synopsis:
typedef struct _Nst_CLArgs {
bool print_tokens, print_ast, print_bytecode;
bool force_execution;
Nst_CPID encoding;
bool no_default;
i32 opt_level;
i8 *command, *filename;
i32 args_start;
} 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_bytecode
: whether the bytecode of the program should be printedforce_execution
: whether to execute the program whenprint_tokens
,print_ast
orprint_bytecode
are 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
,Str
etc...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_parse_args
#
Synopsis:
i32 _Nst_parse_args(i32 argc, i8 **argv, Nst_CLArgs *cl_args)
Description:
Parses command-line arguments.
Parameters:
argc
: length ofargv
argv
: the command-line arguments arraycl_args
: the struct where to put the parsed arguments
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_wargv_to_argv
#
Synopsis:
bool _Nst_wargv_to_argv(int argc, wchar_t **wargv, i8 ***argv)
Description:
WINDOWS ONLY Re-encodes Unicode arguments to UTF-8.
Parameters:
argc
: the length ofwargv
wargv
: the arguments givenargv
: the pointer where the re-encoded arguments are put
Returns:
true
on success and false
on failure.
_Nst_set_console_mode
#
Synopsis:
void _Nst_set_console_mode(void)
Description:
WINDOWS ONLY Initializes the console.