formula = aFormula;
final ArrayList images = new ArrayList();
try
{
int brackets = 0;
final GeneratedFormulaParserTokenManager tokenParser = new GeneratedFormulaParserTokenManager(new JavaCharStream(new StringReader(formula), 1, 1));
Token token = tokenParser.getNextToken();
while (token.kind != GeneratedFormulaParserConstants.EOF)
{
final FormulaToken formulaToken;
images.add(token.image);
final String upper = token.image.toUpperCase();
if ( parserNames.containsKey(upper) )
{
if ( token.image.equals("("))
brackets++;
else if ( token.image.equals(")"))
--brackets;
final FormulaOpCodeMapEntry opCode = (FormulaOpCodeMapEntry) parserNames.get(upper);
formulaToken = opCode.Token;
}
else if ( token.kind == GeneratedFormulaParserConstants.WHITESPACE )
{
final FormulaOpCodeMapEntry opCode = (FormulaOpCodeMapEntry) specialOpCodes.get(FormulaMapGroupSpecialOffset.SPACES);
formulaToken = opCode.Token;
}
else
{
formulaToken = new FormulaToken();
formulaToken.OpCode = opCodePush.Token.OpCode;
formulaToken.Data = new Any(Type.STRING, token.image);
}
tokens.add(formulaToken);
token = tokenParser.getNextToken();
}
if ( brackets > 0 )
{
final FormulaOpCodeMapEntry opCode = (FormulaOpCodeMapEntry) parserNames.get(")");
while ( brackets-- != 0 )