qlang 0.0.14 → 0.0.27
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +2 -0
- data/Gemfile +1 -3
- data/README.md +67 -10
- data/bin/qlang +20 -0
- data/lib/qlang.rb +3 -2
- data/lib/qlang/api.rb +47 -0
- data/lib/qlang/api/func_api.rb +7 -1
- data/lib/qlang/api/integral_api.rb +17 -0
- data/lib/qlang/api/list_api.rb +8 -2
- data/lib/qlang/exec.rb +29 -15
- data/lib/qlang/iq.rb +39 -0
- data/lib/qlang/lexer/base.rb +15 -3
- data/lib/qlang/lexer/cont_lexer.rb +4 -1
- data/lib/qlang/lexer/func_lexer.rb +2 -2
- data/lib/qlang/lexer/tokens.rb +45 -0
- data/lib/qlang/lexer/wrap_lexer.rb +10 -1
- data/lib/qlang/parser.rb +40 -20
- data/lib/qlang/parser/base.rb +0 -13
- data/lib/qlang/parser/formula_parser.rb +36 -0
- data/lib/qlang/parser/func_parser.rb +6 -7
- data/lib/qlang/parser/integral_parser.rb +15 -0
- data/lib/qlang/parser/matrix_parser.rb +6 -2
- data/lib/qlang/parser/vector_parser.rb +4 -2
- data/lib/qlang/version.rb +1 -1
- data/q_lang.gemspec +2 -1
- data/spec/iq_spec.rb +141 -0
- data/spec/lexer/regular_expressions_spec.rb +18 -0
- data/spec/objects/function_spec.rb +33 -0
- data/spec/objects/integral_spec.rb +21 -0
- data/spec/objects/list_spec.rb +31 -0
- data/spec/{matrix_spec.rb → objects/matrix_spec.rb} +3 -0
- data/spec/{vector_spec.rb → objects/vector_spec.rb} +0 -0
- data/spec/q_lang_spec.rb +30 -0
- data/spec/spec_helper.rb +5 -0
- metadata +35 -27
- data/bin/dydx +0 -8
- data/bin/q_lang +0 -3
- data/iqb.rb +0 -6
- data/lib/qlang/q_on_irb.rb +0 -8
- data/spec/function_spec.rb +0 -31
- data/spec/list_spec.rb +0 -31
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Qlang do
|
4
|
+
describe 'Integral' do
|
5
|
+
context 'into R' do
|
6
|
+
it do
|
7
|
+
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'into Ruby' do
|
12
|
+
it do
|
13
|
+
expect(
|
14
|
+
Q.to_ruby.compile('S( log(x)dx )[0..1]')
|
15
|
+
).to eq(
|
16
|
+
'S(log(x), dx)[0, 1]'
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Qlang do
|
4
|
+
describe 'List' do
|
5
|
+
it do
|
6
|
+
# expect(
|
7
|
+
# Q.to_r.compile('{name: "Gogotanaka", age: 21, birth: (1992 8 10) }')
|
8
|
+
# ).to eq(
|
9
|
+
# "list(name=\"Gogotanaka\", age=21, birth=c(1992, 8, 10))"
|
10
|
+
# )
|
11
|
+
|
12
|
+
expect(
|
13
|
+
Q.to_r.compile('{key1: 234234, key2: 387342 }')
|
14
|
+
).to eq(
|
15
|
+
"list(key1=234234, key2=387342)"
|
16
|
+
)
|
17
|
+
|
18
|
+
expect(
|
19
|
+
Q.to_r.compile('{key1:234234,key2:387342,key3:38733242}')
|
20
|
+
).to eq(
|
21
|
+
"list(key1=234234, key2=387342, key3=38733242)"
|
22
|
+
)
|
23
|
+
|
24
|
+
# expect(
|
25
|
+
# Q.to_r.compile('{key1:(1 3 2; 8 2 3),key2:387342,key3:38733242}')
|
26
|
+
# ).to eq(
|
27
|
+
# "list(key1=matrix(c(1, 3, 2, 8, 2, 3), 2, 3, byrow = TRUE), key2=387342, key3=38733242)"
|
28
|
+
# )
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -21,6 +21,7 @@ describe Qlang do
|
|
21
21
|
).to eq(
|
22
22
|
"matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), 3, 3, byrow = TRUE)"
|
23
23
|
)
|
24
|
+
|
24
25
|
expect(
|
25
26
|
Q.to_r.compile('(1;2;3)')
|
26
27
|
).to eq(
|
@@ -36,11 +37,13 @@ describe Qlang do
|
|
36
37
|
).to eq(
|
37
38
|
"Matrix[[1, 2, 3], [4, 5, 6]]"
|
38
39
|
)
|
40
|
+
|
39
41
|
expect(
|
40
42
|
Q.to_ruby.compile('(1 2 3 ; 4 5 6; 7 8 9)')
|
41
43
|
).to eq(
|
42
44
|
"Matrix[[1, 2, 3], [4, 5, 6], [7, 8, 9]]"
|
43
45
|
)
|
46
|
+
|
44
47
|
expect(
|
45
48
|
Q.to_ruby.compile('(1;2;3)')
|
46
49
|
).to eq(
|
File without changes
|
data/spec/q_lang_spec.rb
CHANGED
@@ -12,6 +12,36 @@ describe Qlang do
|
|
12
12
|
describe Dydx do
|
13
13
|
it 'check some example' do
|
14
14
|
expect(d/dx(sin(x))).to eq cos(x)
|
15
|
+
|
16
|
+
expect(
|
17
|
+
Q.to_ruby.compile('d/dx(sin(x))')
|
18
|
+
).to eq(
|
19
|
+
"d/dx(sin (x))"
|
20
|
+
)
|
21
|
+
|
22
|
+
expect(
|
23
|
+
Q.to_ruby.compile('d/dx(log(x))')
|
24
|
+
).to eq(
|
25
|
+
"d/dx(log (x))"
|
26
|
+
)
|
27
|
+
|
28
|
+
expect(
|
29
|
+
Q.to_ruby.compile('f(x, y) = x + y')
|
30
|
+
).to eq(
|
31
|
+
"f(x, y) <= x + y"
|
32
|
+
)
|
33
|
+
|
34
|
+
expect(
|
35
|
+
Matrix[[1, 2, 3], [4, 5, 6]].to_q
|
36
|
+
).to eq(
|
37
|
+
"(1 2 3; 4 5 6)"
|
38
|
+
)
|
39
|
+
|
40
|
+
expect(
|
41
|
+
Vector[1, 2, 3].to_q
|
42
|
+
).to eq(
|
43
|
+
"(1 2 3)"
|
44
|
+
)
|
15
45
|
end
|
16
46
|
end
|
17
47
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,45 +1,45 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qlang
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.27
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gogotanaka
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: dydx
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
type: :
|
19
|
+
version: 0.1.41421
|
20
|
+
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.1.41421
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '1.6'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '1.6'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -70,11 +70,11 @@ description: Enjoy MATH!
|
|
70
70
|
email:
|
71
71
|
- mail@tanakakazuki.com
|
72
72
|
executables:
|
73
|
-
-
|
74
|
-
- q_lang
|
73
|
+
- qlang
|
75
74
|
extensions: []
|
76
75
|
extra_rdoc_files: []
|
77
76
|
files:
|
77
|
+
- ".coveralls.yml"
|
78
78
|
- ".gitignore"
|
79
79
|
- ".rspec"
|
80
80
|
- ".rubocop.yml"
|
@@ -83,36 +83,41 @@ files:
|
|
83
83
|
- LICENSE.txt
|
84
84
|
- README.md
|
85
85
|
- Rakefile
|
86
|
-
- bin/
|
87
|
-
- bin/q_lang
|
88
|
-
- iqb.rb
|
86
|
+
- bin/qlang
|
89
87
|
- lib/qlang.rb
|
90
88
|
- lib/qlang/api.rb
|
91
89
|
- lib/qlang/api/func_api.rb
|
90
|
+
- lib/qlang/api/integral_api.rb
|
92
91
|
- lib/qlang/api/list_api.rb
|
93
92
|
- lib/qlang/api/matrix_api.rb
|
94
93
|
- lib/qlang/api/vector_api.rb
|
95
94
|
- lib/qlang/exec.rb
|
95
|
+
- lib/qlang/iq.rb
|
96
96
|
- lib/qlang/lexer.rb
|
97
97
|
- lib/qlang/lexer/base.rb
|
98
98
|
- lib/qlang/lexer/cont_lexer.rb
|
99
99
|
- lib/qlang/lexer/func_lexer.rb
|
100
|
+
- lib/qlang/lexer/tokens.rb
|
100
101
|
- lib/qlang/lexer/wrap_lexer.rb
|
101
102
|
- lib/qlang/parser.rb
|
102
103
|
- lib/qlang/parser/base.rb
|
104
|
+
- lib/qlang/parser/formula_parser.rb
|
103
105
|
- lib/qlang/parser/func_parser.rb
|
106
|
+
- lib/qlang/parser/integral_parser.rb
|
104
107
|
- lib/qlang/parser/list_parser.rb
|
105
108
|
- lib/qlang/parser/matrix_parser.rb
|
106
109
|
- lib/qlang/parser/vector_parser.rb
|
107
|
-
- lib/qlang/q_on_irb.rb
|
108
110
|
- lib/qlang/version.rb
|
109
111
|
- q_lang.gemspec
|
110
|
-
- spec/
|
111
|
-
- spec/
|
112
|
-
- spec/
|
112
|
+
- spec/iq_spec.rb
|
113
|
+
- spec/lexer/regular_expressions_spec.rb
|
114
|
+
- spec/objects/function_spec.rb
|
115
|
+
- spec/objects/integral_spec.rb
|
116
|
+
- spec/objects/list_spec.rb
|
117
|
+
- spec/objects/matrix_spec.rb
|
118
|
+
- spec/objects/vector_spec.rb
|
113
119
|
- spec/q_lang_spec.rb
|
114
120
|
- spec/spec_helper.rb
|
115
|
-
- spec/vector_spec.rb
|
116
121
|
homepage: http://q-language.org/
|
117
122
|
licenses:
|
118
123
|
- MIT
|
@@ -138,9 +143,12 @@ signing_key:
|
|
138
143
|
specification_version: 4
|
139
144
|
summary: Enjoy MATH!
|
140
145
|
test_files:
|
141
|
-
- spec/
|
142
|
-
- spec/
|
143
|
-
- spec/
|
146
|
+
- spec/iq_spec.rb
|
147
|
+
- spec/lexer/regular_expressions_spec.rb
|
148
|
+
- spec/objects/function_spec.rb
|
149
|
+
- spec/objects/integral_spec.rb
|
150
|
+
- spec/objects/list_spec.rb
|
151
|
+
- spec/objects/matrix_spec.rb
|
152
|
+
- spec/objects/vector_spec.rb
|
144
153
|
- spec/q_lang_spec.rb
|
145
154
|
- spec/spec_helper.rb
|
146
|
-
- spec/vector_spec.rb
|
data/bin/dydx
DELETED
data/bin/q_lang
DELETED
data/iqb.rb
DELETED
data/lib/qlang/q_on_irb.rb
DELETED
data/spec/function_spec.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Qlang do
|
4
|
-
describe 'Function' do
|
5
|
-
it do
|
6
|
-
expect(
|
7
|
-
Q.compile('f(x, y) = x + y')
|
8
|
-
).to eq(
|
9
|
-
"f <- function(x ,y) x + y"
|
10
|
-
)
|
11
|
-
|
12
|
-
expect(
|
13
|
-
Q.compile('g(x) = x ** 2')
|
14
|
-
).to eq(
|
15
|
-
"g <- function(x) x ** 2"
|
16
|
-
)
|
17
|
-
|
18
|
-
expect(
|
19
|
-
Q.compile('g(x) = x ** (2 + 2)')
|
20
|
-
).to eq(
|
21
|
-
"g <- function(x) x ** (2 + 2)"
|
22
|
-
)
|
23
|
-
|
24
|
-
expect(
|
25
|
-
Q.compile('h(a, b, c) = a ** 2 + b ** 2 + c ** 2')
|
26
|
-
).to eq(
|
27
|
-
"h <- function(a ,b ,c) a ** 2 + b ** 2 + c ** 2"
|
28
|
-
)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
data/spec/list_spec.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Qlang do
|
4
|
-
describe 'List' do
|
5
|
-
it do
|
6
|
-
expect(
|
7
|
-
Q.compile('{name: "Gogotanaka", age: 21, birth: (1992 8 10) }')
|
8
|
-
).to eq(
|
9
|
-
"list(name=\"Gogotanaka\", age=21, birth=c(1992, 8, 10))"
|
10
|
-
)
|
11
|
-
|
12
|
-
expect(
|
13
|
-
Q.compile('{key1: 234234, key2: 387342 }')
|
14
|
-
).to eq(
|
15
|
-
"list(key1=234234, key2=387342)"
|
16
|
-
)
|
17
|
-
|
18
|
-
expect(
|
19
|
-
Q.compile('{key1:234234,key2:387342,key3:38733242}')
|
20
|
-
).to eq(
|
21
|
-
"list(key1=234234, key2=387342, key3=38733242)"
|
22
|
-
)
|
23
|
-
|
24
|
-
expect(
|
25
|
-
Q.compile('{key1:(1 3 2; 8 2 3),key2:387342,key3:38733242}')
|
26
|
-
).to eq(
|
27
|
-
"list(key1=matrix(c(1, 3, 2, 8, 2, 3), 2, 3, byrow = TRUE), key2=387342, key3=38733242)"
|
28
|
-
)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|