开发者

Composing data-structures/strings matching a CFG

The JSON syntax is an example of a CFG (Context free grammar).

Va开发者_JS百科lid JSON strings are a sequence of tokens constrained to a CFG... or, the tokens can -equivalently- be thought of as a structure of nested values.

Valid JSON strings can be sequentially composed to produce a new valid JSON string - but this is not the only way existing strings can be combined. If the first string were an array, the second string could be 'inserted' as a new value at any position in the array - and strings can be composed into an infinite number of distinct new strings with the addition only of arrays. By carefully choosing where to insert one string into an array in another, a large number of other possibilities are revealed.

I'm interested to establish a taxonomy of the ways in which valid strings can be composed. I'm interested in all the compositions of values. I accept that a composition may require introduction of new characters such as ',' - to insert a value into an array.

It strikes me that this is a sufficiently fundamental question that there is likely (at least one) standard answer. Does anyone know what I should look up?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