public void parse() {
            skipSpace();
            if (string.charAt(position) != '[') {
                int stopPos = stopCharIndex(position);
                String hexToken = string.substring(position, stopPos);
                if (validHexString(builder.type(), hexToken)) {
                    double[] values = decodeHexString(hexToken, builder.type().valueType());
                    int i = 0;
                    while (indexes.hasNext()) {
                        indexes.next();
                        builder.cellByDirectIndex(indexes.toSourceValueIndex(), values[i++]);
                    }
                    if (i != values.length) {
                        throw new IllegalStateException("consume " + i + " values out of " + values.length);
                    }
                    position = stopPos;
                    return;
                }
            }
            if (!hasInnerStructure)
                consume('[');

            while (indexes.hasNext()) {
                indexes.next();
                for (int i = 0; i < indexes.nextDimensionsAtStart() && hasInnerStructure; i++)
                    consume('[');
                consumeNumber();
                for (int i = 0; i < indexes.nextDimensionsAtEnd() && hasInnerStructure; i++)
                    consume(']');
                if (indexes.hasNext())
                    consume(',');
            }

            if (!hasInnerStructure)
                consume(']');
        }
A single-use dense tensor string parser
vespajlib/src/main/java/com/yahoo/tensor/TensorParser.java