nydp 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/lisp/core-015-documentation.nydp +78 -13
- data/lib/lisp/core-017-builtin-dox.nydp +55 -16
- data/lib/lisp/core-020-utils.nydp +16 -0
- data/lib/lisp/core-060-benchmarking.nydp +2 -2
- data/lib/lisp/tests/builtin-tests.nydp +0 -2
- data/lib/nydp/builtin/eval.rb +1 -1
- data/lib/nydp/builtin/script_run.rb +7 -0
- data/lib/nydp/core.rb +5 -2
- data/lib/nydp/pair.rb +10 -6
- data/lib/nydp/runner.rb +19 -13
- data/lib/nydp/version.rb +1 -1
- data/lib/nydp.rb +17 -11
- metadata +3 -4
- data/lib/nydp/builtin/load_tests.rb +0 -8
- data/lib/nydp/builtin/millisecs.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f085b808304453eb137f0660f08359d1ff6c540f
|
4
|
+
data.tar.gz: 534eaffd255ebc2b1f5c665843995753182bab95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6698547343c2b0b0b3744504323460c0128ee004cff02a701173a931f293bed5c820ba1e75392969a7fad6ac80997ca5e9a30fe737fb5eff2e76e4fdfb85b6b8
|
7
|
+
data.tar.gz: 66870fc5bf0bbeb8b5887f14338ecf2fa44e511005a8c494b5e4f34d4d75af80b97e25b6632aadd988a3676709a174550348ea30f9c93c6fabc005623eb6abe3
|
@@ -1,27 +1,77 @@
|
|
1
|
+
((fn (this-chapter-name chapters chapter-new chapter-build chapter-add-to-chapter)
|
2
|
+
(assign chapters (hash))
|
3
|
+
|
4
|
+
(def chapter-end ()
|
5
|
+
(assign this-chapter-name nil))
|
6
|
+
|
7
|
+
(def chapter-start (name description)
|
8
|
+
(assign this-chapter-name name)
|
9
|
+
(chapter-describe description))
|
10
|
+
|
11
|
+
(def chapter-new (hsh name)
|
12
|
+
(hash-set hsh 'name name)
|
13
|
+
hsh)
|
14
|
+
|
15
|
+
(def chapter-names () (hash-keys chapters))
|
16
|
+
|
17
|
+
(def chapter-build (name chapter)
|
18
|
+
(cond chapter
|
19
|
+
chapter
|
20
|
+
(cond name
|
21
|
+
(hash-set chapters
|
22
|
+
name
|
23
|
+
(chapter-new (hash)
|
24
|
+
name)))))
|
25
|
+
|
26
|
+
(def chapter-find (name)
|
27
|
+
(chapter-build (cond name
|
28
|
+
name
|
29
|
+
this-chapter-name)
|
30
|
+
(hash-get chapters
|
31
|
+
name)))
|
32
|
+
|
33
|
+
(def chapter-add-to-chapter (chapter attribute thing)
|
34
|
+
(cond chapter
|
35
|
+
(hash-cons chapter attribute thing)))
|
36
|
+
|
37
|
+
(def chapter-add-item (item chapter-name)
|
38
|
+
(chapter-add-to-chapter (chapter-find chapter-name)
|
39
|
+
'contents
|
40
|
+
item))
|
41
|
+
|
42
|
+
(def chapter-describe (description chapter-name)
|
43
|
+
(cond description
|
44
|
+
(chapter-add-to-chapter (chapter-find chapter-name)
|
45
|
+
'description
|
46
|
+
description)))))
|
47
|
+
|
48
|
+
(assign this-script nil)
|
49
|
+
(assign this-plugin nil)
|
50
|
+
|
1
51
|
((fn (dox examples chapters dox-new dox-build)
|
2
52
|
(def dox-build (hsh name what texts args src chapters)
|
3
|
-
(hash-set hsh 'name name
|
4
|
-
(hash-set hsh 'what what
|
5
|
-
(hash-set hsh 'texts texts
|
6
|
-
(hash-set hsh 'args args
|
7
|
-
(hash-set hsh 'src src
|
8
|
-
(hash-set hsh 'chapters chapters
|
53
|
+
(hash-set hsh 'name name )
|
54
|
+
(hash-set hsh 'what what )
|
55
|
+
(hash-set hsh 'texts texts )
|
56
|
+
(hash-set hsh 'args args )
|
57
|
+
(hash-set hsh 'src src )
|
58
|
+
(hash-set hsh 'chapters chapters )
|
59
|
+
(hash-set hsh 'file this-script )
|
60
|
+
(hash-set hsh 'plugin this-plugin )
|
9
61
|
hsh)
|
10
62
|
|
11
63
|
(def dox-new (item)
|
12
64
|
(hash-cons dox (hash-get item 'name) item)
|
13
|
-
(dox-add-to-chapters (hash-get item 'chapters)
|
65
|
+
(dox-add-to-chapters item (hash-get item 'chapters)))
|
14
66
|
|
15
67
|
(def dox-add-doc (name what texts args src chapters)
|
16
68
|
(dox-new (dox-build (hash) name what texts args src chapters)))
|
17
69
|
|
18
|
-
(def dox-add-to-
|
19
|
-
(
|
20
|
-
|
21
|
-
(def dox-add-to-chapters (chapters item)
|
70
|
+
(def dox-add-to-chapters (item chapters)
|
71
|
+
(chapter-add-item item)
|
22
72
|
(cond chapters
|
23
|
-
(do (
|
24
|
-
(dox-add-to-chapters (cdr chapters)
|
73
|
+
(do (chapter-add-item item (car chapters))
|
74
|
+
(dox-add-to-chapters item (cdr chapters)))
|
25
75
|
item))
|
26
76
|
|
27
77
|
(def dox-add-examples (name example-exprs)
|
@@ -46,6 +96,21 @@
|
|
46
96
|
(def dox-example-names () (hash-keys examples )))
|
47
97
|
(hash) (hash) (hash) nil)
|
48
98
|
|
99
|
+
(def plugin-start (name) (assign this-plugin name) (chapter-end))
|
100
|
+
(def plugin-end (name) (assign this-plugin nil ) (chapter-end))
|
101
|
+
(def script-start (name) (assign this-script name) (chapter-end))
|
102
|
+
(def script-end (name) (assign this-script nil ) (chapter-end))
|
103
|
+
|
104
|
+
(def script-run (event name)
|
105
|
+
(cond (eq? event 'plugin-start)
|
106
|
+
(plugin-start name)
|
107
|
+
(cond (eq? event 'plugin-end)
|
108
|
+
(plugin-end name)
|
109
|
+
(cond (eq? event 'script-start)
|
110
|
+
(script-start name)
|
111
|
+
(cond (eq? event 'script-end)
|
112
|
+
(script-end name))))))
|
113
|
+
|
49
114
|
(def filter-form (hsh form)
|
50
115
|
; if the car of 'form is a key of 'hsh, add the cdr of 'form to the value of the key in 'hsh
|
51
116
|
; otherwise add the form to the list whose key is nil
|
@@ -1,16 +1,55 @@
|
|
1
|
-
(dox-add-doc 'cons
|
2
|
-
(dox-add-doc 'car
|
3
|
-
(dox-add-doc 'cdr
|
4
|
-
(dox-add-doc '+
|
5
|
-
(dox-add-doc '-
|
6
|
-
(dox-add-doc '*
|
7
|
-
(dox-add-doc '/
|
8
|
-
(dox-add-doc '>
|
9
|
-
(dox-add-doc '<
|
10
|
-
(dox-add-doc 'mod
|
11
|
-
(dox-add-doc 'eval
|
12
|
-
(dox-add-doc 'hash
|
13
|
-
(dox-add-doc 'apply
|
14
|
-
(dox-add-doc 'date
|
15
|
-
(dox-add-doc 'error
|
16
|
-
(dox-add-doc 'parse
|
1
|
+
(dox-add-doc 'cons 'def '("with args a and b, returns a new cons cell, (a . b)") '(a b) nil '(list-manipulation))
|
2
|
+
(dox-add-doc 'car 'def '("with args a, where a is a cons cell (x . y), return x." "Commonly used to get the first element of a list") '(a) nil '(list-manipulation))
|
3
|
+
(dox-add-doc 'cdr 'def '("with args a, where a is a cons cell (x . y), return y." "Commonly used to get contents of a list, excluding the first element") '(a) nil '(list-manipulation))
|
4
|
+
(dox-add-doc '+ 'def '("with rest-args things, return the sum of the elements of things." "Will also increment dates and concatenate strings and lists") 'things nil '(math))
|
5
|
+
(dox-add-doc '- 'def '("return the result of subtracting all other args from the first arg." "(- a b c d) is equivalent to (- a (+ b c d))") 'things nil '(math))
|
6
|
+
(dox-add-doc '* 'def '("with rest-args things, return the product of the elements of things.") 'things nil '(math))
|
7
|
+
(dox-add-doc '/ 'def '("return the result of dividing all other args into the first arg." "(/ a b c d) is equivalent to (/ a (* b c d))") 'things nil '(math))
|
8
|
+
(dox-add-doc '> 'def '("true if each arg is greater than the next arg") 'things nil '(math))
|
9
|
+
(dox-add-doc '< 'def '("true if each arg is less than the next arg") 'things nil '(math))
|
10
|
+
(dox-add-doc 'mod 'def '("return the remainder after diving a by b") '(a b) nil '(math))
|
11
|
+
(dox-add-doc 'eval 'def '("evaluate the given lisp expression") '(expr) nil '(nydp-core))
|
12
|
+
(dox-add-doc 'hash 'def '("create a new Hash instance") nil nil '(hash-manipulation))
|
13
|
+
(dox-add-doc 'apply 'def '("invoke f with args 'args") '(f . args) nil '(nydp-core))
|
14
|
+
(dox-add-doc 'date 'def '("create a new date instance") '(year month day) nil '(time-date))
|
15
|
+
(dox-add-doc 'error 'def '("raise an exception") 'args nil '(flow-control))
|
16
|
+
(dox-add-doc 'parse 'def '("parse the given string and return the corresponding lisp objects") '(str) nil '(nydp-core))
|
17
|
+
(dox-add-doc 'p 'def '("print a message on $stdout") 'args nil '(nydp-core))
|
18
|
+
(dox-add-doc 'sort 'def '("return 'things, sorted according to their natural sort order") 'things nil '(list-manipulation))
|
19
|
+
(dox-add-doc 'sqrt 'def '("return the square root of 'arg") '(arg) nil '(math))
|
20
|
+
(dox-add-doc 'sym 'def '("return the symbol for the given string 'arg") '(arg) nil '(nydp-core))
|
21
|
+
(dox-add-doc 'ensuring 'def '("execute 'tricky-f, then 'ensure-f afterwards"
|
22
|
+
"'ensure-f will always be executed, even if there is an error in 'tricky-f"
|
23
|
+
"returns the return value of 'tricky-f") '(ensure-f tricky-f) nil '(flow-control))
|
24
|
+
(dox-add-doc 'inspect 'def '("return a string representing 'arg, potentially (but not always) in a way that can be parsed back in to get the original object") '(arg) nil '(nydp-core))
|
25
|
+
(dox-add-doc 'comment 'def '("does nothing at all." "Intercepted inside 'def and 'mac and used for documentation") '(arg) nil '(nydp-core))
|
26
|
+
(dox-add-doc 'parse-in-string 'def '("parse the given string assuming a string-open delimiter has already been encountered") '(str) nil '(nydp-core))
|
27
|
+
(dox-add-doc 'random-string 'def '("return a random string of length 'len (default 10)") '(len) nil '(string-manipulation))
|
28
|
+
(dox-add-doc 'to-string 'def '("return a human-readable string representation of 'arg") '(arg) nil '(string-manipulation))
|
29
|
+
(dox-add-doc 'string-length 'def '("return the length of 'arg") '(arg) nil '(string-manipulation))
|
30
|
+
(dox-add-doc 'string-replace 'def '("replace 'pattern with 'insert in 'str") '(pattern insert str) nil '(string-manipulation))
|
31
|
+
(dox-add-doc 'string-split 'def '("split 'str delimited by 'delim") '(str delim) nil '(string-manipulation))
|
32
|
+
(dox-add-doc 'time 'def '("with no args, return the current time."
|
33
|
+
"With one arg, if 'arg-0 is a number, return the current time plus 'arg-0 seconds."
|
34
|
+
"With one arg, if 'arg-0 is a date, return the time at the beginning of the given date."
|
35
|
+
"With one arg, if 'arg-0 is a time, return the number of seconds between 'arg-0 and now."
|
36
|
+
"With two args, 'arg-0 must be a time."
|
37
|
+
"If 'arg-1 is a number, return 'arg-0 plus 'arg-1 seconds as a time object."
|
38
|
+
"If 'arg-1 is a time, return the number of seconds between the two (- 'arg-0 arg-1)."
|
39
|
+
"Otherwise, expect 3, 4, 5, or 6 args, to construct a time from"
|
40
|
+
"year, month, date, hours, minutes, seconds, milliseconds, reading arguments in that order,"
|
41
|
+
"where hours, minutes, seconds, and milliseconds are optional") 'args nil '(date-time))
|
42
|
+
(dox-add-doc 'thread-locals 'def '("return a hash bound to the current thread") nil nil '(nydp-core))
|
43
|
+
(dox-add-doc 'type-of 'def '("return a symbol for the type of 'arg") '(arg) nil '(nydp-core))
|
44
|
+
(dox-add-doc 'eq? 'def '("return 't if 'arg-0 and 'arg-1 are equal, nil otherwise") '(arg-0 arg-1) nil '(nydp-core))
|
45
|
+
(dox-add-doc 'cdr-set 'def '("set the cdr of the given 'cell to 'arg, returns 'cell") '(cell arg) nil '(list-manipulation))
|
46
|
+
(dox-add-doc 'hash-get 'def '("return the value stored by 'key in 'hsh") '(hsh key) nil '(hash-manipulation))
|
47
|
+
(dox-add-doc 'hash-set 'def '("store 'val under 'key in 'hsh, return 'val") '(hsh key val) nil '(hash-manipulation))
|
48
|
+
(dox-add-doc 'hash-keys 'def '("return the list of keys in 'hsh") '(hsh) nil '(hash-manipulation))
|
49
|
+
(dox-add-doc 'hash-key? 'def '("return 't if 'key is a key of 'hsh") '(hsh key) nil '(hash-manipulation))
|
50
|
+
(dox-add-doc 'hash-merge 'def '("return a new hash containing keys and values from 'h0 and 'h1, where values of 'h1 override values of 'h0") '(h0 h1) nil '(hash-manipulation))
|
51
|
+
(dox-add-doc 'vm-info 'def '("return some information about the state of the current thread") nil nil '(nydp-core))
|
52
|
+
(dox-add-doc 'pre-compile 'def '("transform parsed forms before the compile and eval stages") '(arg) nil '(nydp-compilation))
|
53
|
+
(dox-add-doc 'script-run 'def '("announces the start of a plugin load or a script load."
|
54
|
+
"'event may be one of '(script-start script-end plugin-start plugin-end)"
|
55
|
+
"'name is the name of the script or plugin concerned") '(event name) nil '(nydp-core))
|
@@ -1,3 +1,5 @@
|
|
1
|
+
(assign script-name "core-012-utils.nydp")
|
2
|
+
|
1
3
|
(dox-add-doc 'if
|
2
4
|
'mac
|
3
5
|
'("with arguments a, return a"
|
@@ -26,3 +28,17 @@
|
|
26
28
|
(cons (f (car things)) (map f (cdr things)))
|
27
29
|
(map f (list things)))
|
28
30
|
'(list-manipulation))
|
31
|
+
|
32
|
+
(dox-add-doc 'rev
|
33
|
+
'def
|
34
|
+
'("returns 'things in reverse order")
|
35
|
+
'(things)
|
36
|
+
'(rev-accum things nil)
|
37
|
+
'(list-manipulation))
|
38
|
+
|
39
|
+
(dox-add-doc 'hash-cons
|
40
|
+
'def
|
41
|
+
'("push 'v onto the value for 'k in 'h")
|
42
|
+
'(h k v)
|
43
|
+
'(hash-set h k (cons v (hash-get h k)))
|
44
|
+
'(hash-manipulation))
|
@@ -11,9 +11,9 @@
|
|
11
11
|
(p "Benchmark: ~desc - ~repeats runs of ~iterations iterations each")
|
12
12
|
(let times 0
|
13
13
|
(for reps 1 repeats
|
14
|
-
(let
|
14
|
+
(let started (time)
|
15
15
|
(bm-repeat f iterations)
|
16
|
-
(let elapsed (- (
|
16
|
+
(let elapsed (- (time) started)
|
17
17
|
(assign times (+ elapsed times))
|
18
18
|
(p " took: ~elapsed ms, ~(/ elapsed iterations) ms per iteration"))))
|
19
19
|
(p "total ~(just times), average ~(/ times repeats) per run")
|
@@ -22,8 +22,6 @@
|
|
22
22
|
("ensuring" (inspect ensuring ) "builtin/ensuring" )
|
23
23
|
("inspect" (inspect inspect ) "builtin/inspect" )
|
24
24
|
("comment" (inspect comment ) "builtin/comment" )
|
25
|
-
("millisecs" (inspect millisecs ) "builtin/millisecs" )
|
26
|
-
("load-tests" (inspect load-tests ) "builtin/load-tests" )
|
27
25
|
("handle-error" (inspect handle-error ) "builtin/handle-error" )
|
28
26
|
("parse-in-string" (inspect parse-in-string ) "builtin/parse-in-string" )
|
29
27
|
("random-string" (inspect random-string ) "builtin/random-string" )
|
data/lib/nydp/builtin/eval.rb
CHANGED
@@ -2,7 +2,7 @@ class Nydp::Builtin::Eval
|
|
2
2
|
include Nydp::Builtin::Base, Singleton
|
3
3
|
|
4
4
|
def builtin_invoke vm, args
|
5
|
-
evaluator = Nydp::Evaluator.new Nydp::VM.new(vm.ns), vm.ns
|
5
|
+
evaluator = Nydp::Evaluator.new Nydp::VM.new(vm.ns), vm.ns, "<eval>"
|
6
6
|
vm.push_arg evaluator.evaluate args.car
|
7
7
|
end
|
8
8
|
end
|
data/lib/nydp/core.rb
CHANGED
@@ -8,6 +8,10 @@ module Nydp
|
|
8
8
|
File.join File.expand_path(File.dirname(__FILE__)), name
|
9
9
|
end
|
10
10
|
|
11
|
+
def base_path
|
12
|
+
relative_path "../lisp/"
|
13
|
+
end
|
14
|
+
|
11
15
|
def load_rake_tasks
|
12
16
|
load relative_path '../tasks/tests.rake'
|
13
17
|
end
|
@@ -48,8 +52,6 @@ module Nydp
|
|
48
52
|
Symbol.mk(:ensuring, ns).assign(Nydp::Builtin::Ensuring.instance)
|
49
53
|
Symbol.mk(:inspect, ns).assign(Nydp::Builtin::Inspect.instance)
|
50
54
|
Symbol.mk(:comment, ns).assign(Nydp::Builtin::Comment.instance)
|
51
|
-
Symbol.mk(:millisecs, ns).assign(Nydp::Builtin::Millisecs.instance)
|
52
|
-
Symbol.mk("load-tests", ns).assign(Nydp::Builtin::LoadTests.instance)
|
53
55
|
Symbol.mk("handle-error" , ns).assign(Nydp::Builtin::HandleError.instance)
|
54
56
|
Symbol.mk("parse-in-string", ns).assign(Nydp::Builtin::ParseInString.instance)
|
55
57
|
Symbol.mk("random-string" , ns).assign(Nydp::Builtin::RandomString.instance)
|
@@ -70,6 +72,7 @@ module Nydp
|
|
70
72
|
Symbol.mk(:"hash-merge", ns).assign(Nydp::Builtin::HashMerge.instance)
|
71
73
|
Symbol.mk(:"vm-info", ns).assign Nydp::Builtin::VmInfo.instance
|
72
74
|
Symbol.mk(:"pre-compile", ns).assign Nydp::Builtin::PreCompile.instance
|
75
|
+
Symbol.mk(:"script-run" , ns).assign Nydp::Builtin::ScriptRun.instance
|
73
76
|
end
|
74
77
|
end
|
75
78
|
end
|
data/lib/nydp/pair.rb
CHANGED
@@ -2,17 +2,21 @@ class Nydp::Pair
|
|
2
2
|
include Nydp::Helper, Enumerable
|
3
3
|
extend Nydp::Helper
|
4
4
|
|
5
|
-
|
5
|
+
attr_reader :car, :cdr
|
6
6
|
|
7
7
|
def initialize car, cdr
|
8
8
|
@car, @cdr = car, cdr
|
9
9
|
end
|
10
10
|
|
11
|
-
def nydp_type
|
12
|
-
def caar
|
13
|
-
def cadr
|
14
|
-
def cdar
|
15
|
-
def cddr
|
11
|
+
def nydp_type ; :pair ; end
|
12
|
+
def caar ; car.car ; end
|
13
|
+
def cadr ; cdr.car ; end
|
14
|
+
def cdar ; car.cdr ; end
|
15
|
+
def cddr ; cdr.cdr ; end
|
16
|
+
def car= thing ; @car = thing ; @_hash = nil ; end
|
17
|
+
def cdr= thing ; @cdr = thing ; @_hash = nil ; end
|
18
|
+
def hash ; @_hash ||= (car.hash + cdr.hash) ; end
|
19
|
+
def eql? other ; self == other ; end
|
16
20
|
|
17
21
|
def to_ruby list=[]
|
18
22
|
list << n2r(car)
|
data/lib/nydp/runner.rb
CHANGED
@@ -37,11 +37,12 @@ module Nydp
|
|
37
37
|
end
|
38
38
|
|
39
39
|
class Evaluator
|
40
|
-
attr_accessor :vm, :ns
|
40
|
+
attr_accessor :vm, :ns, :name
|
41
41
|
|
42
|
-
def initialize vm, ns
|
43
|
-
@
|
44
|
-
@
|
42
|
+
def initialize vm, ns, name
|
43
|
+
@name = name
|
44
|
+
@vm = vm
|
45
|
+
@ns = ns
|
45
46
|
@precompile = Symbol.mk(:"pre-compile", ns)
|
46
47
|
@quote = Symbol.mk(:quote, ns)
|
47
48
|
end
|
@@ -73,8 +74,8 @@ module Nydp
|
|
73
74
|
end
|
74
75
|
|
75
76
|
class Runner < Evaluator
|
76
|
-
def initialize vm, ns, stream, printer=nil
|
77
|
-
super vm, ns
|
77
|
+
def initialize vm, ns, stream, printer=nil, name=nil
|
78
|
+
super vm, ns, name
|
78
79
|
@printer = printer
|
79
80
|
@parser = Nydp::Parser.new(ns)
|
80
81
|
@tokens = Nydp::Tokeniser.new stream
|
@@ -92,16 +93,21 @@ module Nydp
|
|
92
93
|
end
|
93
94
|
|
94
95
|
def run
|
96
|
+
Nydp.apply_function ns, :"script-run", :"script-start", name
|
95
97
|
res = Nydp::NIL
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
98
|
+
begin
|
99
|
+
while !@tokens.finished
|
100
|
+
expr = @parser.expression(@tokens)
|
101
|
+
unless expr.nil?
|
102
|
+
begin
|
103
|
+
print(res = evaluate(expr))
|
104
|
+
rescue Exception => e
|
105
|
+
handle_run_error e
|
106
|
+
end
|
103
107
|
end
|
104
108
|
end
|
109
|
+
ensure
|
110
|
+
Nydp.apply_function ns, :"script-run", :"script-end", name
|
105
111
|
end
|
106
112
|
res
|
107
113
|
end
|
data/lib/nydp/version.rb
CHANGED
data/lib/nydp.rb
CHANGED
@@ -7,20 +7,26 @@ module Nydp
|
|
7
7
|
def self.loadfiles; PLUGINS.map(&:loadfiles).flatten ; end
|
8
8
|
def self.testfiles; PLUGINS.map(&:testfiles).flatten ; end
|
9
9
|
def self.plugin_names ; PLUGINS.map(&:name) ; end
|
10
|
-
def self.loadall ns, files
|
10
|
+
def self.loadall ns, plugin, files
|
11
11
|
vm = VM.new(ns)
|
12
|
+
apply_function ns, :"script-run", :"plugin-start", plugin.name if plugin
|
12
13
|
files.each { |f|
|
14
|
+
script_name = f.gsub plugin.base_path, ""
|
13
15
|
reader = Nydp::StreamReader.new(File.new(f))
|
14
|
-
Nydp::Runner.new(vm, ns, reader).run
|
16
|
+
Nydp::Runner.new(vm, ns, reader, nil, (script_name || f)).run
|
15
17
|
}
|
18
|
+
ensure
|
19
|
+
apply_function ns, :"script-run", :"plugin-end", plugin.name if plugin
|
16
20
|
end
|
17
21
|
|
18
22
|
def self.build_nydp extra_files=nil
|
19
23
|
ns = { }
|
20
24
|
setup(ns)
|
21
|
-
|
22
|
-
|
23
|
-
|
25
|
+
PLUGINS.each { |plg|
|
26
|
+
loadall ns, plg, plg.loadfiles
|
27
|
+
loadall ns, plg, plg.testfiles
|
28
|
+
}
|
29
|
+
loadall ns, nil, extra_files if extra_files
|
24
30
|
ns
|
25
31
|
end
|
26
32
|
|
@@ -33,17 +39,17 @@ module Nydp
|
|
33
39
|
vm.thread
|
34
40
|
end
|
35
41
|
|
36
|
-
def self.reader
|
37
|
-
def self.eval_src
|
38
|
-
def self.eval_src!
|
39
|
-
def self.eval_with runner, ns, src_txt ; runner.new(VM.new(ns), ns, reader(src_txt)).run ; end
|
42
|
+
def self.reader txt ; Nydp::StringReader.new txt ; end
|
43
|
+
def self.eval_src ns, src_txt, name=nil ; eval_with Nydp::Runner, ns, src_txt, name ; end
|
44
|
+
def self.eval_src! ns, src_txt, name=nil ; eval_with Nydp::ExplodeRunner, ns, src_txt, name ; end
|
45
|
+
def self.eval_with runner, ns, src_txt, name ; runner.new(VM.new(ns), ns, reader(src_txt), nil, name).run ; end
|
40
46
|
|
41
47
|
def self.repl
|
42
48
|
puts "welcome to nydp"
|
43
49
|
puts "^D to exit"
|
44
50
|
reader = Nydp::ReadlineReader.new $stdin, "nydp > "
|
45
51
|
ns = build_nydp
|
46
|
-
Nydp::Runner.new(VM.new(ns), ns, reader, $stdout).run
|
52
|
+
Nydp::Runner.new(VM.new(ns), ns, reader, $stdout, "<stdin>").run
|
47
53
|
end
|
48
54
|
|
49
55
|
def self.tests *options
|
@@ -51,7 +57,7 @@ module Nydp
|
|
51
57
|
puts "welcome to nydp : running tests"
|
52
58
|
reader = Nydp::StringReader.new "(run-all-tests #{verbose})"
|
53
59
|
ns = build_nydp
|
54
|
-
Nydp::Runner.new(VM.new(ns), ns, reader).run
|
60
|
+
Nydp::Runner.new(VM.new(ns), ns, reader, nil, "<test-runner>").run
|
55
61
|
end
|
56
62
|
|
57
63
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nydp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Conan Dalton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05
|
11
|
+
date: 2016-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -167,8 +167,6 @@ files:
|
|
167
167
|
- lib/nydp/builtin/inspect.rb
|
168
168
|
- lib/nydp/builtin/is_equal.rb
|
169
169
|
- lib/nydp/builtin/less_than.rb
|
170
|
-
- lib/nydp/builtin/load_tests.rb
|
171
|
-
- lib/nydp/builtin/millisecs.rb
|
172
170
|
- lib/nydp/builtin/minus.rb
|
173
171
|
- lib/nydp/builtin/modulo.rb
|
174
172
|
- lib/nydp/builtin/parse.rb
|
@@ -178,6 +176,7 @@ files:
|
|
178
176
|
- lib/nydp/builtin/puts.rb
|
179
177
|
- lib/nydp/builtin/quit.rb
|
180
178
|
- lib/nydp/builtin/random_string.rb
|
179
|
+
- lib/nydp/builtin/script_run.rb
|
181
180
|
- lib/nydp/builtin/sort.rb
|
182
181
|
- lib/nydp/builtin/sqrt.rb
|
183
182
|
- lib/nydp/builtin/string_match.rb
|