return 1;
}
-int TPpContext::CPPdefine(TPpToken * yylvalpp)
+int TPpContext::CPPdefine(TPpToken * ppToken)
{
int token, atom, args[maxMacroArgs], argc;
MacroSymbol mac;
Symbol *symb;
memset(&mac, 0, sizeof(mac));
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
if (token != CPP_IDENTIFIER) {
- parseContext.error(yylvalpp->loc, "must be followed by macro atom", "#define", "");
+ parseContext.error(ppToken->loc, "must be followed by macro atom", "#define", "");
return token;
}
- atom = yylvalpp->atom;
- token = currentInput->scan(this, currentInput, yylvalpp);
- if (token == '(' && !yylvalpp->ival) {
+ atom = ppToken->atom;
+ token = currentInput->scan(this, currentInput, ppToken);
+ if (token == '(' && !ppToken->ival) {
// gather arguments
argc = 0;
do {
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
if (argc == 0 && token == ')')
break;
if (token != CPP_IDENTIFIER) {
- parseContext.error(yylvalpp->loc, "bad argument", "#define", "");
+ parseContext.error(ppToken->loc, "bad argument", "#define", "");
return token;
}
if (argc < maxMacroArgs)
- args[argc++] = yylvalpp->atom;
- token = currentInput->scan(this, currentInput, yylvalpp);
+ args[argc++] = ppToken->atom;
+ token = currentInput->scan(this, currentInput, ppToken);
} while (token == ',');
if (token != ')') {
- parseContext.error(yylvalpp->loc, "missing parenthesis", "#define", "");
+ parseContext.error(ppToken->loc, "missing parenthesis", "#define", "");
return token;
}
mac.argc = argc;
mac.args = (int*)mem_Alloc(pool, argc * sizeof(int));
memcpy(mac.args, args, argc * sizeof(int));
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
}
mac.body = NewTokenStream(GetAtomString(atom), pool);
while (token != '\n') {
while (token == '\\') {
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
if (token == '\n')
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
else
- RecordToken(mac.body, '\\', yylvalpp);
+ RecordToken(mac.body, '\\', ppToken);
}
- RecordToken(mac.body, token, yylvalpp);
- token = currentInput->scan(this, currentInput, yylvalpp);
+ RecordToken(mac.body, token, ppToken);
+ token = currentInput->scan(this, currentInput, ppToken);
};
symb = LookUpSymbol(atom);
RewindTokenStream(mac.body);
do {
int old_lval, old_token;
- old_token = ReadToken(symb->mac.body, yylvalpp);
- old_lval = yylvalpp->ival;
- token = ReadToken(mac.body, yylvalpp);
- if (token != old_token || yylvalpp->ival != old_lval) {
+ old_token = ReadToken(symb->mac.body, ppToken);
+ old_lval = ppToken->ival;
+ token = ReadToken(mac.body, ppToken);
+ if (token != old_token || ppToken->ival != old_lval) {
error:
- parseContext.error(yylvalpp->loc, "Macro Redefined", "#define", GetAtomString(atom));
+ parseContext.error(ppToken->loc, "Macro Redefined", "#define", GetAtomString(atom));
break;
}
} while (token > 0);
return '\n';
} // CPPdefine
-int TPpContext::CPPundef(TPpToken * yylvalpp)
+int TPpContext::CPPundef(TPpToken * ppToken)
{
- int token = currentInput->scan(this, currentInput, yylvalpp);
+ int token = currentInput->scan(this, currentInput, ppToken);
Symbol *symb;
if (token == '\n') {
- parseContext.error(yylvalpp->loc, "must be followed by macro name", "#undef", "");
+ parseContext.error(ppToken->loc, "must be followed by macro name", "#undef", "");
return token;
}
if (token != CPP_IDENTIFIER) {
- parseContext.error(yylvalpp->loc, "must be followed by macro name", "#undef", "");
+ parseContext.error(ppToken->loc, "must be followed by macro name", "#undef", "");
return token;
}
- symb = LookUpSymbol(yylvalpp->atom);
+ symb = LookUpSymbol(ppToken->atom);
if (symb) {
symb->mac.undef = 1;
}
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
if (token != '\n')
- parseContext.error(yylvalpp->loc, "can only be followed by a single macro name", "#undef", "");
+ parseContext.error(ppToken->loc, "can only be followed by a single macro name", "#undef", "");
return token;
} // CPPundef
** #elif, or #endif after a #if/#ifdef/#ifndef/#elif test was false
*/
-int TPpContext::CPPelse(int matchelse, TPpToken * yylvalpp)
+int TPpContext::CPPelse(int matchelse, TPpToken * ppToken)
{
int atom;
int depth = 0;
- int token = currentInput->scan(this, currentInput, yylvalpp);
+ int token = currentInput->scan(this, currentInput, ppToken);
while (token > 0) {
if (token != '#') {
while (token != '\n')
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
continue;
}
- if ((token = currentInput->scan(this, currentInput, yylvalpp)) != CPP_IDENTIFIER)
+ if ((token = currentInput->scan(this, currentInput, ppToken)) != CPP_IDENTIFIER)
continue;
- atom = yylvalpp->atom;
+ atom = ppToken->atom;
if (atom == ifAtom || atom == ifdefAtom || atom == ifndefAtom) {
depth++;
ifdepth++;
} else if (matchelse && depth == 0) {
if (atom == elseAtom ) {
// found the #else we are looking for
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
if (token != '\n') {
- parseContext.warn(yylvalpp->loc, "#else", "unexpected tokens following #else directive - expected a newline", "");
+ parseContext.warn(ppToken->loc, "#else", "unexpected tokens following #else directive - expected a newline", "");
while (token != '\n')
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
}
break;
} else if (atom == elifAtom) {
--elsetracker;
}
- return CPPif (yylvalpp);
+ return CPPif (ppToken);
}
} else if ((atom == elseAtom) && (!ChkCorrectElseNesting()))
- parseContext.error(yylvalpp->loc, "#else after #else", "#else", "");
+ parseContext.error(ppToken->loc, "#else after #else", "#else", "");
}; // end while
return token;
#define ALEN(A) (sizeof(A)/sizeof(A[0]))
-int TPpContext::eval(int token, int prec, int *res, int *err, TPpToken * yylvalpp)
+int TPpContext::eval(int token, int prec, int *res, int *err, TPpToken * ppToken)
{
int i, val;
Symbol *s;
if (token == CPP_IDENTIFIER) {
- if (yylvalpp->atom == definedAtom) {
+ if (ppToken->atom == definedAtom) {
bool needclose = 0;
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
if (token == '(') {
needclose = true;
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
}
if (token != CPP_IDENTIFIER) {
- parseContext.error(yylvalpp->loc, "incorrect directive, expected identifier", "preprocessor", "");
+ parseContext.error(ppToken->loc, "incorrect directive, expected identifier", "preprocessor", "");
*err = 1;
*res = 0;
return token;
}
- *res = (s = LookUpSymbol(yylvalpp->atom))
+ *res = (s = LookUpSymbol(ppToken->atom))
? !s->mac.undef : 0;
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
if (needclose) {
if (token != ')') {
- parseContext.error(yylvalpp->loc, "#else after #else", "", "");
+ parseContext.error(ppToken->loc, "#else after #else", "", "");
*err = 1;
*res = 0;
return token;
}
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
}
} else {
- int macroReturn = MacroExpand(yylvalpp->atom, yylvalpp, 1);
+ int macroReturn = MacroExpand(ppToken->atom, ppToken, 1);
if (macroReturn == 0) {
- parseContext.error(yylvalpp->loc, "can't evaluate expression", "preprocessor", "");
+ parseContext.error(ppToken->loc, "can't evaluate expression", "preprocessor", "");
*err = 1;
*res = 0;
if (macroReturn == -1) {
if (parseContext.profile == EEsProfile) {
if (parseContext.messages & EShMsgRelaxedErrors)
- parseContext.warn(yylvalpp->loc, "undefined macro in expression not allowed in es profile", "preprocessor", "");
+ parseContext.warn(ppToken->loc, "undefined macro in expression not allowed in es profile", "preprocessor", "");
else {
- parseContext.error(yylvalpp->loc, "undefined macro in expression", "preprocessor", "");
+ parseContext.error(ppToken->loc, "undefined macro in expression", "preprocessor", "");
*err = 1;
}
}
}
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
- return eval(token, prec, res, err, yylvalpp);
+ return eval(token, prec, res, err, ppToken);
}
}
} else if (token == CPP_INTCONSTANT) {
- *res = yylvalpp->ival;
- token = currentInput->scan(this, currentInput, yylvalpp);
+ *res = ppToken->ival;
+ token = currentInput->scan(this, currentInput, ppToken);
} else if (token == '(') {
- token = currentInput->scan(this, currentInput, yylvalpp);
- token = eval(token, MIN_PREC, res, err, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
+ token = eval(token, MIN_PREC, res, err, ppToken);
if (!*err) {
if (token != ')') {
- parseContext.error(yylvalpp->loc, "expected ')'", "preprocessor", "");
+ parseContext.error(ppToken->loc, "expected ')'", "preprocessor", "");
*err = 1;
*res = 0;
return token;
}
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
}
} else {
for (i = ALEN(unop) - 1; i >= 0; i--) {
break;
}
if (i >= 0) {
- token = currentInput->scan(this, currentInput, yylvalpp);
- token = eval(token, UNARY, res, err, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
+ token = eval(token, UNARY, res, err, ppToken);
*res = unop[i].op(*res);
} else {
- parseContext.error(yylvalpp->loc, "", "bad expression", "");
+ parseContext.error(ppToken->loc, "", "bad expression", "");
*err = 1;
*res = 0;
if (i < 0 || binop[i].prec <= prec)
break;
val = *res;
- token = currentInput->scan(this, currentInput, yylvalpp);
- token = eval(token, binop[i].prec, res, err, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
+ token = eval(token, binop[i].prec, res, err, ppToken);
*res = binop[i].op(val, *res);
}
return token;
} // eval
-int TPpContext::CPPif (TPpToken * yylvalpp)
+int TPpContext::CPPif (TPpToken * ppToken)
{
- int token = currentInput->scan(this, currentInput, yylvalpp);
+ int token = currentInput->scan(this, currentInput, ppToken);
int res = 0, err = 0;
elsetracker++;
if (! ifdepth++)
- ifloc = yylvalpp->loc;
+ ifloc = ppToken->loc;
if (ifdepth > maxIfNesting) {
- parseContext.error(yylvalpp->loc, "maximum nesting depth exceeded", "#if", "");
+ parseContext.error(ppToken->loc, "maximum nesting depth exceeded", "#if", "");
return 0;
}
- token = eval(token, MIN_PREC, &res, &err, yylvalpp);
+ token = eval(token, MIN_PREC, &res, &err, ppToken);
if (token != '\n') {
- parseContext.warn(yylvalpp->loc, "unexpected tokens following #if directive - expected a newline", "#if", "");
+ parseContext.warn(ppToken->loc, "unexpected tokens following #if directive - expected a newline", "#if", "");
while (token != '\n')
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
}
if (!res && !err) {
- token = CPPelse(1, yylvalpp);
+ token = CPPelse(1, ppToken);
}
return token;
} // CPPif
-int TPpContext::CPPifdef(int defined, TPpToken * yylvalpp)
+int TPpContext::CPPifdef(int defined, TPpToken * ppToken)
{
- int token = currentInput->scan(this, currentInput, yylvalpp);
- int name = yylvalpp->atom;
+ int token = currentInput->scan(this, currentInput, ppToken);
+ int name = ppToken->atom;
if (++ifdepth > maxIfNesting) {
- parseContext.error(yylvalpp->loc, "maximum nesting depth exceeded", "#ifdef", "");
+ parseContext.error(ppToken->loc, "maximum nesting depth exceeded", "#ifdef", "");
return 0;
}
elsetracker++;
if (token != CPP_IDENTIFIER) {
if (defined)
- parseContext.error(yylvalpp->loc, "must be followed by macro name", "#ifdef", "");
+ parseContext.error(ppToken->loc, "must be followed by macro name", "#ifdef", "");
else
- parseContext.error(yylvalpp->loc, "must be followed by macro name", "#ifndef", "");
+ parseContext.error(ppToken->loc, "must be followed by macro name", "#ifndef", "");
} else {
Symbol *s = LookUpSymbol(name);
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
if (token != '\n') {
- parseContext.error(yylvalpp->loc, "unexpected tokens following #ifdef directive - expected a newline", "#ifdef", "");
+ parseContext.error(ppToken->loc, "unexpected tokens following #ifdef directive - expected a newline", "#ifdef", "");
while (token != '\n')
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
}
if (((s && !s->mac.undef) ? 1 : 0) != defined)
- token = CPPelse(1, yylvalpp);
+ token = CPPelse(1, ppToken);
}
return token;
} // CPPifdef
// Handle #line
-int TPpContext::CPPline(TPpToken * yylvalpp)
+int TPpContext::CPPline(TPpToken * ppToken)
{
- int token = currentInput->scan(this, currentInput, yylvalpp);
+ int token = currentInput->scan(this, currentInput, ppToken);
if (token == '\n') {
- parseContext.error(yylvalpp->loc, "must by followed by an integral literal", "#line", "");
+ parseContext.error(ppToken->loc, "must by followed by an integral literal", "#line", "");
return token;
}
else if (token == CPP_INTCONSTANT) {
- parseContext.currentLoc.line = atoi(yylvalpp->name);
- token = currentInput->scan(this, currentInput, yylvalpp);
+ parseContext.currentLoc.line = atoi(ppToken->name);
+ token = currentInput->scan(this, currentInput, ppToken);
if (token == CPP_INTCONSTANT) {
- parseContext.currentLoc.string = atoi(yylvalpp->name);
- token = currentInput->scan(this, currentInput, yylvalpp);
+ parseContext.currentLoc.string = atoi(ppToken->name);
+ token = currentInput->scan(this, currentInput, ppToken);
if (token != '\n')
parseContext.error(parseContext.currentLoc, "cannot be followed by more than two integral literals", "#line", "");
} else if (token == '\n')
}
// Handle #error
-int TPpContext::CPPerror(TPpToken * yylvalpp)
+int TPpContext::CPPerror(TPpToken * ppToken)
{
- int token = currentInput->scan(this, currentInput, yylvalpp);
+ int token = currentInput->scan(this, currentInput, ppToken);
std::string message;
- TSourceLoc loc = yylvalpp->loc;
+ TSourceLoc loc = ppToken->loc;
while (token != '\n') {
if (token == CPP_INTCONSTANT || token == CPP_UINTCONSTANT ||
token == CPP_FLOATCONSTANT || token == CPP_DOUBLECONSTANT) {
- message.append(yylvalpp->name);
+ message.append(ppToken->name);
} else if (token == CPP_IDENTIFIER || token == CPP_STRCONSTANT) {
- message.append(GetAtomString(yylvalpp->atom));
+ message.append(GetAtomString(ppToken->atom));
} else {
message.append(GetAtomString(token));
}
message.append(" ");
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
}
//store this msg into the shader's information log..set the Compile Error flag!!!!
parseContext.error(loc, message.c_str(), "#error", "");
return '\n';
}
-int TPpContext::CPPpragma(TPpToken * yylvalpp)
+int TPpContext::CPPpragma(TPpToken * ppToken)
{
char SrcStrName[2];
char** allTokens;
const char* SrcStr;
int i;
- int token = currentInput->scan(this, currentInput, yylvalpp);
+ int token = currentInput->scan(this, currentInput, ppToken);
if (token=='\n') {
- parseContext.error(yylvalpp->loc, "must be followed by pragma arguments", "#pragma", "");
+ parseContext.error(ppToken->loc, "must be followed by pragma arguments", "#pragma", "");
return token;
}
}
switch (token) {
case CPP_IDENTIFIER:
- SrcStr = GetAtomString(yylvalpp->atom);
+ SrcStr = GetAtomString(ppToken->atom);
allTokens[tokenCount] = (char*)malloc(strlen(SrcStr) + 1);
strcpy(allTokens[tokenCount++], SrcStr);
break;
case CPP_UINTCONSTANT:
case CPP_FLOATCONSTANT:
case CPP_DOUBLECONSTANT:
- SrcStr = yylvalpp->name;
+ SrcStr = ppToken->name;
allTokens[tokenCount] = (char*)malloc(strlen(SrcStr) + 1);
strcpy(allTokens[tokenCount++], SrcStr);
break;
case EOF:
- parseContext.error(yylvalpp->loc, "directive must end with a newline", "#pragma", "");
+ parseContext.error(ppToken->loc, "directive must end with a newline", "#pragma", "");
return token;
default:
SrcStrName[0] = token;
allTokens[tokenCount] = (char*)malloc(2);
strcpy(allTokens[tokenCount++], SrcStrName);
}
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
}
- currentInput->ungetch(this, currentInput, token, yylvalpp);
+ currentInput->ungetch(this, currentInput, token, ppToken);
parseContext.handlePragma((const char**)allTokens, tokenCount);
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
for (i = 0; i < tokenCount; ++i) {
free (allTokens[i]);
} // CPPpragma
// This is just for error checking: the version and profile are decided before preprocessing starts
-int TPpContext::CPPversion(TPpToken * yylvalpp)
+int TPpContext::CPPversion(TPpToken * ppToken)
{
- int token = currentInput->scan(this, currentInput, yylvalpp);
+ int token = currentInput->scan(this, currentInput, ppToken);
if (notAVersionToken)
- parseContext.error(yylvalpp->loc, "must occur before any other statement in the program", "#version", "");
+ parseContext.error(ppToken->loc, "must occur before any other statement in the program", "#version", "");
if (token == '\n') {
- parseContext.error(yylvalpp->loc, "must be followed by version number", "#version", "");
+ parseContext.error(ppToken->loc, "must be followed by version number", "#version", "");
return token;
}
if (token != CPP_INTCONSTANT)
- parseContext.error(yylvalpp->loc, "must be followed by version number", "#version", "");
+ parseContext.error(ppToken->loc, "must be followed by version number", "#version", "");
- yylvalpp->ival = atoi(yylvalpp->name);
+ ppToken->ival = atoi(ppToken->name);
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
if (token == '\n')
return token;
else {
- if (yylvalpp->atom != coreAtom &&
- yylvalpp->atom != compatibilityAtom &&
- yylvalpp->atom != esAtom)
- parseContext.error(yylvalpp->loc, "bad profile name; use es, core, or compatibility", "#version", "");
+ if (ppToken->atom != coreAtom &&
+ ppToken->atom != compatibilityAtom &&
+ ppToken->atom != esAtom)
+ parseContext.error(ppToken->loc, "bad profile name; use es, core, or compatibility", "#version", "");
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
if (token == '\n')
return token;
else
- parseContext.error(yylvalpp->loc, "bad tokens following profile -- expected newline", "#version", "");
+ parseContext.error(ppToken->loc, "bad tokens following profile -- expected newline", "#version", "");
}
return token;
} // CPPversion
-int TPpContext::CPPextension(TPpToken * yylvalpp)
+int TPpContext::CPPextension(TPpToken * ppToken)
{
- int token = currentInput->scan(this, currentInput, yylvalpp);
+ int token = currentInput->scan(this, currentInput, ppToken);
char extensionName[80];
if (token=='\n') {
- parseContext.error(yylvalpp->loc, "extension name not specified", "#extension", "");
+ parseContext.error(ppToken->loc, "extension name not specified", "#extension", "");
return token;
}
if (token != CPP_IDENTIFIER)
- parseContext.error(yylvalpp->loc, "extension name expected", "#extension", "");
+ parseContext.error(ppToken->loc, "extension name expected", "#extension", "");
- strcpy(extensionName, GetAtomString(yylvalpp->atom));
+ strcpy(extensionName, GetAtomString(ppToken->atom));
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
if (token != ':') {
- parseContext.error(yylvalpp->loc, "':' missing after extension name", "#extension", "");
+ parseContext.error(ppToken->loc, "':' missing after extension name", "#extension", "");
return token;
}
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
if (token != CPP_IDENTIFIER) {
- parseContext.error(yylvalpp->loc, "behavior for extension not specified", "#extension", "");
+ parseContext.error(ppToken->loc, "behavior for extension not specified", "#extension", "");
return token;
}
- parseContext.updateExtensionBehavior(extensionName, GetAtomString(yylvalpp->atom));
+ parseContext.updateExtensionBehavior(extensionName, GetAtomString(ppToken->atom));
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
if (token == '\n')
return token;
else
- parseContext.error(yylvalpp->loc, "extra tokens -- expected newline", "#extension","");
+ parseContext.error(ppToken->loc, "extra tokens -- expected newline", "#extension","");
return token;
} // CPPextension
-int TPpContext::readCPPline(TPpToken * yylvalpp)
+int TPpContext::readCPPline(TPpToken * ppToken)
{
- int token = currentInput->scan(this, currentInput, yylvalpp);
+ int token = currentInput->scan(this, currentInput, ppToken);
bool isVersion = false;
if (token == CPP_IDENTIFIER) {
- if (yylvalpp->atom == defineAtom) {
- token = CPPdefine(yylvalpp);
- } else if (yylvalpp->atom == elseAtom) {
+ if (ppToken->atom == defineAtom) {
+ token = CPPdefine(ppToken);
+ } else if (ppToken->atom == elseAtom) {
if (ChkCorrectElseNesting()) {
if (! ifdepth) {
- parseContext.error(yylvalpp->loc, "mismatched statements", "#else", "");
+ parseContext.error(ppToken->loc, "mismatched statements", "#else", "");
}
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
if (token != '\n') {
- parseContext.warn(yylvalpp->loc, "unexpected tokens following #else directive - expected a newline", "#else", "");
+ parseContext.warn(ppToken->loc, "unexpected tokens following #else directive - expected a newline", "#else", "");
while (token != '\n')
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
}
- token = CPPelse(0, yylvalpp);
+ token = CPPelse(0, ppToken);
} else {
- parseContext.error(yylvalpp->loc, "#else after a #else", "#else", "");
+ parseContext.error(ppToken->loc, "#else after a #else", "#else", "");
ifdepth = 0;
notAVersionToken = true;
return 0;
}
- } else if (yylvalpp->atom == elifAtom) {
+ } else if (ppToken->atom == elifAtom) {
if (! ifdepth) {
- parseContext.error(yylvalpp->loc, "mismatched statements", "#elif", "");
+ parseContext.error(ppToken->loc, "mismatched statements", "#elif", "");
}
// this token is really a dont care, but we still need to eat the tokens
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
while (token != '\n')
- token = currentInput->scan(this, currentInput, yylvalpp);
- token = CPPelse(0, yylvalpp);
- } else if (yylvalpp->atom == endifAtom) {
+ token = currentInput->scan(this, currentInput, ppToken);
+ token = CPPelse(0, ppToken);
+ } else if (ppToken->atom == endifAtom) {
elsedepth[elsetracker] = 0;
--elsetracker;
if (! ifdepth)
- parseContext.error(yylvalpp->loc, "mismatched statements", "#endif", "");
+ parseContext.error(ppToken->loc, "mismatched statements", "#endif", "");
else
--ifdepth;
- } else if (yylvalpp->atom == ifAtom) {
- token = CPPif (yylvalpp);
- } else if (yylvalpp->atom == ifdefAtom) {
- token = CPPifdef(1, yylvalpp);
- } else if (yylvalpp->atom == ifndefAtom) {
- token = CPPifdef(0, yylvalpp);
- } else if (yylvalpp->atom == lineAtom) {
- token = CPPline(yylvalpp);
- } else if (yylvalpp->atom == pragmaAtom) {
- token = CPPpragma(yylvalpp);
- } else if (yylvalpp->atom == undefAtom) {
- token = CPPundef(yylvalpp);
- } else if (yylvalpp->atom == errorAtom) {
- token = CPPerror(yylvalpp);
- } else if (yylvalpp->atom == versionAtom) {
- token = CPPversion(yylvalpp);
+ } else if (ppToken->atom == ifAtom) {
+ token = CPPif (ppToken);
+ } else if (ppToken->atom == ifdefAtom) {
+ token = CPPifdef(1, ppToken);
+ } else if (ppToken->atom == ifndefAtom) {
+ token = CPPifdef(0, ppToken);
+ } else if (ppToken->atom == lineAtom) {
+ token = CPPline(ppToken);
+ } else if (ppToken->atom == pragmaAtom) {
+ token = CPPpragma(ppToken);
+ } else if (ppToken->atom == undefAtom) {
+ token = CPPundef(ppToken);
+ } else if (ppToken->atom == errorAtom) {
+ token = CPPerror(ppToken);
+ } else if (ppToken->atom == versionAtom) {
+ token = CPPversion(ppToken);
isVersion = true;
- } else if (yylvalpp->atom == extensionAtom) {
- token = CPPextension(yylvalpp);
+ } else if (ppToken->atom == extensionAtom) {
+ token = CPPextension(ppToken);
} else {
- parseContext.error(yylvalpp->loc, "Invalid Directive", "#", GetAtomString(yylvalpp->atom));
+ parseContext.error(ppToken->loc, "Invalid Directive", "#", GetAtomString(ppToken->atom));
}
}
while (token != '\n' && token != 0 && token != EOF) {
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
}
notAVersionToken = ! isVersion;
DeleteTokenStream(s->body);
}
-int eof_scan(TPpContext*, TPpContext::InputSrc* in, TPpToken* yylvalpp) { return -1; }
-void noop(TPpContext*, TPpContext::InputSrc* in, int ch, TPpToken* yylvalpp) { }
+int eof_scan(TPpContext*, TPpContext::InputSrc* in, TPpToken* ppToken) { return -1; }
+void noop(TPpContext*, TPpContext::InputSrc* in, int ch, TPpToken* ppToken) { }
void TPpContext::PushEofSrc()
{
}
}
-TPpContext::TokenStream* TPpContext::PrescanMacroArg(TokenStream *a, TPpToken * yylvalpp)
+TPpContext::TokenStream* TPpContext::PrescanMacroArg(TokenStream *a, TPpToken * ppToken)
{
int token;
TokenStream *n;
RewindTokenStream(a);
do {
- token = ReadToken(a, yylvalpp);
- if (token == CPP_IDENTIFIER && LookUpSymbol(yylvalpp->atom))
+ token = ReadToken(a, ppToken);
+ if (token == CPP_IDENTIFIER && LookUpSymbol(ppToken->atom))
break;
} while (token > 0);
if (token <= 0) return a;
n = NewTokenStream("macro arg", 0);
PushEofSrc();
ReadFromTokenStream(a, 0, 0);
- while ((token = currentInput->scan(this, currentInput, yylvalpp)) > 0) {
- if (token == CPP_IDENTIFIER && MacroExpand(yylvalpp->atom, yylvalpp, 0) == 1)
+ while ((token = currentInput->scan(this, currentInput, ppToken)) > 0) {
+ if (token == CPP_IDENTIFIER && MacroExpand(ppToken->atom, ppToken, 0) == 1)
continue;
- RecordToken(n, token, yylvalpp);
+ RecordToken(n, token, ppToken);
}
PopEofSrc();
DeleteTokenStream(a);
/* macro_scan ---
** return the next token for a macro expansion, handling macro args
*/
-int TPpContext::macro_scan(TPpContext* pp, TPpContext::InputSrc* inInput, TPpToken* yylvalpp)
+int TPpContext::macro_scan(TPpContext* pp, TPpContext::InputSrc* inInput, TPpToken* ppToken)
{
TPpContext::MacroInputSrc* in = (TPpContext::MacroInputSrc*)inInput;
int i;
- int token = pp->ReadToken(in->mac->body, yylvalpp);
+ int token = pp->ReadToken(in->mac->body, ppToken);
if (token == CPP_IDENTIFIER) {
for (i = in->mac->argc-1; i>=0; i--)
- if (in->mac->args[i] == yylvalpp->atom)
+ if (in->mac->args[i] == ppToken->atom)
break;
if (i >= 0) {
- pp->ReadFromTokenStream(in->args[i], yylvalpp->atom, 0);
+ pp->ReadFromTokenStream(in->args[i], ppToken->atom, 0);
- return pp->currentInput->scan(pp, pp->currentInput, yylvalpp);
+ return pp->currentInput->scan(pp, pp->currentInput, ppToken);
}
}
}
free(in);
- return pp->currentInput->scan(pp, pp->currentInput, yylvalpp);
+ return pp->currentInput->scan(pp, pp->currentInput, ppToken);
} // macro_scan
// return a zero, for scanning a macro that was never defined
-int TPpContext::zero_scan(TPpContext* pp, InputSrc *inInput, TPpToken* yylvalpp)
+int TPpContext::zero_scan(TPpContext* pp, InputSrc *inInput, TPpToken* ppToken)
{
MacroInputSrc* in = (MacroInputSrc*)inInput;
- strcpy(yylvalpp->name, "0");
- yylvalpp->ival = 0;
+ strcpy(ppToken->name, "0");
+ ppToken->ival = 0;
// pop input
pp->currentInput = in->base.prev;
** expand to 0 and return -1.
** Otherwise, return 0.
*/
-int TPpContext::MacroExpand(int atom, TPpToken* yylvalpp, int expandUndef)
+int TPpContext::MacroExpand(int atom, TPpToken* ppToken, int expandUndef)
{
Symbol *sym = LookUpSymbol(atom);
MacroInputSrc *in;
int depth = 0;
if (atom == __LINE__Atom) {
- yylvalpp->ival = parseContext.currentLoc.line;
- sprintf(yylvalpp->name, "%d", yylvalpp->ival);
- UngetToken(CPP_INTCONSTANT, yylvalpp);
+ ppToken->ival = parseContext.currentLoc.line;
+ sprintf(ppToken->name, "%d", ppToken->ival);
+ UngetToken(CPP_INTCONSTANT, ppToken);
return 1;
}
if (atom == __FILE__Atom) {
- yylvalpp->ival = parseContext.currentLoc.string;
- sprintf(yylvalpp->name, "%d", yylvalpp->ival);
- UngetToken(CPP_INTCONSTANT, yylvalpp);
+ ppToken->ival = parseContext.currentLoc.string;
+ sprintf(ppToken->name, "%d", ppToken->ival);
+ UngetToken(CPP_INTCONSTANT, ppToken);
return 1;
}
if (atom == __VERSION__Atom) {
- yylvalpp->ival = parseContext.version;
- sprintf(yylvalpp->name, "%d", yylvalpp->ival);
- UngetToken(CPP_INTCONSTANT, yylvalpp);
+ ppToken->ival = parseContext.version;
+ sprintf(ppToken->name, "%d", ppToken->ival);
+ UngetToken(CPP_INTCONSTANT, ppToken);
return 1;
}
in->base.scan = macro_scan;
in->mac = &sym->mac;
if (sym->mac.args) {
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
if (token != '(') {
- UngetToken(token, yylvalpp);
- yylvalpp->atom = atom;
+ UngetToken(token, ppToken);
+ ppToken->atom = atom;
return 0;
}
do {
depth = 0;
while (1) {
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
if (token <= 0) {
- parseContext.error(yylvalpp->loc, "EOF in macro", "preprocessor", GetAtomString(atom));
+ parseContext.error(ppToken->loc, "EOF in macro", "preprocessor", GetAtomString(atom));
return 1;
}
if (depth == 0 && (token == ',' || token == ')')) break;
if (token == '(') depth++;
if (token == ')') depth--;
- RecordToken(in->args[i], token, yylvalpp);
+ RecordToken(in->args[i], token, ppToken);
j=1;
}
if (token == ')') {
} while (i < in->mac->argc);
if (i < in->mac->argc)
- parseContext.error(yylvalpp->loc, "Too few args in Macro", "preprocessor", GetAtomString(atom));
+ parseContext.error(ppToken->loc, "Too few args in Macro", "preprocessor", GetAtomString(atom));
else if (token != ')') {
depth=0;
while (token >= 0 && (depth > 0 || token != ')')) {
if (token == ')')
depth--;
- token = currentInput->scan(this, currentInput, yylvalpp);
+ token = currentInput->scan(this, currentInput, ppToken);
if (token == '(')
depth++;
}
if (token <= 0) {
- parseContext.error(yylvalpp->loc, "EOF in macro", "preprocessor", GetAtomString(atom));
+ parseContext.error(ppToken->loc, "EOF in macro", "preprocessor", GetAtomString(atom));
return 1;
}
- parseContext.error(yylvalpp->loc, "Too many args in Macro", "preprocessor", GetAtomString(atom));
+ parseContext.error(ppToken->loc, "Too many args in Macro", "preprocessor", GetAtomString(atom));
}
for (i = 0; i<in->mac->argc; i++) {
- in->args[i] = PrescanMacroArg(in->args[i], yylvalpp);
+ in->args[i] = PrescanMacroArg(in->args[i], ppToken);
}
}
#if 0
return EOF;
}
-void noop(TPpContext*, TPpContext::InputSrc *in, int ch, TPpToken * yylvalpp)
+void noop(TPpContext*, TPpContext::InputSrc *in, int ch, TPpToken * ppToken)
{
}
* letter 'e', or a precision ending (e.g., F or LF).
*/
-int TPpContext::lFloatConst(char *str, int len, int ch, TPpToken * yylvalpp)
+int TPpContext::lFloatConst(char *str, int len, int ch, TPpToken * ppToken)
{
bool HasDecimalOrExponent = false;
int declen, exp, ExpSign;
if (ch == '.') {
HasDecimalOrExponent = true;
str[len++]=ch;
- ch = currentInput->getch(this, currentInput, yylvalpp);
+ ch = currentInput->getch(this, currentInput, ppToken);
while (ch >= '0' && ch <= '9') {
if (len < TPpToken::maxTokenLength) {
declen++;
str[len] = ch;
len++;str_len++;
}
- ch = currentInput->getch(this, currentInput, yylvalpp);
+ ch = currentInput->getch(this, currentInput, ppToken);
} else {
- parseContext.error(yylvalpp->loc, "float literal too long", "", "");
+ parseContext.error(ppToken->loc, "float literal too long", "", "");
len = 1,str_len=1;
}
}
if (ch == 'e' || ch == 'E') {
HasDecimalOrExponent = true;
if (len >= TPpToken::maxTokenLength) {
- parseContext.error(yylvalpp->loc, "float literal too long", "", "");
+ parseContext.error(ppToken->loc, "float literal too long", "", "");
len = 1,str_len=1;
} else {
ExpSign = 1;
str[len++]=ch;
- ch = currentInput->getch(this, currentInput, yylvalpp);
+ ch = currentInput->getch(this, currentInput, ppToken);
if (ch == '+') {
str[len++]=ch;
- ch = currentInput->getch(this, currentInput, yylvalpp);
+ ch = currentInput->getch(this, currentInput, ppToken);
} else if (ch == '-') {
ExpSign = -1;
str[len++]=ch;
- ch = currentInput->getch(this, currentInput, yylvalpp);
+ ch = currentInput->getch(this, currentInput, ppToken);
}
if (ch >= '0' && ch <= '9') {
while (ch >= '0' && ch <= '9') {
if (len < TPpToken::maxTokenLength) {
exp = exp*10 + ch - '0';
str[len++]=ch;
- ch = currentInput->getch(this, currentInput, yylvalpp);
+ ch = currentInput->getch(this, currentInput, ppToken);
} else {
- parseContext.error(yylvalpp->loc, "float literal too long", "", "");
+ parseContext.error(ppToken->loc, "float literal too long", "", "");
len = 1,str_len=1;
}
}
} else {
- parseContext.error(yylvalpp->loc, "bad character in float exponent", "", "");
+ parseContext.error(ppToken->loc, "bad character in float exponent", "", "");
}
exp *= ExpSign;
}
}
if (len == 0) {
- yylvalpp->dval = 0.0;
+ ppToken->dval = 0.0;
strcpy(str, "0.0");
} else {
if (ch == 'l' || ch == 'L') {
if (! HasDecimalOrExponent)
- parseContext.error(yylvalpp->loc, "float literal needs a decimal point or exponent", "", "");
- int ch2 = currentInput->getch(this, currentInput, yylvalpp);
+ parseContext.error(ppToken->loc, "float literal needs a decimal point or exponent", "", "");
+ int ch2 = currentInput->getch(this, currentInput, ppToken);
if (ch2 != 'f' && ch2 != 'F') {
- currentInput->ungetch(this, currentInput, ch2, yylvalpp);
- currentInput->ungetch(this, currentInput, ch, yylvalpp);
+ currentInput->ungetch(this, currentInput, ch2, ppToken);
+ currentInput->ungetch(this, currentInput, ch, ppToken);
} else {
if (len < TPpToken::maxTokenLength) {
str[len++] = ch;
str[len++] = ch2;
isDouble = 1;
} else {
- parseContext.error(yylvalpp->loc, "float literal too long", "", "");
+ parseContext.error(ppToken->loc, "float literal too long", "", "");
len = 1,str_len=1;
}
}
} else if (ch == 'f' || ch == 'F') {
if (! HasDecimalOrExponent)
- parseContext.error(yylvalpp->loc, "float literal needs a decimal point or exponent", "", "");
+ parseContext.error(ppToken->loc, "float literal needs a decimal point or exponent", "", "");
if (len < TPpToken::maxTokenLength)
str[len++] = ch;
else {
- parseContext.error(yylvalpp->loc, "float literal too long", "", "");
+ parseContext.error(ppToken->loc, "float literal too long", "", "");
len = 1,str_len=1;
}
} else
- currentInput->ungetch(this, currentInput, ch, yylvalpp);
+ currentInput->ungetch(this, currentInput, ch, ppToken);
str[len]='\0';
- yylvalpp->dval = strtod(str, 0);
+ ppToken->dval = strtod(str, 0);
}
// Suffix:
- strcpy(yylvalpp->name, str);
+ strcpy(ppToken->name, str);
if (isDouble)
return CPP_DOUBLECONSTANT;
///////////////////////////////////////// Normal Scanner //////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
-int TPpContext::byte_scan(TPpContext* pp, InputSrc *in, TPpToken * yylvalpp)
+int TPpContext::byte_scan(TPpContext* pp, InputSrc *in, TPpToken * ppToken)
{
char tokenText[TPpToken::maxTokenLength + 1];
int AlreadyComplained = 0;
unsigned ival = 0;
for (;;) {
- yylvalpp->ival = 0;
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ppToken->ival = 0;
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
while (ch == ' ' || ch == '\t' || ch == '\r') {
- yylvalpp->ival = 1;
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ppToken->ival = 1;
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
}
- yylvalpp->loc = pp->parseContext.currentLoc;
+ ppToken->loc = pp->parseContext.currentLoc;
len = 0;
switch (ch) {
default:
do {
if (ch == '\\') {
// escaped character
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
if (ch == '\r' || ch == '\n') {
- int nextch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ int nextch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
if (ch == '\r' && nextch == '\n')
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
else
ch = nextch;
} else
- pp->parseContext.error(yylvalpp->loc, "can only escape newlines", "\\", "");
+ pp->parseContext.error(ppToken->loc, "can only escape newlines", "\\", "");
} else if (len < TPpToken::maxTokenLength) {
tokenText[len++] = ch;
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
} else {
if (! AlreadyComplained) {
- pp->parseContext.error(yylvalpp->loc, "name too long", "", "");
+ pp->parseContext.error(ppToken->loc, "name too long", "", "");
AlreadyComplained = 1;
}
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
}
} while ((ch >= 'a' && ch <= 'z') ||
(ch >= 'A' && ch <= 'Z') ||
ch == '\\');
tokenText[len] = '\0';
- pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
- yylvalpp->atom = pp->LookUpAddString(tokenText);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, ppToken);
+ ppToken->atom = pp->LookUpAddString(tokenText);
return CPP_IDENTIFIER;
case '0':
- yylvalpp->name[len++] = ch;
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ppToken->name[len++] = ch;
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
if (ch == 'x' || ch == 'X') {
// must be hexidecimal
bool isUnsigned = false;
- yylvalpp->name[len++] = ch;
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ppToken->name[len++] = ch;
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
if ((ch >= '0' && ch <= '9') ||
(ch >= 'A' && ch <= 'F') ||
(ch >= 'a' && ch <= 'f'))
ival = 0;
do {
if (ival <= 0x0fffffff) {
- yylvalpp->name[len++] = ch;
+ ppToken->name[len++] = ch;
if (ch >= '0' && ch <= '9') {
ii = ch - '0';
} else if (ch >= 'A' && ch <= 'F') {
} else if (ch >= 'a' && ch <= 'f') {
ii = ch - 'a' + 10;
} else
- pp->parseContext.error(yylvalpp->loc, "bad digit in hexidecimal literal", "", "");
+ pp->parseContext.error(ppToken->loc, "bad digit in hexidecimal literal", "", "");
ival = (ival << 4) | ii;
} else {
if (! AlreadyComplained) {
- pp->parseContext.error(yylvalpp->loc, "hexidecimal literal too big", "", "");
+ pp->parseContext.error(ppToken->loc, "hexidecimal literal too big", "", "");
AlreadyComplained = 1;
}
ival = 0xffffffff;
}
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
} while ((ch >= '0' && ch <= '9') ||
(ch >= 'A' && ch <= 'F') ||
(ch >= 'a' && ch <= 'f'));
} else {
- pp->parseContext.error(yylvalpp->loc, "bad digit in hexidecimal literal", "", "");
+ pp->parseContext.error(ppToken->loc, "bad digit in hexidecimal literal", "", "");
}
if (ch == 'u' || ch == 'U') {
if (len < TPpToken::maxTokenLength)
- yylvalpp->name[len++] = ch;
+ ppToken->name[len++] = ch;
isUnsigned = true;
} else
- pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
- yylvalpp->name[len] = '\0';
- yylvalpp->ival = (int)ival;
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, ppToken);
+ ppToken->name[len] = '\0';
+ ppToken->ival = (int)ival;
if (isUnsigned)
return CPP_UINTCONSTANT;
// see how much octal-like stuff we can read
while (ch >= '0' && ch <= '7') {
if (len < TPpToken::maxTokenLength)
- yylvalpp->name[len++] = ch;
+ ppToken->name[len++] = ch;
else if (! AlreadyComplained) {
- pp->parseContext.error(yylvalpp->loc, "numeric literal too long", "", "");
+ pp->parseContext.error(ppToken->loc, "numeric literal too long", "", "");
AlreadyComplained = 1;
}
if (ival <= 0x1fffffff) {
ival = (ival << 3) | ii;
} else
octalOverflow = true;
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
}
// could be part of a float...
nonOctal = true;
do {
if (len < TPpToken::maxTokenLength)
- yylvalpp->name[len++] = ch;
+ ppToken->name[len++] = ch;
else if (! AlreadyComplained) {
- pp->parseContext.error(yylvalpp->loc, "numeric literal too long", "", "");
+ pp->parseContext.error(ppToken->loc, "numeric literal too long", "", "");
AlreadyComplained = 1;
}
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
} while (ch >= '0' && ch <= '9');
}
if (ch == '.' || ch == 'e' || ch == 'f' || ch == 'E' || ch == 'F' || ch == 'l' || ch == 'L')
- return pp->lFloatConst(yylvalpp->name, len, ch, yylvalpp);
+ return pp->lFloatConst(ppToken->name, len, ch, ppToken);
// wasn't a float, so must be octal...
if (nonOctal)
- pp->parseContext.error(yylvalpp->loc, "octal literal digit too large", "", "");
+ pp->parseContext.error(ppToken->loc, "octal literal digit too large", "", "");
if (ch == 'u' || ch == 'U') {
if (len < TPpToken::maxTokenLength)
- yylvalpp->name[len++] = ch;
+ ppToken->name[len++] = ch;
isUnsigned = true;
} else
- pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
- yylvalpp->name[len] = '\0';
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, ppToken);
+ ppToken->name[len] = '\0';
if (octalOverflow)
- pp->parseContext.error(yylvalpp->loc, "octal literal too big", "", "");
+ pp->parseContext.error(ppToken->loc, "octal literal too big", "", "");
- yylvalpp->ival = (int)ival;
+ ppToken->ival = (int)ival;
if (isUnsigned)
return CPP_UINTCONSTANT;
do {
if (len < TPpToken::maxTokenLength)
- yylvalpp->name[len++] = ch;
+ ppToken->name[len++] = ch;
else if (! AlreadyComplained) {
- pp->parseContext.error(yylvalpp->loc, "numeric literal too long", "", "");
+ pp->parseContext.error(ppToken->loc, "numeric literal too long", "", "");
AlreadyComplained = 1;
}
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
} while (ch >= '0' && ch <= '9');
if (ch == '.' || ch == 'e' || ch == 'f' || ch == 'E' || ch == 'F' || ch == 'l' || ch == 'L') {
- return pp->lFloatConst(yylvalpp->name, len, ch, yylvalpp);
+ return pp->lFloatConst(ppToken->name, len, ch, ppToken);
} else {
// Finish handling signed and unsigned integers
int numericLen = len;
int uint = 0;
if (ch == 'u' || ch == 'U') {
if (len < TPpToken::maxTokenLength)
- yylvalpp->name[len++] = ch;
+ ppToken->name[len++] = ch;
uint = 1;
} else
- pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, ppToken);
- yylvalpp->name[len] = '\0';
+ ppToken->name[len] = '\0';
ival = 0;
for (ii = 0; ii < numericLen; ii++) {
- ch = yylvalpp->name[ii] - '0';
+ ch = ppToken->name[ii] - '0';
if ((ival > 429496729) || (ival == 429496729 && ch >= 6)) {
- pp->parseContext.error(yylvalpp->loc, "numeric literal too big", "", "");
+ pp->parseContext.error(ppToken->loc, "numeric literal too big", "", "");
ival = -1;
break;
} else
ival = ival * 10 + ch;
}
- yylvalpp->ival = (int)ival;
+ ppToken->ival = (int)ival;
if (uint)
return CPP_UINTCONSTANT;
}
break;
case '-':
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
if (ch == '-') {
return CPP_DEC_OP;
} else if (ch == '=') {
return CPP_SUB_ASSIGN;
} else {
- pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, ppToken);
return '-';
}
case '+':
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
if (ch == '+') {
return CPP_INC_OP;
} else if (ch == '=') {
return CPP_ADD_ASSIGN;
} else {
- pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, ppToken);
return '+';
}
case '*':
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
if (ch == '=') {
return CPP_MUL_ASSIGN;
} else {
- pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, ppToken);
return '*';
}
case '%':
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
if (ch == '=') {
return CPP_MOD_ASSIGN;
} else if (ch == '>'){
return CPP_RIGHT_BRACE;
} else {
- pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, ppToken);
return '%';
}
case ':':
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
if (ch == '>') {
return CPP_RIGHT_BRACKET;
} else {
- pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, ppToken);
return ':';
}
case '^':
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
if (ch == '^') {
return CPP_XOR_OP;
} else {
if (ch == '=')
return CPP_XOR_ASSIGN;
else{
- pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, ppToken);
return '^';
}
}
case '=':
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
if (ch == '=') {
return CPP_EQ_OP;
} else {
- pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, ppToken);
return '=';
}
case '!':
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
if (ch == '=') {
return CPP_NE_OP;
} else {
- pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, ppToken);
return '!';
}
case '|':
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
if (ch == '|') {
return CPP_OR_OP;
} else {
if (ch == '=')
return CPP_OR_ASSIGN;
else{
- pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, ppToken);
return '|';
}
}
case '&':
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
if (ch == '&') {
return CPP_AND_OP;
} else {
if (ch == '=')
return CPP_AND_ASSIGN;
else{
- pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, ppToken);
return '&';
}
}
case '<':
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
if (ch == '<') {
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
if (ch == '=')
return CPP_LEFT_ASSIGN;
else{
- pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, ppToken);
return CPP_LEFT_OP;
}
} else {
else if (ch == ':')
return CPP_LEFT_BRACKET;
else{
- pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, ppToken);
return '<';
}
}
}
case '>':
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
if (ch == '>') {
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
if (ch == '=')
return CPP_RIGHT_ASSIGN;
else{
- pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, ppToken);
return CPP_RIGHT_OP;
}
} else {
if (ch == '=') {
return CPP_GE_OP;
} else {
- pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, ppToken);
return '>';
}
}
case '.':
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
if (ch >= '0' && ch <= '9') {
- pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
- return pp->lFloatConst(yylvalpp->name, 0, '.', yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, ppToken);
+ return pp->lFloatConst(ppToken->name, 0, '.', ppToken);
} else {
- pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, ppToken);
return '.';
}
case '/':
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
if (ch == '/') {
do {
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
if (ch == '\\') {
// allow an escaped newline, otherwise escapes in comments are meaningless
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
if (ch == '\r' || ch == '\n') {
- int nextch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ int nextch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
if (ch == '\r' && nextch == '\n')
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
else
ch = nextch;
}
return '\n';
} else if (ch == '*') {
int nlcount = 0;
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
do {
while (ch != '*') {
if (ch == '\n')
nlcount++;
if (ch == EOF) {
- pp->parseContext.error(yylvalpp->loc, "EOF in comment", "comment", "");
+ pp->parseContext.error(ppToken->loc, "EOF in comment", "comment", "");
return EOF;
}
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
}
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
if (ch == EOF) {
- pp->parseContext.error(yylvalpp->loc, "EOF in comment", "comment", "");
+ pp->parseContext.error(ppToken->loc, "EOF in comment", "comment", "");
return EOF;
}
} else if (ch == '=') {
return CPP_DIV_ASSIGN;
} else {
- pp->currentInput->ungetch(pp, pp->currentInput, ch, yylvalpp);
+ pp->currentInput->ungetch(pp, pp->currentInput, ch, ppToken);
return '/';
}
break;
case '"':
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
while (ch != '"' && ch != '\n' && ch != EOF) {
if (ch == '\\') {
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
if (ch == '\n' || ch == EOF) {
break;
}
if (len < TPpToken::maxTokenLength) {
tokenText[len] = ch;
len++;
- ch = pp->currentInput->getch(pp, pp->currentInput, yylvalpp);
+ ch = pp->currentInput->getch(pp, pp->currentInput, ppToken);
} else
break;
};
tokenText[len] = '\0';
if (ch == '"') {
- yylvalpp->atom = pp->LookUpAddString(tokenText);
+ ppToken->atom = pp->LookUpAddString(tokenText);
return CPP_STRCONSTANT;
} else {
- pp->parseContext.error(yylvalpp->loc, "end of line in string", "string", "");
+ pp->parseContext.error(ppToken->loc, "end of line in string", "string", "");
return CPP_ERROR_SY;
}
}
}
} // byte_scan
-const char* TPpContext::tokenize(TPpToken* yylvalpp)
+const char* TPpContext::tokenize(TPpToken* ppToken)
{
int token = '\n';
for(;;) {
const char* tokenString = 0;
- token = currentInput->scan(this, currentInput, yylvalpp);
- yylvalpp->ppToken = token;
+ token = currentInput->scan(this, currentInput, ppToken);
+ ppToken->token = token;
if (check_EOF(token))
return 0;
if (token == '#') {
if (previous_token == '\n' || previous_token == 0) {
- token = readCPPline(yylvalpp);
+ token = readCPPline(ppToken);
if (check_EOF(token))
return 0;
continue;
} else {
- parseContext.error(yylvalpp->loc, "preprocessor directive cannot be preceded by another token", "#", "");
+ parseContext.error(ppToken->loc, "preprocessor directive cannot be preceded by another token", "#", "");
return 0;
}
}
notAVersionToken = true;
// expand macros
- if (token == CPP_IDENTIFIER && MacroExpand(yylvalpp->atom, yylvalpp, 0) == 1)
+ if (token == CPP_IDENTIFIER && MacroExpand(ppToken->atom, ppToken, 0) == 1)
continue;
if (token == CPP_IDENTIFIER)
- tokenString = GetAtomString(yylvalpp->atom);
+ tokenString = GetAtomString(ppToken->atom);
else if (token == CPP_INTCONSTANT || token == CPP_UINTCONSTANT ||
token == CPP_FLOATCONSTANT || token == CPP_DOUBLECONSTANT)
- tokenString = yylvalpp->name;
+ tokenString = ppToken->name;
else
tokenString = GetAtomString(token);