The attached code creates a number of stale values.
#!/usr/local/bin/apl --script
 ⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝
⍝
⍝ stale 2016-07-04 22:15:49 (GMT-7)
⍝
 ⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝

∇ucmd_args pkg args;⎕io;_cmd_info;_verbs;verb;action;rc;pm
 ⍝ This is the APL Package Manager's top-level command dispatcher.
 ⎕io←1
 ⍎(0≠⎕nc 'ucmd_args')/'args←1↓ucmd_args'
 ⍎(1=≡args)/'args←⊂args'
 _cmd_info←pkg_cmd_info
 _verbs←1⊃¨_cmd_info
 verb←_verbs pkg⍙prefix_match 1↑args
 action←(_verbs∊verb)/_verbs
 →(0=⍴action)/unmatched
 args←1↓args
 rc←⍎'pkg⍙cmd_',(↑action),' args'
 →rc/0
 usage:
 ⎕←'usage:',((1⊃¨_cmd_info)⍳action)⊃_cmd_info
 →0
 unmatched:
 →(0=⍴⍴args)/show
 ⎕←⊂'Unrecognized command'
 pm←_verbs pkg⍙prefix_matches 1↑args
 →(0=⍴pm)/0
 ⎕←'Possibly:',pm
 →0
 show:
 pkg⍙sink pkg⍙cmd_help ''
∇

∇z←pkg⍙alp
 z←'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
∇

∇z←pkg⍙dig
 z←'1234567890'
∇

∇z←pkg⍙id1
 z←'⎕∆⍙_'
∇

∇z←pkg⍙idX
 z←'∆⍙_¯'
∇

∇z←pkg⍙nu1
 z←'¯'
∇

∇z←pkg⍙nuX
 z←'JE¯.'
∇

∇z←pkg⍙empty_string text;m
 ⍝ Remove content from quoted string, leaving only a pair of quotes.
 ⍝ This is useful to hide quoted text from analysis.
 z←((¯1⌽m)∨m←~≠\text='''')/text
 z←(~2↓(m,0 0)∧(0 0,m←z=''''))/z
∇

∇z←(pred pkg⍙filter1) list
 ⍝ Filter items of list according to unary predicate.
 z←(,⊃pred¨list)/list
∇

∇z←pkg⍙function_refs func;labels;name;locals;tokens;ids
 ⍝ For a function expressed as a list of lines, return a list of all
 ⍝ nonlocal names used in the function.
 z←labels←⍬
 (name locals)←pkg⍙header_info pkg⍙parse 1⊃func
 more:
 func←1↓func
 →(0=⍴func)/done
 tokens←pkg⍙parse pkg⍙empty_string pkg⍙strip_comment 1⊃func
 ids←pkg⍙is_id pkg⍙filter1 tokens
 ids←(~ids∊locals)/ids
 labels←labels,pkg⍙label tokens
 z←z,ids
 →more
 done:
 z←∪z~labels
∇

∇z←pkg⍙header_info tokens;queue;locals;t;op;name
 ⍝ Given a parsed function or operator header line, return the
 ⍝ function or operator name and a list of local variable names.
 ⍝
 ⍝ z←foo;locals
 ⍝ z←foo b;locals
 ⍝ z←a foo b;locals
 ⍝ z←(x foo);locals
 ⍝ z←(x foo) b;locals
 ⍝ z←(x foo y);locals
 ⍝ z←(x foo y) b;locals
 ⍝ z←a (x foo) b;locals
 ⍝ z←a (x foo y) b;locals
 queue←locals←name←⍬
 op←0
 more:
 →(0=⍴tokens)/end
 t←1⊃tokens
 tokens←1↓tokens
 →('←'∊t)/assign
 →('('∊t)/op_start
 →((')'∊t)∧(op=1))/op_end
 →(';'∊t)/locals_list
 ⍎(pkg⍙is_id t)/'queue←queue,⊂t'
 →more
 assign:
 locals←locals,queue
 queue←⍬
 →more
 op_start:
 locals←locals,queue
 queue←⍬
 op←1
 →more
 op_end:
 locals←locals,⊂1⊃queue
 name←2⊃queue
 ⍎(3=⍴queue)/'locals←locals,⊂3⊃queue'
 queue←⍬
 →more
 locals_list:
 ⍎(pkg⍙is_id t)/'locals←locals,⊂t'
 →(0=⍴tokens)/end
 t←1⊃tokens
 tokens←1↓tokens
 →locals_list
 end:
 →(0≠⍴name)/out
 ⍎(1=⍴queue)/'name←1⊃queue ◊ queue←⍬'
 ⍎(2=⍴queue)/'name←1⊃queue ◊ queue←1↓queue'
 ⍎(3=⍴queue)/'name←2⊃queue ◊ queue←1 0 1/queue'
 out:
 z←name (locals,queue)
∇

∇z←pkg⍙is_id token
 ⍝ Return true if token is a valid identifier.
 z←((1↑,token)∊pkg⍙id1,pkg⍙alp)∧(∧/(1↓,token)∊pkg⍙idX,pkg⍙alp,pkg⍙dig)
∇

∇z←pkg⍙label tokens
 ⍝ Given a parsed function line, return the name of a label which
 ⍝ appears on that line.
 z←(1⌽∨/¨':'=¨tokens)/tokens
∇

∇z←pkg⍙parse text;c;i;n;f
 ⍝ Parse text into a list of identifiers and interstital text. Note
 ⍝ that the interstitial text preserves blanks; this is useful when we
 ⍝ want to rewrite the identifiers in a text without changing the
 ⍝ layout.
 z←c←⍬
 i←n←0
 more:
 →(0=⍴text)/done
 f←1↑text
 text←1↓text
 →((f∊pkg⍙nuX,pkg⍙dig)∧(n=1))/accum
 →(((f∊pkg⍙idX,pkg⍙alp,pkg⍙dig)∧(i=1))∨((f∊pkg⍙nuX,pkg⍙dig)∧(n=1)))/accum
 →((f∊pkg⍙id1,pkg⍙alp)∧(i=0))/start_id
 →((f∊pkg⍙nu1,pkg⍙dig)∧(i=0)∧(n=0))/start_num
 ⍎((0≠⍴c)∧(i=1)∨(n=1))/'z←z,⊂c ◊ c←⍬'
 i←n←0
 →accum
 start_id:
 i←1
 →flush
 start_num:
 n←1
 flush:
 ⍎(0≠⍴c)/'z←z,⊂c ◊ c←⍬'
 accum:
 c←c,f
 →more
 done:
 z←z,⊂c
∇

∇z←pkg⍙strip_comment text
 ⍝ Strip an APL comment from text.
 z←(~∨\(text='⍝')>≠\text='''')/text
∇

pkg⍙function_refs ⊂[2] ⎕cr 'pkg'

)check

Reply via email to