Add "-strict" command line option, to loosen C syntax and allow default arguments when not set
This commit is contained in:
parent
cfe2c7bed5
commit
fac53cfd54
|
@ -139,6 +139,7 @@ The compiler is command line driven, and creates an executable .prg file.
|
||||||
* -xz : extended zero page usage, more zero page space, but no return to basic
|
* -xz : extended zero page usage, more zero page space, but no return to basic
|
||||||
* -cid : cartridge type ID, used by vice emulator
|
* -cid : cartridge type ID, used by vice emulator
|
||||||
* -pp : compile in C++ mode
|
* -pp : compile in C++ mode
|
||||||
|
* -strict : use strict ANSI C parsing (no C++ goodies)
|
||||||
* -psci : use PETSCII encoding for all strings without prefix
|
* -psci : use PETSCII encoding for all strings without prefix
|
||||||
* -rmp : generate error files .error.map, .error.asm when linker fails
|
* -rmp : generate error files .error.map, .error.asm when linker fails
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ static const uint64 COPT_PETSCII = 1ULL << 53;
|
||||||
static const uint64 COPT_ERROR_FILES = 1ULL << 54;
|
static const uint64 COPT_ERROR_FILES = 1ULL << 54;
|
||||||
|
|
||||||
static const uint64 COPT_PROFILEINFO = 1ULL << 55;
|
static const uint64 COPT_PROFILEINFO = 1ULL << 55;
|
||||||
|
static const uint64 COPT_STRICT = 1ULL << 56;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1447,7 +1447,7 @@ Declaration * Parser::ParseFunctionDeclaration(Declaration* bdec)
|
||||||
|
|
||||||
adec->mSize = adec->mBase->mSize;
|
adec->mSize = adec->mBase->mSize;
|
||||||
|
|
||||||
if ((mCompilerOptions & COPT_CPLUSPLUS) && ConsumeTokenIf(TK_ASSIGN))
|
if (((mCompilerOptions & COPT_CPLUSPLUS) || !(mCompilerOptions & COPT_STRICT)) && ConsumeTokenIf(TK_ASSIGN))
|
||||||
{
|
{
|
||||||
adec->mValue = ParseExpression(false);
|
adec->mValue = ParseExpression(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -321,6 +321,12 @@ int main2(int argc, const char** argv)
|
||||||
{
|
{
|
||||||
compiler->mCompilerOptions |= COPT_CPLUSPLUS;
|
compiler->mCompilerOptions |= COPT_CPLUSPLUS;
|
||||||
compiler->AddDefine(Ident::Unique("__cplusplus"), "1");
|
compiler->AddDefine(Ident::Unique("__cplusplus"), "1");
|
||||||
|
compiler->AddDefine(Ident::Unique("__cplusplus__"), "1");
|
||||||
|
}
|
||||||
|
else if (arg[1] == 's' && arg[2] == 't' && arg[3] == 'r' && arg[4] == 'i' && arg[5] == 'c' && arg[6] == 't' && !arg[7])
|
||||||
|
{
|
||||||
|
compiler->mCompilerOptions |= COPT_STRICT;
|
||||||
|
compiler->AddDefine(Ident::Unique("__strict__"), "1");
|
||||||
}
|
}
|
||||||
else if (arg[1] == 'r' && arg[2] == 'm' && arg[3] == 'p' && !arg[4])
|
else if (arg[1] == 'r' && arg[2] == 'm' && arg[3] == 'p' && !arg[4])
|
||||||
{
|
{
|
||||||
|
@ -339,6 +345,7 @@ int main2(int argc, const char** argv)
|
||||||
{
|
{
|
||||||
compiler->mCompilerOptions |= COPT_CPLUSPLUS;
|
compiler->mCompilerOptions |= COPT_CPLUSPLUS;
|
||||||
compiler->AddDefine(Ident::Unique("__cplusplus"), "1");
|
compiler->AddDefine(Ident::Unique("__cplusplus"), "1");
|
||||||
|
compiler->AddDefine(Ident::Unique("__cplusplus__"), "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
compiler->mCompilationUnits->AddUnit(loc, argv[i], nullptr);
|
compiler->mCompilationUnits->AddUnit(loc, argv[i], nullptr);
|
||||||
|
|
Loading…
Reference in New Issue