qlang 0.0.27182123 → 0.0.27182124

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: efc24d9a17341eccb2b98fb01a6a3e579028ad31
4
- data.tar.gz: 3514ada671a76cbdb7c436b416535718a0b3b4a9
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MTIxMDJhZjBiZGFkMDJlMjQ2YzQ0MDY4M2Y3ZTIwNGEwOGY3ZWM3Nw==
5
+ data.tar.gz: !binary |-
6
+ MTM4YWY3NTIyODllYTJmNTVhNjc2NjUzZTViODEzMzcxOWU0N2QxOA==
5
7
  SHA512:
6
- metadata.gz: aec36262dd70c8676939beb423c22ac623644a02b84dda5cbd297797688d452aaaf023432a9a5740f030919c805d7ff6a2847432684e824e207da90078cfdff4
7
- data.tar.gz: 8813f7d439d2a7d79e8a5e2ec4d32f7fe983f2df6fa85f059586025af56c81ec308e0a35c22e462fecb5526261c94a5e7c7d2a596a1f337b68151662191f6972
8
+ metadata.gz: !binary |-
9
+ ZDI0ZWE1ZTk4Yjk2MTc1NjU3Y2RjYmUwY2YxMjg4MTZiMDk2NzVkZGE2ZWUz
10
+ YjczMWI4OTZjM2FlM2QwNTUxZTAzNWEyMTc2ZDJmMjAyM2Q5ZTljNGQ0YjQ1
11
+ ZWU0NWQ4MDFiZTQ0NzkwMzlkY2RmMDU1YmQ4OThlNDIxNzkxYmQ=
12
+ data.tar.gz: !binary |-
13
+ OGNiZmMyOGI4YTg5M2Y5MWQxOGQ5ZTZhZmZmZWQzYzc0YzljZjc2NDkwMzVj
14
+ YzM2YzVjNDZjYzBmMDUwYWZlNmMzYWIwYTJkODgzN2Q5Mjk3MjllNmJmMGM0
15
+ MzM3NDg1MThlMTY4NGY0YmVlNDlhMDk3OGFmZjRmMTJiZjM2NGY=
data/.gitignore CHANGED
@@ -20,3 +20,4 @@ tmp
20
20
  *.o
21
21
  *.a
22
22
  mkmf.log
23
+ .ruby-version
data/Gemfile CHANGED
@@ -3,5 +3,7 @@ source 'https://rubygems.org'
3
3
  gem 'rubocop'
4
4
  gem 'coveralls', require: false
5
5
  gem 'pry'
6
+ gem 'guard'
7
+ gem 'guard-rspec', require: false
6
8
 
7
9
  gemspec
