Am 29.07.2015 um 20:44 schrieb Walter Bright:
On 7/29/2015 1:37 AM, Sönke Ludwig wrote:
There are actually even four levels:
1. Range of characters
2. Range of tokens
3. Range of nodes
4. DOM value
What's the need for users to see a token stream? I don't know what the
DOM value is - is that just JSON as an ast?
Yes.
Having a special case for range of DOM values may or may not be a
worthwhile
thing to optimize for handling big JSON arrays of values.
I see no point for that.
Hm, I misread "container of JSON values" as "range of JSON values". I
guess you just meant JSONValue, so my comment doesn't apply.
Currently not all, but most, conversions between the levels are
implemented, and
sometimes a level is skipped for efficiency. The question is if it
would be
worth the effort and the API complexity to implement all of them.
lexJSON: character range -> token range
parseJSONStream: character range -> node range
parseJSONStream: token range -> node range
parseJSONValue: character range -> DOM value
parseJSONValue: token range -> DOM value (same for toJSONValue)
writeJSON: token range -> character range (output range)
writeJSON: node range -> character range (output range)
writeJSON: DOM value -> character range (output range)
writeJSON: to -> character range (output range)
(same for toJSON with string output)
I don't see why there are more than the 3 I mentioned.
The token level is useful for reasoning about the text representation.
It could be used for example to implement syntax highlighting, or for
using the location information to mark errors in the source code.