\r
extern "C" {\r
\r
-void CPPDebugLogMsg(const char *msg)\r
+void ShPpDebugLogMsg(const char *msg)\r
{\r
TParseContext& pc = *((TParseContext *)cpp->pC);\r
\r
pc.infoSink.debug.message(EPrefixNone, msg);\r
}\r
\r
-void CPPWarningToInfoLog(const char *msg)\r
+void ShPpWarningToInfoLog(const char *msg)\r
{\r
TParseContext& pc = *((TParseContext *)cpp->pC);\r
\r
pc.infoSink.info.message(EPrefixWarning, msg, yylineno);\r
}\r
\r
-void CPPShInfoLogMsg(const char *msg)\r
+void ShPpErrorToInfoLog(const char *msg)\r
{\r
TParseContext& pc = *((TParseContext *)cpp->pC);\r
\r
- pc.error(yylineno,"", "",msg,"");\r
+ pc.error(yylineno, "", "Preprocessor", msg, "");\r
GlobalParseContext->recover();\r
}\r
\r
-void CPPErrorToInfoLog(const char *msg)\r
+// return 1 if error\r
+// return 0 if no error\r
+int ShPpMacrosMustBeDefinedError()\r
{\r
TParseContext& pc = *((TParseContext *)cpp->pC);\r
\r
- pc.error(yylineno, "CPP error:", "", msg, "");\r
- GlobalParseContext->recover();\r
+ if (pc.profile == EEsProfile) {\r
+ if (pc.messages & EShMsgRelaxedErrors)\r
+ ShPpWarningToInfoLog("undefined macro in expression not allowed in es profile");\r
+ else {\r
+ ShPpErrorToInfoLog("undefined macro in expression");\r
+ \r
+ return 1;\r
+ }\r
+ }\r
+\r
+ return 0;\r
}\r
\r
void SetLineNumber(int line)\r
\r
if (!strcmp(tokens[0], "optimize")) {\r
if (numTokens != 4) {\r
- CPPShInfoLogMsg("optimize pragma syntax is incorrect");\r
+ ShPpErrorToInfoLog("optimize pragma syntax is incorrect");\r
return;\r
}\r
\r
if (strcmp(tokens[1], "(")) {\r
- CPPShInfoLogMsg("\"(\" expected after 'optimize' keyword");\r
+ ShPpErrorToInfoLog("\"(\" expected after 'optimize' keyword");\r
return;\r
}\r
\r
else if (!strcmp(tokens[2], "off"))\r
pc.contextPragma.optimize = false;\r
else {\r
- CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'optimize' pragma");\r
+ ShPpErrorToInfoLog("\"on\" or \"off\" expected after '(' for 'optimize' pragma");\r
return;\r
}\r
\r
if (strcmp(tokens[3], ")")) {\r
- CPPShInfoLogMsg("\")\" expected to end 'optimize' pragma");\r
+ ShPpErrorToInfoLog("\")\" expected to end 'optimize' pragma");\r
return;\r
}\r
} else if (!strcmp(tokens[0], "debug")) {\r
if (numTokens != 4) {\r
- CPPShInfoLogMsg("debug pragma syntax is incorrect");\r
+ ShPpErrorToInfoLog("debug pragma syntax is incorrect");\r
return;\r
}\r
\r
if (strcmp(tokens[1], "(")) {\r
- CPPShInfoLogMsg("\"(\" expected after 'debug' keyword");\r
+ ShPpErrorToInfoLog("\"(\" expected after 'debug' keyword");\r
return;\r
}\r
\r
else if (!strcmp(tokens[2], "off"))\r
pc.contextPragma.debug = false;\r
else {\r
- CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'debug' pragma");\r
+ ShPpErrorToInfoLog("\"on\" or \"off\" expected after '(' for 'debug' pragma");\r
return;\r
}\r
\r
if (strcmp(tokens[3], ")")) {\r
- CPPShInfoLogMsg("\")\" expected to end 'debug' pragma");\r
+ ShPpErrorToInfoLog("\")\" expected to end 'debug' pragma");\r
return;\r
}\r
} else {\r
else if (!strcmp("warn", behavior))\r
return EBhWarn;\r
else {\r
- CPPShInfoLogMsg((TString("behavior '") + behavior + "' is not supported").c_str());\r
+ ShPpErrorToInfoLog((TString("behavior '") + behavior + "' is not supported").c_str());\r
return EBhDisable;\r
}\r
}\r
// special cased for all extension\r
if (!strcmp(extName, "all")) {\r
if (behaviorVal == EBhRequire || behaviorVal == EBhEnable) {\r
- CPPShInfoLogMsg("extension 'all' cannot have 'require' or 'enable' behavior");\r
+ ShPpErrorToInfoLog("extension 'all' cannot have 'require' or 'enable' behavior");\r
return;\r
} else {\r
for (iter = pc.extensionBehavior.begin(); iter != pc.extensionBehavior.end(); ++iter)\r
if (iter == pc.extensionBehavior.end()) {\r
switch (behaviorVal) {\r
case EBhRequire:\r
- CPPShInfoLogMsg((TString("extension '") + extName + "' is not supported").c_str());\r
+ ShPpErrorToInfoLog((TString("extension '") + extName + "' is not supported").c_str());\r
break;\r
case EBhEnable:\r
case EBhWarn:\r
int FinalCPP(void)
{
if (cpp->ifdepth)
- CPPErrorToInfoLog("#if mismatch");
+ ShPpErrorToInfoLog("missing #endif");
return 1;
}
memset(&mac, 0, sizeof(mac));
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
if (token != CPP_IDENTIFIER) {
- CPPErrorToInfoLog("#define");
+ ShPpErrorToInfoLog("#define not followed by macro name");
return token;
}
name = yylvalpp->sc_ident;
argc = 0;
do {
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- if (argc == 0 && token == ')') break;
+ if (argc == 0 && token == ')')
+ break;
if (token != CPP_IDENTIFIER) {
- CPPErrorToInfoLog("#define");
+ ShPpErrorToInfoLog("#define: bad argument");
+
return token;
}
if (argc < MAX_MACRO_ARGS)
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
} while (token == ',');
if (token != ')') {
- CPPErrorToInfoLog("#define");
+ ShPpErrorToInfoLog("#define: missing parenthesis");
+
return token;
}
mac.argc = argc;
if (symb) {
if (!symb->details.mac.undef) {
// already defined -- need to make sure they are identical
- if (symb->details.mac.argc != mac.argc) goto error;
+ if (symb->details.mac.argc != mac.argc)
+ goto error;
for (argc=0; argc < mac.argc; argc++)
if (symb->details.mac.args[argc] != mac.args[argc])
goto error;
if (token != old_token || yylvalpp->sc_int != old_lval) {
error:
StoreStr("Macro Redefined");
- StoreStr(GetStringOfAtom(atable,name));
- message=GetStrfromTStr();
+ StoreStr(GetStringOfAtom(atable, name));
+ message = GetStrfromTStr();
DecLineNumber();
- CPPShInfoLogMsg(message);
+ ShPpErrorToInfoLog(message);
IncLineNumber();
ResetTString();
- break; }
+ break;
+ }
} while (token > 0);
}
//FreeMacro(&symb->details.mac);
symb = AddSymbol(&dummyLoc, macros, name, MACRO_S);
}
symb->details.mac = mac;
+
return '\n';
} // CPPdefine
{
int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
Symbol *symb;
- if(token == '\n'){
- CPPErrorToInfoLog("#undef");
+ if (token == '\n') {
+ ShPpErrorToInfoLog("#undef must be followed by macro name");
+
return token;
}
- if (token != CPP_IDENTIFIER)
- goto error;
+ if (token != CPP_IDENTIFIER) {
+ ShPpErrorToInfoLog("#undef must be followed by macro name");
+
+ return token;
+ }
+
symb = LookUpSymbol(macros, yylvalpp->sc_ident);
if (symb) {
symb->details.mac.undef = 1;
}
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
if (token != '\n') {
- error:
- CPPErrorToInfoLog("#undef");
+ ShPpErrorToInfoLog("#undef can only be followed by a single macro name");
}
+
return token;
} // CPPundef
// found the #else we are looking for
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
if (token != '\n') {
- CPPWarningToInfoLog("unexpected tokens following #else preprocessor directive - expected a newline");
+ ShPpWarningToInfoLog("unexpected tokens following #else preprocessor directive - expected a newline");
while (token != '\n')
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
}
return CPPif(yylvalpp);
}
} else if((atom == elseAtom) && (!ChkCorrectElseNesting())) {
- CPPErrorToInfoLog("#else after a #else");
+ ShPpErrorToInfoLog("#else after #else");
cpp->CompileError = 1;
}
}; // end while
{
int i, val;
Symbol *s;
+
if (token == CPP_IDENTIFIER) {
if (yylvalpp->sc_ident == definedAtom) {
int needclose = 0;
needclose = 1;
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
}
- if (token != CPP_IDENTIFIER)
- goto error;
+ if (token != CPP_IDENTIFIER) {
+ ShPpErrorToInfoLog("incorrect preprocessor directive");
+ *err = 1;
+ *res = 0;
+
+ return token;
+ }
*res = (s = LookUpSymbol(macros, yylvalpp->sc_ident))
? !s->details.mac.undef : 0;
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
if (needclose) {
- if (token != ')')
- goto error;
+ if (token != ')') {
+ ShPpErrorToInfoLog("missing ')'");
+ *err = 1;
+ *res = 0;
+
+ return token;
+ }
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
}
- } else if (MacroExpand(yylvalpp->sc_ident, yylvalpp)) {
- token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- return eval(token, prec, res, err, yylvalpp);
- } else {
- goto error;
+ } else {
+ int macroReturn = MacroExpand(yylvalpp->sc_ident, yylvalpp);
+ if (macroReturn == 1) {
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+
+ return eval(token, prec, res, err, yylvalpp);
+ } else if (macroReturn == -1) {
+ *res = 0;
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ if (ShPpMacrosMustBeDefinedError())
+ *err = 1;
+
+ return token;
+ } else {
+ ShPpErrorToInfoLog("can't evaluate expression");
+ *err = 1;
+ *res = 0;
+
+ return token;
+ }
}
} else if (token == CPP_INTCONSTANT) {
*res = yylvalpp->sc_int;
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
token = eval(token, MIN_PREC, res, err, yylvalpp);
if (!*err) {
- if (token != ')')
- goto error;
+ if (token != ')') {
+ ShPpErrorToInfoLog("expected ')'");
+ *err = 1;
+ *res = 0;
+
+ return token;
+ }
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
}
} else {
token = eval(token, UNARY, res, err, yylvalpp);
*res = unop[i].op(*res);
} else {
- goto error;
+ ShPpErrorToInfoLog("bad expression");
+ *err = 1;
+ *res = 0;
+
+ return token;
}
}
while (!*err) {
token = eval(token, binop[i].prec, res, err, yylvalpp);
*res = binop[i].op(val, *res);
}
- return token;
-error:
- CPPErrorToInfoLog("incorrect preprocessor directive");
- *err = 1;
- *res = 0;
+
return token;
} // eval
if (!cpp->ifdepth++)
ifloc = *cpp->tokenLoc;
if (cpp->ifdepth > MAX_IF_NESTING){
- CPPErrorToInfoLog("max #if nesting depth exceeded");
+ ShPpErrorToInfoLog("max #if nesting depth exceeded");
return 0;
}
token = eval(token, MIN_PREC, &res, &err, yylvalpp);
if (token != '\n') {
- CPPWarningToInfoLog("unexpected tokens following the preprocessor directive - expected a newline");
+ ShPpWarningToInfoLog("unexpected tokens following the preprocessor directive - expected a newline");
while (token != '\n')
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
}
{
int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
int name = yylvalpp->sc_ident;
- if(++cpp->ifdepth >MAX_IF_NESTING){
- CPPErrorToInfoLog("max #if nesting depth exceeded");
+ if(++cpp->ifdepth > MAX_IF_NESTING){
+ ShPpErrorToInfoLog("max #if nesting depth exceeded");
return 0;
}
cpp->elsetracker++;
if (token != CPP_IDENTIFIER) {
- defined ? CPPErrorToInfoLog("ifdef"):CPPErrorToInfoLog("ifndef");
+ defined ? ShPpErrorToInfoLog("#ifdef not followed by macro name") : ShPpErrorToInfoLog("#ifndef not followed by macro name");
} else {
Symbol *s = LookUpSymbol(macros, name);
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
if (token != '\n') {
- CPPWarningToInfoLog("unexpected tokens following #ifdef preprocessor directive - expected a newline");
+ ShPpWarningToInfoLog("unexpected tokens following #ifdef preprocessor directive - expected a newline");
while (token != '\n')
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
}
static int CPPline(yystypepp * yylvalpp)
{
int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
- if(token=='\n'){
+ if (token=='\n') {
DecLineNumber();
- CPPErrorToInfoLog("#line");
+ ShPpErrorToInfoLog("#line must by followed by an integral literal");
IncLineNumber();
return token;
}
SetStringNumber(yylvalpp->sc_int);
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
if(token!='\n')
- CPPErrorToInfoLog("#line");
+ ShPpErrorToInfoLog("#line cannot be followed by more than two integral literals");
}
- else if (token == '\n'){
+ else if (token == '\n')
+
return token;
- }
- else{
- CPPErrorToInfoLog("#line");
- }
- }
- else{
- CPPErrorToInfoLog("#line");
- }
+ else
+ ShPpErrorToInfoLog("#line second argument can only be an integral literal");
+ } else
+ ShPpErrorToInfoLog("#line first argument can only be an integral literal");
+
return token;
}
-static int CPPerror(yystypepp * yylvalpp) {
-
+static int CPPerror(yystypepp * yylvalpp)
+{
int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
const char *message;
if (token == CPP_FLOATCONSTANT || token == CPP_INTCONSTANT){
StoreStr(yylvalpp->symbol_name);
}else if(token == CPP_IDENTIFIER || token == CPP_STRCONSTANT){
- StoreStr(GetStringOfAtom(atable,yylvalpp->sc_ident));
+ StoreStr(GetStringOfAtom(atable, yylvalpp->sc_ident));
}else {
- StoreStr(GetStringOfAtom(atable,token));
+ StoreStr(GetStringOfAtom(atable, token));
}
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
}
DecLineNumber();
//store this msg into the shader's information log..set the Compile Error flag!!!!
message=GetStrfromTStr();
- CPPShInfoLogMsg(message);
+ ShPpErrorToInfoLog(message);
ResetTString();
cpp->CompileError=1;
IncLineNumber();
if (token=='\n') {
DecLineNumber();
- CPPErrorToInfoLog("#pragma");
+ ShPpErrorToInfoLog("#pragma must be followed by pragma arguments");
IncLineNumber();
return token;
}
break;
case -1:
// EOF
- CPPShInfoLogMsg("#pragma directive must end with a newline");
+ ShPpErrorToInfoLog("#pragma directive must end with a newline");
return token;
default:
SrcStrName[0] = token;
int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
if (cpp->notAVersionToken == 1)
- CPPShInfoLogMsg("#version must occur before any other statement in the program");
+ ShPpErrorToInfoLog("#version must occur before any other statement in the program");
if(token=='\n'){
DecLineNumber();
- CPPErrorToInfoLog("#version");
+ ShPpErrorToInfoLog("#version");
IncLineNumber();
return token;
}
if (token != CPP_INTCONSTANT)
- CPPErrorToInfoLog("#version");
+ ShPpErrorToInfoLog("#version");
yylvalpp->sc_int=atoi(yylvalpp->symbol_name);
else if (yylvalpp->sc_ident == esAtom)
SetProfile(EEsProfile);
else
- CPPErrorToInfoLog("#version profile name");
+ ShPpErrorToInfoLog("#version profile name");
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
if (token == '\n')
return token;
else
- CPPErrorToInfoLog("#version");
+ ShPpErrorToInfoLog("#version");
}
return token;
if(token=='\n'){
DecLineNumber();
- CPPShInfoLogMsg("extension name not specified");
+ ShPpErrorToInfoLog("extension name not specified");
IncLineNumber();
return token;
}
if (token != CPP_IDENTIFIER)
- CPPErrorToInfoLog("#extension");
+ ShPpErrorToInfoLog("#extension");
strcpy(extensionName, GetAtomString(atable, yylvalpp->sc_ident));
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
if (token != ':') {
- CPPShInfoLogMsg("':' missing after extension name");
+ ShPpErrorToInfoLog("':' missing after extension name");
return token;
}
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
if (token != CPP_IDENTIFIER) {
- CPPShInfoLogMsg("behavior for extension not specified");
+ ShPpErrorToInfoLog("behavior for extension not specified");
return token;
}
return token;
}
else{
- CPPErrorToInfoLog("#extension");
+ ShPpErrorToInfoLog("#extension");
}
return token;
} // CPPextension
} else if (yylvalpp->sc_ident == elseAtom) {
if (ChkCorrectElseNesting()) {
if (! cpp->ifdepth) {
- CPPErrorToInfoLog("#else mismatch");
+ ShPpErrorToInfoLog("#else mismatch");
cpp->CompileError = 1;
}
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
if (token != '\n') {
- CPPWarningToInfoLog("unexpected tokens following #else preprocessor directive - expected a newline");
+ ShPpWarningToInfoLog("unexpected tokens following #else preprocessor directive - expected a newline");
while (token != '\n')
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
}
token = CPPelse(0, yylvalpp);
} else {
- CPPErrorToInfoLog("#else after a #else");
+ ShPpErrorToInfoLog("#else after a #else");
cpp->ifdepth = 0;
cpp->notAVersionToken = 1;
return 0;
}
} else if (yylvalpp->sc_ident == elifAtom) {
if (!cpp->ifdepth){
- CPPErrorToInfoLog("#elif mismatch");
+ ShPpErrorToInfoLog("#elif mismatch");
cpp->CompileError=1;
}
// this token is really a dont care, but we still need to eat the tokens
cpp->elsedepth[cpp->elsetracker] = 0;
--cpp->elsetracker;
if (!cpp->ifdepth){
- CPPErrorToInfoLog("#endif mismatch");
+ ShPpErrorToInfoLog("#endif mismatch");
cpp->CompileError=1;
}
else
token = CPPextension(yylvalpp);
} else {
StoreStr("Invalid Directive");
- StoreStr(GetStringOfAtom(atable,yylvalpp->sc_ident));
+ StoreStr(GetStringOfAtom(atable, yylvalpp->sc_ident));
message=GetStrfromTStr();
- CPPShInfoLogMsg(message);
+ ShPpErrorToInfoLog(message);
ResetTString();
}
}
PushEofSrc();
ReadFromTokenStream(a, 0, 0);
while ((token = cpp->currentInput->scan(cpp->currentInput, yylvalpp)) > 0) {
- if (token == CPP_IDENTIFIER && MacroExpand(yylvalpp->sc_ident, yylvalpp))
+ if (token == CPP_IDENTIFIER && MacroExpand(yylvalpp->sc_ident, yylvalpp) == 1)
continue;
RecordToken(n, token, yylvalpp);
}
} MacroInputSrc;
/* macro_scan ---
-** return the next token for a macro expanion, handling macro args
+** return the next token for a macro expansion, handling macro args
*/
static int macro_scan(InputSrc *inInput, yystypepp * yylvalpp) {
MacroInputSrc* in = (MacroInputSrc*)inInput;
free(in->args);
}
free(in);
+
return cpp->currentInput->scan(cpp->currentInput, yylvalpp);
} // macro_scan
/* MacroExpand
-** check an identifier (atom) to see if it a macro that should be expanded.
+** Check an identifier (atom) to see if it is a macro that should be expanded.
** If it is, push an InputSrc that will produce the appropriate expansion
-** and return TRUE. If not, return FALSE.
+** and return 1.
+** If it is, but undefined, it should expand to 0, push an InputSrc that will
+** expand to 0 and return -1.
+** Otherwise, return 0.
*/
-
int MacroExpand(int atom, yystypepp * yylvalpp)
{
- Symbol *sym = LookUpSymbol(macros, atom);
- MacroInputSrc *in;
- int i,j, token, depth=0;
+ Symbol *sym = LookUpSymbol(macros, atom);
+ MacroInputSrc *in;
+ int i, j, token;
+ int depth = 0;
const char *message;
+
if (atom == __LINE__Atom) {
yylvalpp->sc_int = GetLineNumber();
- sprintf(yylvalpp->symbol_name,"%d",yylvalpp->sc_int);
+ sprintf(yylvalpp->symbol_name, "%d", yylvalpp->sc_int);
UngetToken(CPP_INTCONSTANT, yylvalpp);
+
return 1;
}
+
if (atom == __FILE__Atom) {
yylvalpp->sc_int = GetStringNumber();
- sprintf(yylvalpp->symbol_name,"%d",yylvalpp->sc_int);
+ sprintf(yylvalpp->symbol_name, "%d", yylvalpp->sc_int);
UngetToken(CPP_INTCONSTANT, yylvalpp);
+
return 1;
}
+
if (atom == __VERSION__Atom) {
- strcpy(yylvalpp->symbol_name,"100");
+ strcpy(yylvalpp->symbol_name, "100");
yylvalpp->sc_int = atoi(yylvalpp->symbol_name);
UngetToken(CPP_INTCONSTANT, yylvalpp);
+
return 1;
}
- if (!sym || sym->details.mac.undef) return 0;
- if (sym->details.mac.busy) return 0; // no recursive expansions
+
+ if (! sym || sym->details.mac.undef)
+
+ return -1;
+
+ else if (sym->details.mac.busy)
+
+ return 0; // no recursive expansions
+
in = (MacroInputSrc*)malloc(sizeof(*in));
memset(in, 0, sizeof(*in));
in->base.scan = macro_scan;
if (token != '(') {
UngetToken(token, yylvalpp);
yylvalpp->sc_ident = atom;
+
return 0;
}
in->args = (TokenStream**)malloc(in->mac->argc * sizeof(TokenStream *));
for (i=0; i<in->mac->argc; i++)
in->args[i] = NewTokenStream("macro arg", 0);
i=0;j=0;
- do{
+ do {
depth = 0;
- while(1) {
+ while (1) {
token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
if (token <= 0) {
StoreStr("EOF in Macro ");
- StoreStr(GetStringOfAtom(atable,atom));
+ StoreStr(GetStringOfAtom(atable, atom));
message=GetStrfromTStr();
- CPPShInfoLogMsg(message);
+ ShPpErrorToInfoLog(message);
ResetTString();
+
return 1;
}
if((in->mac->argc==0) && (token!=')')) break;
break;
}
i++;
- }while(i < in->mac->argc);
+ } while (i < in->mac->argc);
if (i < in->mac->argc) {
StoreStr("Too few args in Macro ");
- StoreStr(GetStringOfAtom(atable,atom));
+ StoreStr(GetStringOfAtom(atable, atom));
message=GetStrfromTStr();
- CPPShInfoLogMsg(message);
+ ShPpErrorToInfoLog(message);
ResetTString();
} else if (token != ')') {
depth=0;
if (token <= 0) {
StoreStr("EOF in Macro ");
- StoreStr(GetStringOfAtom(atable,atom));
+ StoreStr(GetStringOfAtom(atable, atom));
message=GetStrfromTStr();
- CPPShInfoLogMsg(message);
+ ShPpErrorToInfoLog(message);
ResetTString();
+
return 1;
}
StoreStr("Too many args in Macro ");
- StoreStr(GetStringOfAtom(atable,atom));
+ StoreStr(GetStringOfAtom(atable, atom));
message=GetStrfromTStr();
- CPPShInfoLogMsg(message);
+ ShPpErrorToInfoLog(message);
ResetTString();
}
for (i=0; i<in->mac->argc; i++) {
sym->details.mac.busy = 1;
RewindTokenStream(sym->details.mac.body);
cpp->currentInput = &in->base;
+
return 1;
} // MacroExpand
}
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
} else {
- CPPErrorToInfoLog("ERROR___FP_CONST_TOO_LONG");
+ ShPpErrorToInfoLog("floating-point literal too long");
len = 1,str_len=1;
}
}
if (ch == 'e' || ch == 'E') {
if (len >= MAX_SYMBOL_NAME_LEN) {
- CPPErrorToInfoLog("ERROR___FP_CONST_TOO_LONG");
+ ShPpErrorToInfoLog("floating-point literal too long");
len = 1,str_len=1;
} else {
ExpSign = 1;
str[len++]=ch;
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
} else {
- CPPErrorToInfoLog("ERROR___FP_CONST_TOO_LONG");
+ ShPpErrorToInfoLog("floating-point literal too long");
len = 1,str_len=1;
}
}
} else {
- CPPErrorToInfoLog("ERROR___ERROR_IN_EXPONENT");
+ ShPpErrorToInfoLog("bad character in exponent");
}
exp *= ExpSign;
}
if (len == 0) {
yylvalpp->sc_fval = 0.0f;
yylvalpp->sc_dval = 0.0;
- strcpy(str,"0.0");
+ strcpy(str, "0.0");
} else {
if (ch == 'l' || ch == 'L') {
int ch2 = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
str[len++] = ch;
str[len++] = ch2;
} else {
- CPPErrorToInfoLog("ERROR___FP_CONST_TOO_LONG");
+ ShPpErrorToInfoLog("floating-point literal too long");
len = 1,str_len=1;
}
}
if (len < MAX_SYMBOL_NAME_LEN)
str[len++] = ch;
else {
- CPPErrorToInfoLog("ERROR___FP_CONST_TOO_LONG");
+ ShPpErrorToInfoLog("floating-point literal too long");
len = 1,str_len=1;
}
} else
ival = (ival << 4) | ii;
} else {
if (!AlreadyComplained)
- CPPErrorToInfoLog("ERROR___HEX_CONST_OVERFLOW");
+ ShPpErrorToInfoLog("hexidecimal literal too long");
AlreadyComplained = 1;
}
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
(ch >= 'A' && ch <= 'F') ||
(ch >= 'a' && ch <= 'f'));
} else {
- CPPErrorToInfoLog("ERROR___ERROR_IN_HEX_CONSTANT");
+ ShPpErrorToInfoLog("bad digit in hexidecimal literal");
}
if (ch == 'u' || ch == 'U')
yylvalpp->symbol_name[len++] = ch;
ival = (ival << 3) | ii;
} else {
if (!AlreadyComplained)
- CPPErrorToInfoLog("ERROR___OCT_CONST_OVERFLOW");
+ ShPpErrorToInfoLog("octal literal too long");
AlreadyComplained = 1;
}
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
ch = yylvalpp->symbol_name[ii] - '0';
if ((ival > 429496729) || (ival == 429496729 && ch >= 6)) {
if (! AlreadyComplained)
- CPPErrorToInfoLog("ERROR___INTEGER_CONST_OVERFLOW");
+ ShPpErrorToInfoLog("integral literal too long");
AlreadyComplained = 1;
}
ival = ival * 10 + ch;
while (ch != '*') {
if (ch == '\n') nlcount++;
if (ch == EOF) {
- CPPErrorToInfoLog("ERROR___EOF_IN_COMMENT");
+ ShPpErrorToInfoLog("EOF in comment");
return -1;
}
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
}
ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
if (ch == EOF) {
- CPPErrorToInfoLog("ERROR___EOF_IN_COMMENT");
+ ShPpErrorToInfoLog("EOF in comment");
return -1;
}
} while (ch != '/');
yylvalpp->sc_ident = LookUpAddString(atable, string_val);
return CPP_STRCONSTANT;
} else {
- CPPErrorToInfoLog("ERROR___CPP_EOL_IN_STRING");
+ ShPpErrorToInfoLog("end of line in string");
return ERROR_SY;
}
}
int yylex_CPP(char* buf, int maxSize)
{
- yystypepp yylvalpp;
+ yystypepp yylvalpp;
int token = '\n';
for(;;) {
char* tokenString = 0;
token = cpp->currentInput->scan(cpp->currentInput, &yylvalpp);
- if(check_EOF(token))
- return 0;
+ if(check_EOF(token))
+ return 0;
if (token == '#') {
if (cpp->previous_token == '\n'|| cpp->previous_token == 0) {
- token = readCPPline(&yylvalpp);
+ token = readCPPline(&yylvalpp);
if(check_EOF(token))
return 0;
- continue;
+ continue;
} else {
- CPPErrorToInfoLog("preprocessor command must not be preceded by any other statement in that line");
+ ShPpErrorToInfoLog("preprocessor directive cannot be preceded by another token");
return 0;
}
}
cpp->previous_token = token;
// expand macros
- if (token == CPP_IDENTIFIER && MacroExpand(yylvalpp.sc_ident, &yylvalpp)) {
+ if (token == CPP_IDENTIFIER && MacroExpand(yylvalpp.sc_ident, &yylvalpp) == 1) {
cpp->notAVersionToken = 1;
continue;
}
-
+
if (token == '\n')
continue;
-
+
if (token == CPP_IDENTIFIER) {
cpp->notAVersionToken = 1;
tokenString = GetStringOfAtom(atable,yylvalpp.sc_ident);
} else if (token == CPP_FLOATCONSTANT||token == CPP_INTCONSTANT){
cpp->notAVersionToken = 1;
tokenString = yylvalpp.symbol_name;
- } else {
+ } else {
cpp->notAVersionToken = 1;
tokenString = GetStringOfAtom(atable,token);
- }
+ }
if (tokenString) {
if ((signed)strlen(tokenString) >= maxSize) {
cpp->tokensBeforeEOF = 1;
return maxSize;
} else if (strlen(tokenString) > 0) {
- strcpy(buf, tokenString);
+ strcpy(buf, tokenString);
cpp->tokensBeforeEOF = 1;
return (int)strlen(tokenString);
}
{
if(token==-1){
if(cpp->ifdepth >0){
- CPPErrorToInfoLog("#endif missing!! Compilation stopped");
+ ShPpErrorToInfoLog("missing #endif");
cpp->CompileError=1;
}
return 1;