Created
March 13, 2018 18:51
-
-
Save lepinekong/1a0344da2184b9fbfd7a2a010c0dd287 to your computer and use it in GitHub Desktop.
.code.analyze
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Red [ | |
Title: ".code.analyze" | |
] | |
src: {Red [ | |
Title: ".system.override.red" | |
] | |
if not value? 'syscd [ | |
syscd: :cd | |
cd: func [ | |
"Change directory (shell shortcut function)." | |
[catch] | |
'path [file! word! path! unset! string! paren! url!] "Accepts %file, :variables and just words (as dirs)" | |
][; some code for cd | |
] | |
] | |
if not value? 'sysprint [ | |
sysprint: :print | |
print: func [ | |
"print." | |
value | |
/mute | |
][; some code for print | |
] | |
] | |
} | |
code: load src | |
collect-funcs: copy [] | |
.code.analyze: function[code][ | |
code-copy: copy code | |
forall code [ | |
i: index? code | |
element: code/1 | |
; type: type? element | |
; if (type = set-word!) [ | |
if set-word? element [ | |
j: i + 1 | |
next-element: code-copy/:j | |
if (next-element = 'func) or (next-element = 'function) [ | |
func-collect: copy [] | |
append func-collect compose/deep [(element) (next-element)] | |
j: i + 2 | |
append/only func-collect code-copy/:j | |
j: i + 3 | |
append/only func-collect code-copy/:j | |
probe func-collect | |
ask "func-collect " | |
append collect-funcs func-collect | |
] | |
] | |
if block? element [ | |
.code.analyze element | |
] | |
] | |
return collect-funcs | |
] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
.code.analyze code