#include "input.h"
#include "macrotab.h"
#include "scanner.h"
+#include "standard.h"
#include "segments.h"
fprintf (stderr,
"Usage: %s [options] file\n"
"Short options:\n"
- " -A\t\t\tStrict ANSI mode\n"
" -Cl\t\t\tMake local variables static\n"
" -Dsym[=defn]\t\tDefine a symbol\n"
" -I dir\t\tSet an include directory search path\n"
"\n"
"Long options:\n"
" --add-source\t\tInclude source as comment\n"
- " --ansi\t\tStrict ANSI mode\n"
" --bss-name seg\tSet the name of the BSS segment\n"
" --check-stack\t\tGenerate stack overflow checks\n"
" --code-name seg\tSet the name of the CODE segment\n"
" --register-vars\tEnable register variables\n"
" --rodata-name seg\tSet the name of the RODATA segment\n"
" --signed-chars\tDefault characters are signed\n"
+ " --standard std\tLanguage standard (c89, c99, cc65)\n"
" --static-locals\tMake local variables static\n"
" --target sys\t\tSet the target system\n"
" --verbose\t\tIncrease verbosity\n"
-static void OptAnsi (const char* Opt attribute ((unused)),
- const char* Arg attribute ((unused)))
-/* Compile in strict ANSI mode */
-{
- ANSI = 1;
-}
-
-
-
static void OptBssName (const char* Opt attribute ((unused)), const char* Arg)
/* Handle the --bss-name option */
{
+static void OptStandard (const char* Opt, const char* Arg)
+/* Handle the --standard option */
+{
+ /* Find the standard from the given name */
+ standard_t Std = FindStandard (Arg);
+ if (Std == STD_UNKNOWN) {
+ AbEnd ("Invalid argument for %s: `%s'", Opt, Arg);
+ } else if (IS_Get (&Standard) != STD_UNKNOWN) {
+ AbEnd ("Option %s given more than once", Opt);
+ } else {
+ IS_Set (&Standard, Std);
+ }
+}
+
+
+
static void OptStaticLocals (const char* Opt attribute ((unused)),
const char* Arg attribute ((unused)))
/* Place local variables in static storage */
/* Program long options */
static const LongOpt OptTab[] = {
{ "--add-source", 0, OptAddSource },
- { "--ansi", 0, OptAnsi },
{ "--bss-name", 1, OptBssName },
{ "--check-stack", 0, OptCheckStack },
{ "--code-name", 1, OptCodeName },
{ "--register-vars", 0, OptRegisterVars },
{ "--rodata-name", 1, OptRodataName },
{ "--signed-chars", 0, OptSignedChars },
+ { "--standard", 1, OptStandard },
{ "--static-locals", 0, OptStaticLocals },
{ "--target", 1, OptTarget },
{ "--verbose", 0, OptVerbose },
OptVerbose (Arg, 0);
break;
- case 'A':
- OptAnsi (Arg, 0);
- break;
-
case 'C':
P = Arg + 2;
while (*P) {
SetMemoryModel (MMODEL_NEAR);
}
+ /* If no language standard was given, use the default one */
+ if (IS_Get (&Standard) == STD_UNKNOWN) {
+ IS_Set (&Standard, STD_DEFAULT);
+ }
+
/* Go! */
Compile (InputFile);