Anonymous user
JSON: Difference between revisions
m
→{{header|Tailspin}}: readability tweaks
(Added Wren) |
m (→{{header|Tailspin}}: readability tweaks) |
||
Line 3,973:
templates hexToInt
templates hexDigit
<='0'> 0! <='1'> 1! <='2'> 2! <='3'> 3! <='4'> 4! <='5'> 5! <='6'> 6! <='7'> 7! <='8'> 8! <='9'> 9!
<'[Aa]'> 10! <'[Bb]'> 11! <'[Cc]'> 12! <'[Dd]'> 13! <'[Ee]'> 14! <'[Ff]'> 15!
end hexDigit
Line 3,985:
rule value: (<WS>?) <string|number|object|array|true|false|null> (<WS>?)
rule string: (<='"'>) <chars> (<='"'>)
rule chars: [ <quote|backslash|slash|backspace|formfeed|linefeed|return|tab|unicode|'[^"]'>* ] -> '$...;'
rule quote: <='
rule backslash: <='
rule slash: <='
rule backspace: <='
rule formfeed: <='
rule linefeed: <='
rule return: <='
rule tab: <='
rule unicode: (<='
rule number: <'-?(0|[1-9][0-9]*)(\.[0-9]+)?((e|E)(\+|-)?[0-9]+)?'> // TODO: represent this other than string
rule object: (<='
rule keyValues: <keyValue> <followingKeyValue>*
rule keyValue: <string>: (<WS>? <=':'>) <value>
rule followingKeyValue: (<=','> <WS>?) <keyValue>
rule array: (<='
rule arrayValues: <value> <followingArrayValue>*
rule followingArrayValue: (<=','>) <value>
rule true: <='true'> // TODO: represent this other than string
rule false: <='false'> // TODO: represent this other than string
rule null: <='null'> // TODO: represent this other than string
end jsonParser
Line 4,018:
end printKeyValue
templates encodeChars
<='"'> '\"' !
<='
<='/'> '\/' !
<='$#8;'> '\b' !
<='$#12;'> '\f' !
<='$#10;'> '\n' !
<='$#13;'> '\r' !
<='$#9;'> '\t' !
<> $ !
end encodeChars
Line 4,040:
// Other types do not yet exist in Tailspin
end printJson
'{ "foo": 1, "bar": [10, "apples"] }' -> jsonParser -> '$.bar(2);
' -> !OUT::write
{ blue: [1,2], ocean: 'water' } -> printJson -> '$;
' -> !OUT::write
|