Purple  0.1
Standard Language Specification
Functions | Variables
arguments.c File Reference

Command line interface logic. More...

#include <stdlib.h>
#include <string.h>
#include "info.h"
#include "utils/arguments.h"
#include "utils/formatting.h"
#include "utils/logging.h"
Include dependency graph for arguments.c:

Functions

error_t parse_opt (int key, char *arg, struct argp_state *state)
 
void parse_args (PurpleArgs *args, int argc, char *argv[])
 Parses command-line arguments via argp. More...
 
void set_opt_level (PurpleArgs *args, int opt_level)
 Set optimization flags based on a given opt level. More...
 
void help_flags ()
 

Variables

const char * argp_program_version = PROJECT_NAME_AND_VERS
 
const char * argp_program_bug_address = "[email protected]"
 
static char doc [] = "The standard compiler for the Purple programming language"
 
static char args_doc [] = "PROGRAM"
 
static struct argp_option options []
 
static struct argp argp = {options, parse_opt, args_doc, doc, 0, 0, 0}
 

Detailed Description

Command line interface logic.

Author
Charles Averill
Date
08-Sep-2022

Function Documentation

◆ help_flags()

void help_flags ( )

◆ parse_args()

void parse_args ( PurpleArgs args,
int  argc,
char *  argv[] 
)

Parses command-line arguments via argp.

◆ parse_opt()

error_t parse_opt ( int  key,
char *  arg,
struct argp_state *  state 
)

◆ set_opt_level()

void set_opt_level ( PurpleArgs args,
int  opt_level 
)

Set optimization flags based on a given opt level.

Parameters
argsPurpleArgs struct to set flags in
opt_levelLevel of optimization to set

Variable Documentation

◆ argp

struct argp argp = {options, parse_opt, args_doc, doc, 0, 0, 0}
static

◆ argp_program_bug_address

const char* argp_program_bug_address = "[email protected]"

◆ argp_program_version

const char* argp_program_version = PROJECT_NAME_AND_VERS

◆ args_doc

char args_doc[] = "PROGRAM"
static

◆ doc

char doc[] = "The standard compiler for the Purple programming language"
static

◆ options

struct argp_option options[]
static
Initial value:
= {
{0, 0, 0, 0, "Informational Options:", 1},
{"logging", 'l', "LEVEL", 0,
"Level of log statements to print (NONE, DEBUG, INFO, WARNING, ERROR, CRITICAL)", 0},
{"quiet", 'q', 0, 0, "Equivalent to --logging=NONE", 0},
{"verbose", 'v', 0, 0, "Equivalent to --logging=DEBUG", 0},
{"help-flags", ARGP_HELP_FLAGS, 0, 0, "Show help information for various flags used in Purple",
0},
{0, 0, 0, 0, "Compiler Options:", 2},
{"clang-executable", 'g', "PATH", 0,
"Alternate path to clang executable (default is \"" DEFAULT_CLANG_EXECUTABLE_PATH "\"", 0},
{"cmd", 'c', "PROGRAM", OPTION_HIDDEN, "Program passed in as a string", 0},
{"llvm-output", ARGP_LLVM_OUTPUT, "FILE", 0, "Path to the generated LLVM file", 0},
{"output", 'o', "FILE", 0, "Path to compiled binary", 0},
{"opt", 'O', "OPTLEVEL", 0, "Level of optimization to enable (0-3)"},
{"fconst-expr-reduce", FCONST_EXPR_REDUCE_CODE, 0, OPTION_HIDDEN,
"Reduces constant expressions at compile-time", 0},
{"fprint-func-annotations", FPRINT_FUNC_ANNOTATIONS, 0, OPTION_HIDDEN,
"When generating llvm, prints a comment containing which function in the compiler is printing",
0},
{0, 0, 0, 0, "Generic Options:", -1},
{0},
}
#define FCONST_EXPR_REDUCE_CODE
Definition: arguments.h:45
#define ARGP_HELP_FLAGS
Definition: arguments.h:42
#define FPRINT_FUNC_ANNOTATIONS
Definition: arguments.h:46
#define ARGP_LLVM_OUTPUT
Definition: arguments.h:43
#define DEFAULT_CLANG_EXECUTABLE_PATH
Definition: info.h:17