throws CalculateFormulaException {
String originalFormula = formula;
int maxTries = 10;
// Get actual Errors
CharStream stream = new ANTLRStringStream(formula);
metricsGrammarLexer lexer = new metricsGrammarLexer(stream);
TokenStream tokenStream = new CommonTokenStream(lexer);
metricsGrammarParser parser = new metricsGrammarParser(tokenStream, mc,
stack, doNotDisplay, syntaxCheck);
try {
parser.evaluator();
} catch (NestedCalculateFormulaException ncfe) {
ArrayList<MismatchedTokenException> oldList = ncfe
.getMismatchedTokenExceptions();
ArrayList<String> missingChar = new ArrayList<String>();
int numberOfItemsStart;
int numberOfItemsEnd;
do {
maxTries--;
numberOfItemsStart = missingChar.size();
for (MismatchedTokenException mmte : oldList) {
if (mmte.c == Token.EOF) {
try {
if (AntlrException.getTokenList()[mmte.expecting]
.equals("')'")) {
formula = formula + ")";
missingChar.add(")");
}
} catch (ArrayIndexOutOfBoundsException aioob) {
}
}
}
CharStream stream2 = new ANTLRStringStream(formula);
metricsGrammarLexer lexer2 = new metricsGrammarLexer(stream2);
TokenStream tokenStream2 = new CommonTokenStream(lexer2);
metricsGrammarParser parser2 = new metricsGrammarParser(
tokenStream2, mc, stack, doNotDisplay, syntaxCheck);
try {
parser2.evaluator();