Advertisement
GroggyOtter

from if to ternary part 1

Jun 30th, 2023
1,536
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. case xval:
  2.    v:
  3.     (char == '{') ? (o := Map(), (path[path.Length] is Array) ? path[path.Length].Push(o) : path[path.Length][key] := o, path.Push(o), expect := xobj, ji++)
  4.     : (char == '[') ? (a := [], (path[path.Length] is Array) ? path[path.Length].Push(a) : path[path.Length][key] := a, path.Push(a), expect := xarr, ji++)
  5.     : (char == str_flag) ? (end := InStr(jtxt, str_flag, 1, ji+1)) ? is_key ? (is_key := 0, key := SubStr(jtxt, ji+1, end-ji-1), expect := xcln, ji := end+1) : (rev(SubStr(jtxt, ji+1, end-ji-1)), expect := xend, ji := end+1) : err(24, ji, '"', SubStr(jtxt, ji))
  6.    : InStr('-0123456789', char, 1) ? RegExMatch(jtxt, '(-?(?:0|[123456789]\d*)(?:\.\d+)?(?:[eE][-+]?\d+)?)', &match, ji) ? (rev(Number(match[])), expect := xend, ji := match.Pos + match.Len ) : err(25, ji, , SubStr(jtxt, ji))
  7.    : (char == 't') ? (SubStr(jtxt, ji, 4) == 'true')  ? (rev(true) , ji+=4, expect := xend) : err(26, ji + tfn_idx('true', SubStr(jtxt, ji, 4)), 'true' , SubStr(jtxt, ji, 4))
  8.    : (char == 'f') ? (SubStr(jtxt, ji, 5) == 'false') ? (rev(false), ji+=5, expect := xend) : err(27, ji + tfn_idx('false', SubStr(jtxt, ji, 5)), 'false', SubStr(jtxt, ji, 5))
  9.    : (char == 'n') ? (SubStr(jtxt, ji, 4) == 'null')  ? (rev(null) , ji+=4, expect := xend) : err(28, ji + tfn_idx('null', SubStr(jtxt, ji, 4)), 'null' , SubStr(jtxt, ji, 4))
  10.    : err(29, ji, '`n`tArray: [ `n`tObject: { `n`tString: " `n`tNumber: -0123456789 `n`ttrue/false/null: tfn ', char)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement