diff --git a/sourcepawn/compiler/sc2.cpp b/sourcepawn/compiler/sc2.cpp index 31f5a79b..9dd3ca68 100644 --- a/sourcepawn/compiler/sc2.cpp +++ b/sourcepawn/compiler/sc2.cpp @@ -2053,6 +2053,55 @@ const char *sc_tokens[] = { "-label-", "-string-", "-string-" }; +static inline bool +IsUnimplementedKeyword(int token) +{ + switch (token) { + case tACQUIRE: + case tAS: + case tCATCH: + case tCAST_TO: + case tDOUBLE: + case tEXPLICIT: + case tFINALLY: + case tFOREACH: + case tIMPLICIT: + case tIMPORT: + case tIN: + case tINT8: + case tINT16: + case tINT32: + case tINT64: + case tINTERFACE: + case tINTN: + case tLET: + case tNAMESPACE: + case tPACKAGE: + case tPRIVATE: + case tPROTECTED: + case tREADONLY: + case tSEALED: + case tTHROW: + case tTRY: + case tTYPEOF: + case tUINT8: + case tUINT16: + case tUINT32: + case tUINT64: + case tUINTN: + case tUNION: + case tUSING: + case tVAR: + case tVARIANT: + case tVIRTUAL: + case tVOLATILE: + case tWITH: + return true; + default: + return false; + } +} + static full_token_t *advance_token_ptr() { assert(sTokenBuffer->depth == 0); @@ -2150,10 +2199,18 @@ int lex(cell *lexvalue,char **lexsym) } /* while */ while (i<=tLAST) { /* match reserved words and compiler directives */ if (*lptr==**tokptr && match(*tokptr,TRUE)) { - tok->id = i; - errorset(sRESET,0); /* reset error flag (clear the "panic mode")*/ - if (pc_docexpr) /* optionally concatenate to documentation string */ - insert_autolist(*tokptr); + if (IsUnimplementedKeyword(i)) { + // Try to gracefully error. + error(173, sc_tokens[i - tFIRST]); + tok->id = tSYMBOL; + strcpy(tok->str, sc_tokens[i - tFIRST]); + tok->len = strlen(tok->str); + } else { + tok->id = i; + errorset(sRESET,0); /* reset error flag (clear the "panic mode")*/ + if (pc_docexpr) /* optionally concatenate to documentation string */ + insert_autolist(*tokptr); + } tok->end.line = fline; tok->end.col = (int)(lptr - pline); return tok->id; diff --git a/sourcepawn/compiler/sc5-in.scp b/sourcepawn/compiler/sc5-in.scp index 111b0f7d..472295d1 100644 --- a/sourcepawn/compiler/sc5-in.scp +++ b/sourcepawn/compiler/sc5-in.scp @@ -216,6 +216,7 @@ static const char *errmsg[] = { /*170*/ "creating new object '%s' requires using 'new' before its constructor\n", /*171*/ "cannot use 'new' with non-object-like methodmap '%s'\n", /*172*/ "methodmap '%s' does not have a constructor\n", +/*173*/ "'%s' is a newly reserved keyword that may be used in the future; use a different name as an identifier\n", #else "\315e\306\227\266k\217:\235\277bu\201fo\220\204\223\012", "\202l\224\250s\205g\346\356e\233\201(\243\315\214\267\202) \253 f\255low ea\305 \042c\353e\042\012",