mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 06:45:43 +02:00
Fixed handling of defined() in expression evaluator.
This commit is contained in:
parent
2164ad4e15
commit
a259c14511
2 changed files with 16 additions and 3 deletions
|
@ -878,7 +878,8 @@ public class Scanner2Test extends BaseScanner2Test
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
validateEOF();
|
validateEOF();
|
||||||
fail(EXPECTED_FAILURE);
|
// These are no longer scanner exceptions, the are simply ignored.
|
||||||
|
//fail(EXPECTED_FAILURE);
|
||||||
}
|
}
|
||||||
catch (ScannerException se)
|
catch (ScannerException se)
|
||||||
{
|
{
|
||||||
|
|
|
@ -241,7 +241,7 @@ public class ExpressionEvaluator {
|
||||||
int limit = bufferLimit[bufferStackPos];
|
int limit = bufferLimit[bufferStackPos];
|
||||||
|
|
||||||
// check first character
|
// check first character
|
||||||
int c = buffer[++bufferPos[bufferStackPos]];
|
char c = buffer[++bufferPos[bufferStackPos]];
|
||||||
if (!((c >= 'A' && c <= 'Z') || c == '_' || (c >= 'a' && c <= 'z'))) {
|
if (!((c >= 'A' && c <= 'Z') || c == '_' || (c >= 'a' && c <= 'z'))) {
|
||||||
throw new EvalException("illegal identifier in defined()");
|
throw new EvalException("illegal identifier in defined()");
|
||||||
}
|
}
|
||||||
|
@ -250,12 +250,14 @@ public class ExpressionEvaluator {
|
||||||
int idstart = bufferPos[bufferStackPos];
|
int idstart = bufferPos[bufferStackPos];
|
||||||
int idlen = 1;
|
int idlen = 1;
|
||||||
while (++bufferPos[bufferStackPos] < limit) {
|
while (++bufferPos[bufferStackPos] < limit) {
|
||||||
if ((c >= 'A' && c <= 'Z') || c == '_' || (c >= 'a' && c <= 'z') || (c >= '0' || c <= '9')) {
|
c = buffer[bufferPos[bufferStackPos]];
|
||||||
|
if ((c >= 'A' && c <= 'Z') || c == '_' || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9')) {
|
||||||
++idlen;
|
++idlen;
|
||||||
continue;
|
continue;
|
||||||
} else
|
} else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
--bufferPos[bufferStackPos];
|
||||||
|
|
||||||
// consume to the closing paren;
|
// consume to the closing paren;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -286,6 +288,8 @@ public class ExpressionEvaluator {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static char[] _defined = "defined".toCharArray();
|
||||||
|
|
||||||
private void nextToken() throws EvalException {
|
private void nextToken() throws EvalException {
|
||||||
contextLoop:
|
contextLoop:
|
||||||
while (bufferStackPos >= 0) {
|
while (bufferStackPos >= 0) {
|
||||||
|
@ -374,6 +378,14 @@ public class ExpressionEvaluator {
|
||||||
|
|
||||||
--bufferPos[bufferStackPos];
|
--bufferPos[bufferStackPos];
|
||||||
|
|
||||||
|
// Check for defined(
|
||||||
|
pos = bufferPos[bufferStackPos];
|
||||||
|
if (pos + 1 < limit && buffer[pos + 1] == '('
|
||||||
|
&& CharArrayUtils.equals(buffer, start, len, _defined)) {
|
||||||
|
tokenType = t_defined;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Check for macro expansion
|
// Check for macro expansion
|
||||||
Object expObject = null;
|
Object expObject = null;
|
||||||
if (bufferData[bufferStackPos] instanceof FunctionStyleMacro.Expansion) {
|
if (bufferData[bufferStackPos] instanceof FunctionStyleMacro.Expansion) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue