View/Edit #35:unparse_key

Switch to edit mode.

Name(s): unparse_key
1:  key = args[1]
2:  type = typeof(key)
3:  if (!(type in {$LIST, $OBJ}))
4:    return "(None.)"
5:  elseif (type == $OBJ)
6:    "Slight changes made to output --Dax"
7:    if (valid(key))
8:      return $find_ref(key) || key:nn()
9:      return tostr(key, "[", key.name, "]")
10:   else
11:     return tostr($find_ref(key) || key)
12:     return tostr(key)
13:   endif
14: else
15:   op = key[1]
16:   arg1 = this:unparse_key(key[2])
17:   if (op == "?")
18:     return "?" + arg1
19:   elseif (op == "^")
20:     return "^" + arg1
21:   elseif (op == "!")
22:     if (typeof(key[2]) == $LIST)
23:       return "!(" + arg1 + ")"
24:     else
25:       return "!" + arg1
26:     endif
27:   elseif (op in {"&&", "||"})
28:     other = op == "&&" ? "||" | "&&"
29:     lhs = arg1
30:     rhs = this:unparse_key(key[3])
31:     if (typeof(key[2]) == $OBJ || key[2][1] != other)
32:       exp = lhs
33:     else
34:       exp = "(" + lhs + ")"
35:     endif
36:     exp = exp + " " + op + " "
37:     if (typeof(key[3]) == $OBJ || key[3][1] != other)
38:       exp = exp + rhs
39:     else
40:       exp = exp + "(" + rhs + ")"
41:     endif
42:     return exp
43:   else
44:     raise(E_INVARG)
45:   endif
46: endif
47: "Last modified by Dax (#789) on Mon Aug  7 21:54:09 2006 MDT."

Verb arguments: this none this
Verb perms: Readable eXecutable NOT-Debug
Verb owned by: Hacker (#60)

You are not logged in.

[home | help | who | search | setup | code]