@@ -0,0 +1,33 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ # Note: The cmd option is now required due to the increasing number of ways
5
+ # rspec may be run, below are examples of the most common uses.
6
+ # * bundler: 'bundle exec rspec'
7
+ # * bundler binstubs: 'bin/rspec'
8
+ # * spring: 'bin/rsspec' (This will use spring if running and you have
9
+ # installed the spring binstubs per the docs)
10
+ # * zeus: 'zeus rspec' (requires the server to be started separetly)
11
+ # * 'just' rspec: 'rspec'
12
+ guard :rspec, cmd: 'bundle exec rspec' do
13
+ watch(%r{^spec/.+_spec\.rb$})
14
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
15
+ watch('spec/spec_helper.rb') { "spec" }
16
+
17
+ # Rails example
18
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
19
+ watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
20
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
21
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
22
+ watch('config/routes.rb') { "spec/routing" }
23
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
24
+ watch('spec/rails_helper.rb') { "spec" }
25
+
26
+ # Capybara features specs
27
+ watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
28
+
29
+ # Turnip features and steps
30
+ watch(%r{^spec/acceptance/(.+)\.feature$})
31
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
32
+ end
33
+
data/README.md CHANGED
@@ -2,27 +2,27 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/qlang.svg)](http://badge.fury.io/rb/qlang) [![Build Status](https://travis-ci.org/gogotanaka/Q.svg?branch=master)](https://travis-ci.org/gogotanaka/Q) [![Coverage Status](https://coveralls.io/repos/gogotanaka/Q/badge.png?branch=master)](https://coveralls.io/r/gogotanaka/Q?branch=master) [![Code Climate](https://codeclimate.com/github/gogotanaka/Q/badges/gpa.svg)](https://codeclimate.com/github/gogotanaka/Q) [![Dependency Status](https://gemnasium.com/gogotanaka/Q.svg)](https://gemnasium.com/gogotanaka/Q)
4
4
 
5
- ## Do you know one of the best language in this world?
5
+ ## Do you know the one best language in this world?
6
6
 
7
- #### I belive mathematics is that one absolutely.
7
+ #### I believe mathematics is absolutely that one.
8
8
 
9
- ## How can we deal such a great mathematics in discret world?
9
+ ## How can we deal something as great as mathematics in a discrete world?
10
10
 
11
- #### Q-language can be.
11
+ #### Q-language is the answer.
12
12
 
13
- Q let you know the sense of mathematics with Keyboard same as with a pen.
13
+ Q lets you have a sense of mathematics using a keyboard, the same as you would with a pen.
14
14
 
15
15
  ```
16
- +---Discret world---+ +------mathematics-----+
17
- | Ruby | | axiom |
18
- | TeX |<------ Q ------>| Uncountable noun |
19
- | Pyhthon | | real number topology|
20
- +-------------------+ +----------------------+
16
+ +---Discrete world---+ +------Mathematics-------+
17
+ | Ruby | | axiom |
18
+ | TeX |<------ Q ------>| Uncountable noun |
19
+ | Python | | real number topology |
20
+ +--------------------+ +------------------------+
21
21
  ```
22
22
 
23
23
  ## Demo
24
24
 
25
- Below codes is input and output for interpreter of q-lang
25
+ The code below is input and output for the q-lang interpreter
26
26
 
27
27
  (you can try it by `qlang -i`)
28
28
 
@@ -37,7 +37,7 @@ d/dx(cos(x))
37
37
  d/dx log(x)
38
38
  => ( 1 / x )
39
39
 
40
- d/dy xy
40
+ d/dy xy
41
41
  => ( x )
42
42
 
43
43
  d/dx e^x
@@ -53,7 +53,7 @@ S(log(x)dx)[0..1]
53
53
  S(sin(x)dx)[0..pi]
54
54
  => 2.0
55
55
 
56
- S(cos(x)dx)[0..pi]
56
+ S(cos(x)dx)[0..pi]
57
57
  => 0.0
58
58
  ```
59
59
 
@@ -96,21 +96,25 @@ f(1, 2)
96
96
 
97
97
  ## How to use
98
98
 
99
- Install qlang gme.
99
+ Install qlang gem.
100
100
 
101
101
  $ gem install qlang
102
-
103
-
102
+
103
+ ## Interpreter
104
+
105
+ $ qlang -i
106
+ Q:->
107
+
104
108
  ## Use as native language
105
109
 
106
110
  ### Compile into R
107
111
 
108
112
  $ qlang -r foo.q
109
-
113
+
110
114
  ### Compile into Ruby
111
115
 
112
116
  $ qlang -rb foo.q
113
-
117
+
114
118
  ### Compile into Python
115
119
 
116
120
  $ qlang -py foo.q
@@ -135,7 +139,7 @@ end
135
139
  ```
136
140
 
137
141
  $ qlang -rb example.rb
138
-
142
+
139
143
 
140
144
  ```rb
141
145
  class ExampleClass
@@ -149,12 +153,7 @@ class ExampleClass
149
153
  end
150
154
  ```
151
155
 
152
- ## Interpreter
153
-
154
- $ qlang -i
155
- Q:->
156
-
157
156
  ## Contributing
158
157
 
159
- Welcome any your PR or issue.
160
- You can become commiter, if you commit even once.
158
+ Any PRs or issues are welcome.
159
+ You can become a commiter, even if you only commit once.
data/Rakefile CHANGED
@@ -1,20 +1,20 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
3
 
4
4
  Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
5
+ t.libs << 'test'
6
6
  t.test_files = FileList['test/**/test_*.rb']
7
7
  end
8
8
 
9
- require "rake/extensiontask"
9
+ require 'rake/extensiontask'
10
10
 
11
- Rake::ExtensionTask.new("qlang") do |ext|
12
- ext.lib_dir = "lib/qlang"
11
+ Rake::ExtensionTask.new('qlang') do |ext|
12
+ ext.lib_dir = 'lib/qlang'
13
13
  end
14
14
 
15
15
  task :compile_and_test do
16
- Rake::Task["compile"].invoke
17
- Rake::Task["test"].invoke
16
+ Rake::Task['compile'].invoke
17
+ Rake::Task['test'].invoke
18
18
  end
19
19
 
20
20
  task default: :compile_and_test
@@ -1,3 +1,3 @@
1
- require "mkmf"
1
+ require 'mkmf'
2
2
 
3
- create_makefile("qlang/qlang")
3
+ create_makefile('qlang/qlang')
@@ -12,13 +12,13 @@ describe Qlang do
12
12
  expect(
13
13
  Q.to_r.compile('{key1: 234234, key2: 387342 }')
14
14
  ).to eq(
15
- "list(key1=234234, key2=387342)"
15
+ 'list(key1=234234, key2=387342)'
16
16
  )
17
17
 
18
18
  expect(
19
19
  Q.to_r.compile('{key1:234234,key2:387342,key3:38733242}')
20
20
  ).to eq(
21
- "list(key1=234234, key2=387342, key3=38733242)"
21
+ 'list(key1=234234, key2=387342, key3=38733242)'
22
22
  )
23
23
 
24
24
  # expect(
@@ -7,25 +7,25 @@ describe Qlang do
7
7
  expect(
8
8
  Q.to_r.compile('(1 2 3; 4 5 6)')
9
9
  ).to eq(
10
- "matrix(c(1, 2, 3, 4, 5, 6), 2, 3, byrow = TRUE)"
10
+ 'matrix(c(1, 2, 3, 4, 5, 6), 2, 3, byrow = TRUE)'
11
11
  )
12
12
 
13
13
  expect(
14
14
  Q.to_r.compile('(1 2 3 ; 4 5 6)')
15
15
  ).to eq(
16
- "matrix(c(1, 2, 3, 4, 5, 6), 2, 3, byrow = TRUE)"
16
+ 'matrix(c(1, 2, 3, 4, 5, 6), 2, 3, byrow = TRUE)'
17
17
  )
18
18
 
19
19
  expect(
20
20
  Q.to_r.compile('(1 2 3 ; 4 5 6; 7 8 9)')
21
21
  ).to eq(
22
- "matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), 3, 3, byrow = TRUE)"
22
+ 'matrix(c(1, 2, 3, 4, 5, 6, 7, 8, 9), 3, 3, byrow = TRUE)'
23
23
  )
24
24
 
25
25
  expect(
26
26
  Q.to_r.compile('(1;2;3)')
27
27
  ).to eq(
28
- "matrix(c(1, 2, 3), 3, 1, byrow = TRUE)"
28
+ 'matrix(c(1, 2, 3), 3, 1, byrow = TRUE)'
29
29
  )
30
30
  end
31
31
  end
@@ -35,19 +35,19 @@ describe Qlang do
35
35
  expect(
36
36
  Q.to_ruby.compile('(1 2 3; 4 5 6)')
37
37
  ).to eq(
38
- "Matrix[[1, 2, 3], [4, 5, 6]]"
38
+ 'Matrix[[1, 2, 3], [4, 5, 6]]'
39
39
  )
40
40
 
41
41
  expect(
42
42
  Q.to_ruby.compile('(1 2 3 ; 4 5 6; 7 8 9)')
43
43
  ).to eq(
44
- "Matrix[[1, 2, 3], [4, 5, 6], [7, 8, 9]]"
44
+ 'Matrix[[1, 2, 3], [4, 5, 6], [7, 8, 9]]'
45
45
  )
46
46
 
47
47
  expect(
48
48
  Q.to_ruby.compile('(1;2;3)')
49
49
  ).to eq(
50
- "Matrix[[1], [2], [3]]"
50
+ 'Matrix[[1], [2], [3]]'
51
51
  )
52
52
  end
53
53
  end
@@ -7,19 +7,19 @@ describe Qlang do
7
7
  expect(
8
8
  Q.to_r.compile('(1 2 3)')
9
9
  ).to eq(
10
- "c(1, 2, 3)"
10
+ 'c(1, 2, 3)'
11
11
  )
12
12
 
13
13
  expect(
14
14
  Q.to_r.compile('(1 2 3 4 5 6)')
15
15
  ).to eq(
16
- "c(1, 2, 3, 4, 5, 6)"
16
+ 'c(1, 2, 3, 4, 5, 6)'
17
17
  )
18
18
 
19
19
  expect(
20
20
  Q.to_r.compile('(1 2 3 4 5 6)')
21
21
  ).to eq(
22
- "c(1, 2, 3, 4, 5, 6)"
22
+ 'c(1, 2, 3, 4, 5, 6)'
23
23
  )
24
24
  end
25
25
  end
@@ -29,7 +29,7 @@ describe Qlang do
29
29
  expect(
30
30
  Q.to_ruby.compile('(1 2 3)')
31
31
  ).to eq(
32
- "Vector[1, 2, 3]"
32
+ 'Vector[1, 2, 3]'
33
33
  )
34
34
  end
35
35
  end
@@ -39,7 +39,7 @@ describe Qlang do
39
39
  expect(
40
40
  Q.to_python.compile('(1 2 3)')
41
41
  ).to eq(
42
- "array([1, 2, 3])"
42
+ 'array([1, 2, 3])'
43
43
  )
44
44
  end
45
45
  end
@@ -10,7 +10,6 @@ module Qlang
10
10
  else
11
11
  fail "Function is not implemented for #{$meta_info.lang_str}"
12
12
  end
13
-
14
13
  end
15
14
  module_function :execute
16
15
  end
@@ -9,7 +9,6 @@ module Qlang
9
9
  else
10
10
  fail "Integral is not implemented for #{$meta_info.lang_str}"
11
11
  end
12
-
13
12
  end
14
13
  module_function :execute
15
14
  end
@@ -17,6 +17,6 @@ module Qlang
17
17
  fail "List is not implemented for #{$meta_info.lang_str}"
18
18
  end
19
19
  end
20
- end
20
+ end
21
21
  end
22
22
  end
@@ -9,7 +9,6 @@ module Qlang
9
9
  else
10
10
  fail "List is not implemented for #{$meta_info.lang_str}"
11
11
  end
12
-
13
12
  end
14
13
  module_function :execute
15
14
  end
@@ -11,6 +11,6 @@ module Qlang
11
11
  fail "List is not implemented for #{$meta_info.lang_str}"
12
12
  end
13
13
  end
14
- end
14
+ end
15
15
  end
16
16
  end
@@ -15,7 +15,7 @@ module Qlang
15
15
 
16
16
  print "#{e.class}: " unless e.class == RuntimeError
17
17
  puts "#{e.message}"
18
- puts " Use --trace for backtrace."
18
+ puts ' Use --trace for backtrace.'
19
19
  exit 1
20
20
  ensure
21
21
  exit 0
@@ -23,42 +23,42 @@ module Qlang
23
23
 
24
24
  private
25
25
 
26
- def ch_compile_type(lang)
27
- case lang
28
- when '-rb'
29
- Qlang.to_ruby
30
- when '-r'
31
- Qlang.to_r
32
- when '-py'
33
- Qlang.to_python
34
- else
35
- print 'Q support only Ruby and R now.'
36
- end
26
+ def ch_compile_type(lang)
27
+ case lang
28
+ when '-rb'
29
+ Qlang.to_ruby
30
+ when '-r'
31
+ Qlang.to_r
32
+ when '-py'
33
+ Qlang.to_python
34
+ else
35
+ print 'Q support only Ruby and R now.'
37
36
  end
37
+ end
38
38
 
39
- def parse(file_path)
40
- file = open_file(file_path)
41
- input_string = read_file(file)
42
- file.close
43
- input_string.gsub(/(.*)I love mathematics\.(.*)Q\.E\.D(.*)/m) {
44
- "#{$1}#{Kconv.tosjis(Qlang.compile($2))}#{$3}"
45
- }
46
- end
39
+ def parse(file_path)
40
+ file = open_file(file_path)
41
+ input_string = read_file(file)
42
+ file.close
43
+ input_string.gsub(/(.*)I love mathematics\.(.*)Q\.E\.D(.*)/m) {
44
+ "#{$1}#{Kconv.tosjis(Qlang.compile($2))}#{$3}"
45
+ }
46
+ end
47
47
 
48
- def write!(output_path, string)
49
- open(output_path, 'w') do |f|
50
- f.puts string
51
- end
48
+ def write!(output_path, string)
49
+ open(output_path, 'w') do |f|
50
+ f.puts string
52
51
  end
52
+ end
53
53
 
54
- def open_file(filename, flag = 'r')
55
- return if filename.nil?
56
- File.open(filename, flag)
57
- end
54
+ def open_file(filename, flag = 'r')
55
+ return if filename.nil?
56
+ File.open(filename, flag)
57
+ end
58
58
 
59
- def read_file(file)
60
- file.read
61
- end
59
+ def read_file(file)
60
+ file.read
61
+ end
62
62
  end
63
63
  end
64
64
  end
@@ -41,6 +41,5 @@ module Qlang
41
41
  str.equalize!
42
42
  end
43
43
  end
44
-
45
44
  end
46
45
  end
@@ -67,15 +67,15 @@ module Qlang
67
67
  ## POST(with side effect, without idempotence.)
68
68
  def parsed!(parsed, target)
69
69
  case target
70
- when Range
71
- parsed_between!((target.first.to_i)..(target.last.to_i), parsed)
72
- else
73
- parsed_at!(target.to_i, parsed)
70
+ when Range
71
+ parsed_between!((target.first.to_i)..(target.last.to_i), parsed)
72
+ else
73
+ parsed_at!(target.to_i, parsed)
74
74
  end
75
75
  end
76
76
 
77
- #squash!(range, token: :CONT)
78
- def squash!(range, opts={token: :CONT})
77
+ # squash!(range, token: :CONT)
78
+ def squash!(range, opts = { token: :CONT })
79
79
  token = opts[:token]
80
80
  range = (range.first.to_i)..(range.last.to_i)
81
81
  value = values[range].join
@@ -89,19 +89,19 @@ module Qlang
89
89
  end
90
90
 
91
91
  private
92
- def parsed_at!(token_position, parsed)
93
- @lexeds.delete_at(token_position)
94
- @lexeds.insert(token_position, { token: :R, value: parsed })
95
- end
96
92
 
97
- def parsed_between!(token_range, parsed)
98
- start_pos = token_range.first
99
- token_range.count.times do
100
- @lexeds.delete_at(start_pos)
101
- end
102
- @lexeds.insert(start_pos, { token: :R, value: parsed })
103
- end
93
+ def parsed_at!(token_position, parsed)
94
+ @lexeds.delete_at(token_position)
95
+ @lexeds.insert(token_position, { token: :R, value: parsed })
96
+ end
104
97
 
98
+ def parsed_between!(token_range, parsed)
99
+ start_pos = token_range.first
100
+ token_range.count.times do
101
+ @lexeds.delete_at(start_pos)
102
+ end
103
+ @lexeds.insert(start_pos, { token: :R, value: parsed })
104
+ end
105
105
  end
106
106
  end
107
107
  end
@@ -1,3 +1,6 @@
1
+ #!/bin/env ruby
2
+ # encoding: utf-8
3
+
1
4
  module Qlang
2
5
  module Lexer
3
6
  class MainLexer < Base
@@ -12,6 +15,7 @@ module Qlang
12
15
  rule(/#{LPRN}(#{NUMS_BY_SP_BY_SCLN_OR_NELN})#{RPRN}/m) { :matrix }
13
16
 
14
17
  rule(/∑#{LBRCT}(#{VAR})=(#{INT}),#{ANYSP}(#{INT})#{RBRCT} (#{FORMULA})/) { :sigma }
18
+ rule(/sigma#{LBRCT}(#{VAR})=(#{INT}),#{ANYSP}(#{INT})#{RBRCT} (#{FORMULA})/) { :sigma }
15
19
 
16
20
  rule(/#{FUNCCN}/) { :FUNCCN }
17
21
 
@@ -19,15 +19,14 @@ module Qlang
19
19
 
20
20
  # VARIABLE
21
21
  VAR = /(?:[a-d]|[f-z])/
22
- #VAR_MUL2 = /(?!pi)#{VAR}{2}/
22
+ # VAR_MUL2 = /(?!pi)#{VAR}{2}/
23
23
  # #VAR_MUL3 = /(?!#{EMBEDDED_FUNC})#{VAR}{3}/
24
24
  # # FIX:
25
- #VAR_MUL = /(?!#{EMBEDDED_FUNC})#{VAR_MUL2}/
25
+ # VAR_MUL = /(?!#{EMBEDDED_FUNC})#{VAR_MUL2}/
26
26
 
27
27
  # # TERM
28
28
  # TERM = /(#{NUM}|#{VAR_MUL}|#{VAR_MUL})/
29
29
 
30
-
31
30
  # OPE
32
31
  PLS = /\+/
33
32
  SUB = /-/
@@ -41,7 +40,6 @@ module Qlang
41
40
  ANYSTR = /.+/
42
41
  NONL = /[^\r\n]/
43
42
 
44
-
45
43
  PRN = /(?:#{LPRN}|#{RPRN})/
46
44
 
47
45
  LBRCS = /\{/
@@ -71,7 +69,7 @@ module Qlang
71
69
  # TODO: what is better
72
70
  class Util
73
71
  def self.string_out(str, partition)
74
- /#{ANYSP}#{str}(?:#{ANYSP}#{partition}#{ANYSP}#{str})*#{ANYSP}/
72
+ /#{ANYSP}#{str}(?:#{ANYSP}#{partition}#{ANYSP}#{str})*#{ANYSP}/
75
73
  end
76
74
 
77
75
  def self.func_call(args)
@@ -12,12 +12,12 @@ class MetaInfo
12
12
  # TODO: YAML.load_file("./lib/qlang/utils/langs.yml")['langs']
13
13
  def langs_hash
14
14
  {
15
- r:"R",
16
- ruby: "Ruby",
17
- python: "Pyhton",
18
- haskell: "Haskell",
19
- scala: "Scala",
20
- js: "Javascript"
15
+ r: 'R',
16
+ ruby: 'Ruby',
17
+ python: 'Pyhton',
18
+ haskell: 'Haskell',
19
+ scala: 'Scala',
20
+ js: 'Javascript'
21
21
  }
22
22
  end
23
23
 
@@ -25,25 +25,26 @@ module Qlang
25
25
  when /:(vector)(\d+)/, /:(matrix)(\d+)/, /:(tmatrix)(\d+)/, /:(integral)(\d+)/, /:(def_func)(\d+)/, /:(differential)(\d+)/, /:(limit)(\d+)/, /:(sigma)(\d+)/
26
26
  token_els = lexed.get_els($2)
27
27
 
28
- parsed = case $1
29
- when 'vector'
30
- VectorParser.execute(token_els)
31
- when 'matrix'
32
- MatrixParser.execute(token_els)
33
- when 'tmatrix'
34
- MatrixParser.execute(token_els, trans: true)
35
- when 'limit'
36
- LimitParser.execute(token_els)
37
- when 'integral'
38
- IntegralParser.execute(token_els)
39
- when 'def_func'
40
- FuncParser.execute(token_els)
41
- when 'sigma'
42
- SigmaParser.execute(token_els)
43
- when 'differential'
44
- del_var, formula = token_els
45
- "d/d#{del_var}(#{FormulaParser.execute(formula)})"
46
- end
28
+ parsed =
29
+ case $1
30
+ when 'vector'
31
+ VectorParser.execute(token_els)
32
+ when 'matrix'
33
+ MatrixParser.execute(token_els)
34
+ when 'tmatrix'
35
+ MatrixParser.execute(token_els, trans: true)
36
+ when 'limit'
37
+ LimitParser.execute(token_els)
38
+ when 'integral'
39
+ IntegralParser.execute(token_els)
40
+ when 'def_func'
41
+ FuncParser.execute(token_els)
42
+ when 'sigma'
43
+ SigmaParser.execute(token_els)
44
+ when 'differential'
45
+ del_var, formula = token_els
46
+ "d/d#{del_var}(#{FormulaParser.execute(formula)})"
47
+ end
47
48
  lexed.parsed!(parsed, $2)
48
49
 
49
50
  when /:LPRN(\d+):CONT(\d+):RPRN(\d+)/
@@ -59,7 +60,8 @@ module Qlang
59
60
  tokens_range = $1.to_i..$3.to_i
60
61
  token_val = lexed.get_value($2)
61
62
 
62
- cont = case token_val
63
+ cont =
64
+ case token_val
63
65
  when /#{ONEHASH}(#{CMA}#{ONEHASH})*/
64
66
  ListParser.execute(token_val)
65
67
  else
@@ -95,6 +97,5 @@ module Qlang
95
97
  end
96
98
  end
97
99
  end
98
-
99
100
  end
100
101
  end
@@ -3,7 +3,7 @@ module Qlang
3
3
  module ListParser
4
4
  include Base
5
5
  def execute(lexed)
6
- arys = lexed.split(/ *, */).map { |e| e.split(/ *: */).map{|e2|e2.delete(' ')} }
6
+ arys = lexed.split(/ *, */).map { |e| e.split(/ *: */).map { |e2| e2.delete(' ') } }
7
7
  ListApi.execute(arys)
8
8
  end
9
9
  module_function :execute
@@ -2,7 +2,7 @@ module Qlang
2
2
  module Parser
3
3
  module MatrixParser
4
4
  include Base
5
- def execute(els, opts={trans: false})
5
+ def execute(els, opts = { trans: false })
6
6
  trans = opts[:trans]
7
7
  rows = els.first.split(/ *(?:;|\n) */).map(&:split_by_sp)
8
8
  rows.all? { |row| row.count == rows.first.count }
@@ -1,3 +1,3 @@
1
1
  module Qlang
2
- VERSION = "0.0.27182123"
2
+ VERSION = '0.0.27182124'
3
3
  end
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Qlang::VERSION
9
9
  spec.authors = ['gogotanaka']
10
10
  spec.email = ['mail@tanakakazuki.com']
11
- spec.extensions = ["ext/qlang/extconf.rb"]
11
+ spec.extensions = ['ext/qlang/extconf.rb']
12
12
  spec.summary = %q{Enjoy MATH!}
13
13
  spec.description = %q{Enjoy MATH!}
14
14
  spec.homepage = 'http://q-language.org/'
@@ -19,10 +19,10 @@ Gem::Specification.new do |spec|
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ['lib']
21
21
 
22
- spec.add_dependency "dydx", '~> 0.1.41421'
22
+ spec.add_dependency 'dydx', '~> 0.1.41421'
23
23
 
24
- spec.add_development_dependency "bundler"
25
- spec.add_development_dependency "rake"
26
- spec.add_development_dependency "rake-compiler"
27
- spec.add_development_dependency "minitest"
24
+ spec.add_development_dependency 'bundler'
25
+ spec.add_development_dependency 'rake'
26
+ spec.add_development_dependency 'rake-compiler'
27
+ spec.add_development_dependency 'minitest'
28
28
  end
@@ -3,7 +3,6 @@ require 'minitest_helper'
3
3
  class TestTokens < MiniTest::Unit::TestCase
4
4
  include Qlang::Lexer::Tokens
5
5
  def setup
6
-
7
6
  end
8
7
 
9
8
  def full_match(rgx, str)
@@ -2,7 +2,6 @@ require 'minitest_helper'
2
2
 
3
3
  class TestDifferential < TestInterpreterBase
4
4
  def setup
5
-
6
5
  end
7
6
 
8
7
  def test_general
@@ -2,7 +2,6 @@ require 'minitest_helper'
2
2
 
3
3
  class TestFunction < TestInterpreterBase
4
4
  def setup
5
-
6
5
  end
7
6
 
8
7
  def test_general
@@ -2,7 +2,6 @@ require 'minitest_helper'
2
2
 
3
3
  class TestGeneral < TestInterpreterBase
4
4
  def setup
5
-
6
5
  end
7
6
 
8
7
  def test_general
@@ -2,7 +2,6 @@ require 'minitest_helper'
2
2
 
3
3
  class TestIntegral < TestInterpreterBase
4
4
  def setup
5
-
6
5
  end
7
6
 
8
7
  def test_general
@@ -2,7 +2,6 @@ require 'minitest_helper'
2
2
 
3
3
  class TestLimit < TestInterpreterBase
4
4
  def setup
5
-
6
5
  end
7
6
 
8
7
  def assert_iq_equal(output, input)
@@ -20,10 +19,10 @@ class TestLimit < TestInterpreterBase
20
19
  'lim[x->10] x'
21
20
  )
22
21
 
23
- assert_iq_equal(
24
- '2.7182682371744895',
25
- 'lim[x->oo] (1 + 1/x)^x'
26
- )
22
+ # assert_iq_equal(
23
+ # '2.7182682371744895',
24
+ # 'lim[x->oo] (1 + 1/x)^x'
25
+ # )
27
26
 
28
27
  assert_iq_equal(
29
28
  'oo',
@@ -2,7 +2,6 @@ require 'minitest_helper'
2
2
 
3
3
  class TestMatrix < TestInterpreterBase
4
4
  def setup
5
-
6
5
  end
7
6
 
8
7
  def test_integer
@@ -1,8 +1,9 @@
1
+ #!/bin/env ruby
2
+ # encoding: utf-8
1
3
  require 'minitest_helper'
2
4
 
3
5
  class TestSigma < TestInterpreterBase
4
6
  def setup
5
-
6
7
  end
7
8
 
8
9
  def test_general
@@ -2,7 +2,6 @@ require 'minitest_helper'
2
2
 
3
3
  class TestVector < TestInterpreterBase
4
4
  def setup
5
-
6
5
  end
7
6
 
8
7
  def test_integer
@@ -2,7 +2,6 @@ require 'minitest_helper'
2
2
 
3
3
  class TestR < TestInterpreterBase
4
4
  def setup
5
-
6
5
  end
7
6
 
8
7
  def assert_r_compl_eq(output, input)
@@ -2,7 +2,6 @@ require 'minitest_helper'
2
2
 
3
3
  class TestRuby < TestInterpreterBase
4
4
  def setup
5
-
6
5
  end
7
6
 
8
7
  def test_integer
@@ -6,7 +6,7 @@ class TestQMatrix < TestInterpreterBase
6
6
  end
7
7
 
8
8
  def test_main
9
- #assert_equal(50.0, QMatrix.new.func(10))
9
+ # assert_equal(50.0, QMatrix.new.func(10))
10
10
 
11
11
  assert_equal(8.0, QMatrix.new.execute(0, 2, 100))
12
12
  end
@@ -2,7 +2,6 @@ require 'minitest_helper'
2
2
 
3
3
  class TestQlang < MiniTest::Unit::TestCase
4
4
  def setup
5
-
6
5
  end
7
6
 
8
7
  def assert_to_ruby(input, output)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qlang
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.27182123
4
+ version: 0.0.27182124
5
5
  platform: ruby
6
6
  authors:
7
7
  - gogotanaka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-31 00:00:00.000000000 Z
11
+ date: 2014-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dydx
@@ -28,56 +28,56 @@ dependencies:
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
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
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ! '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ! '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake-compiler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ! '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: minitest
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ! '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ! '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: Enjoy MATH!
@@ -94,6 +94,7 @@ files:
94
94
  - .rubocop.yml
95
95
  - .travis.yml
96
96
  - Gemfile
97
+ - Guardfile
97
98
  - LICENSE.txt
98
99
  - README.md
99
100
  - Rakefile
@@ -170,17 +171,17 @@ require_paths:
170
171
  - lib
171
172
  required_ruby_version: !ruby/object:Gem::Requirement
172
173
  requirements:
173
- - - '>='
174
+ - - ! '>='
174
175
  - !ruby/object:Gem::Version
175
176
  version: '0'
176
177
  required_rubygems_version: !ruby/object:Gem::Requirement
177
178
  requirements:
178
- - - '>='
179
+ - - ! '>='
179
180
  - !ruby/object:Gem::Version
180
181
  version: '0'
181
182
  requirements: []
182
183
  rubyforge_project:
183
- rubygems_version: 2.0.2
184
+ rubygems_version: 2.4.2
184
185
  signing_key:
185
186
  specification_version: 4
186
187
  summary: Enjoy MATH!