*/
private void throwSyntaxError(String error) {
int problemStartPosition = scanner.getCurrentTokenStartPosition();
- int problemEndPosition = scanner.getCurrentTokenEndPosition();
- throwSyntaxError(error, problemStartPosition, problemEndPosition + 1);
+ int problemEndPosition = scanner.getCurrentTokenEndPosition() + 1;
+ if (scanner.source.length <= problemEndPosition && problemEndPosition > 0) {
+ problemEndPosition = scanner.source.length - 1;
+ if (problemStartPosition > 0 && problemStartPosition >= problemEndPosition && problemEndPosition > 0) {
+ problemStartPosition = problemEndPosition - 1;
+ }
+ }
+ throwSyntaxError(error, problemStartPosition, problemEndPosition);
}
/**
throwSyntaxError("End-of-file not reached.");
}
break;
- } catch (SyntaxError sytaxErr1) {
+ } catch (SyntaxError syntaxError) {
+ // syntaxError.printStackTrace();
break;
- // // if an error occured,
- // // try to find keywords 'abstract' 'final' 'class' or 'function'
- // // to parse the rest of the string
- // boolean tokenize = scanner.tokenizeStrings;
- // if (!tokenize) {
- // scanner.tokenizeStrings = true;
- // }
- // try {
- // while (token != TokenNameEOF) {
- // if (token == TokenNameabstract || token == TokenNamefinal || token == TokenNameclass || token == TokenNamefunction) {
- // break;
- // }
- // getNextToken();
- // }
- // if (token == TokenNameEOF) {
- // break;
- // }
- // } catch (SyntaxError sytaxErr2) {
- // break;
- // } finally {
- // scanner.tokenizeStrings = tokenize;
- // }
}
} while (true);
}
return statement;
} else if (token == TokenNameINLINE_HTML) {
- getNextToken();
+ if (scanner.phpExpressionTag) {
+ // start of <?= ... ?> block
+ getNextToken();
+ expr();
+ if (token == TokenNameSEMICOLON) {
+ getNextToken();
+ }
+ if (token != TokenNameINLINE_HTML) {
+ throwSyntaxError("Missing '?>' for open PHP expression block ('<?=').");
+ }
+ } else {
+ getNextToken();
+ }
return statement;
// } else if (token == TokenNameprint) {
// getNextToken();
case TokenNameIdentifier:
case TokenNameVariable:
case TokenNameDOLLAR:
- boolean rememberedVar = false;
+ boolean rememberedVar = false;
Expression lhs = variable(true, true);
if (lhs != null && lhs instanceof FieldReference && token != TokenNameEQUAL && token != TokenNamePLUS_EQUAL
&& token != TokenNameMINUS_EQUAL && token != TokenNameMULTIPLY_EQUAL && token != TokenNameDIVIDE_EQUAL
getNextToken();
break;
} else {
+ // System.out.println(scanner.getCurrentTokenStartPosition());
+ // System.out.println(scanner.getCurrentTokenEndPosition());
+
throwSyntaxError("Error in expression (found token '" + scanner.toStringAction(token) + "').");
}
}