@SuppressWarnings({ "rawtypes", "unchecked" })
    private <T> T parsePrimitive(ClassAccessor<T> clazz, Symbol sym, TokenStream stream) {
        try {
            if (clazz.subclassOf(String.class)) {
                return (T) getNextToken(stream);
            } else if (clazz.subclassOf(int.class)) {
                return (T) Integer.valueOf(getNextToken(stream));
            } else if (clazz.subclassOf(long.class)) {
                return (T) Long.valueOf(getNextToken(stream));
            } else if (clazz.subclassOf(double.class)) {
                return (T) Double.valueOf(getNextToken(stream));
            } else if (clazz.subclassOf(List.class)) {
                if (sym == null)
                    throw new ParseException("Cannot parse list class without @Symbol annotation.");
                return (T) parseList(sym.padding(), new ClassAccessor(sym.subtype()), stream, sym.ignoreCase());
            } else {
                throw new ParseException("Invalid type for primitive: " + clazz.getName());
            }
        } catch (ParseException e) {
            throw e;
        } catch (Exception e) {
            throw new ParseException("Could not parse primitive of type " + clazz.getName(), e);
        }
    }