... | @@ -59,17 +59,34 @@ ND BixNum[0] .................... |
... | @@ -59,17 +59,34 @@ ND BixNum[0] .................... |
|
Assume that `valueToken` is a bit stream that marks the end position of
|
|
Assume that `valueToken` is a bit stream that marks the end position of
|
|
any legal JSON numeral, string or keyword, then the example above would look like:
|
|
any legal JSON numeral, string or keyword, then the example above would look like:
|
|
```
|
|
```
|
|
valueToken ...................1
|
|
valueToken ...................1.
|
|
|
|
EOFbit ....................1
|
|
```
|
|
```
|
|
|
|
|
|
Then we can validate if we have valid non-nesting values by checking:
|
|
Then we can validate if we have valid non-nesting values by checking:
|
|
|
|
|
|
```
|
|
```
|
|
otherND = bnc.UGT(ND, 0)
|
|
otherND = bnc.UGT(ND, 0)
|
|
|
|
zeroND = bnc.EQ(ND, 0);
|
|
begin = ~Advance(<1>, 1)
|
|
begin = ~Advance(<1>, 1)
|
|
firstValue = ScanTo(begin, valueToken)
|
|
valueAtZero = valueToken & zeroND
|
|
nonNestingValue = ScanTo(Advance(firstValue, 1), valueToken)
|
|
stopAtEOF = ~EOFbit
|
|
errSimpleValue = nonNestingValue & ~otherND
|
|
|
|
|
|
// If we have simple value at depth 0, we cannot have any other token
|
|
|
|
firstValue = ScanTo(begin, valueAtZero)
|
|
|
|
nonNestedValue = ScanTo(Advance(firstValue, 1), anyToken)
|
|
|
|
errValue = ScanThru(Advance(nonNestedValue, 1), stopAtEOF)
|
|
|
|
|
|
|
|
// If we have any symbol, we cannot have any value at depth 0
|
|
|
|
firstSymbol = ScanTo(begin, symbols)
|
|
|
|
valueAtZeroAfterSymbol = ScanTo(Advance(firstSymbol, 1), valueAtZero)
|
|
|
|
errSymbol = ScanThru(Advance(valueAtZeroAfterSymbol, 1), stopAtEOF)
|
|
|
|
|
|
|
|
// EOFbit is always at depth 0, otherwise we have unmatched parens
|
|
|
|
errEOF = EOFbit & otherND
|
|
|
|
|
|
|
|
// combine all possible errors at depth zero
|
|
|
|
errSimpleValue = errValue | errSymbol | errEOF
|
|
```
|
|
```
|
|
|
|
|
|
|
|
|
... | | ... | |