@Override public ParseResult parse(final TokenList tokens, final int templatePos) { final Object o1 = tokens.get(templatePos); final Object o2 = tokens.get(templatePos + 2); QuotedString ret; if ((o1 instanceof QuotedString) && (o2 instanceof QuotedString)) { ret = new QuotedString(((QuotedString) o1).value + ((QuotedString) o2).value); } else if (o1 instanceof QuotedString) { ret = new QuotedString(((QuotedString) o1).value + o2.toString()); } else if (o2 instanceof QuotedString) { ret = new QuotedString(o1.toString() + ((QuotedString) o2).value); } else return ParseResult.fail(); return ParseResult.success( tokens.replaceWithTokens(templatePos, templatePos + template.size(), ret)); }
@Override public ParseResult parse(final TokenList tokens, final int templatePos) { final Object num = tokens.get(templatePos); final long li = num instanceof LargeInteger ? ((LargeInteger) tokens.get(templatePos)).longValue() : ((Radix) num).integer; final String convertTo = (String) tokens.get(templatePos + 2); Object result; if (convertTo.startsWith("bin")) { result = new Radix(li, 2); } else if (convertTo.startsWith("hex")) { result = new Radix(li, 16); } else if (convertTo.startsWith("oct")) { result = new Radix(li, 8); } else { result = LargeInteger.valueOf(li); } return ParseResult.success( tokens.replaceWithTokens(templatePos, templatePos + template.size(), result)); }