qlang 0.0.27182120 → 0.0.27182121

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82f393f67556cb1f5e6e37eba4a70f75b5e3357d
4
- data.tar.gz: 660f56cb8a0fbae5d321ad3e2b9ca888719fa4c1
3
+ metadata.gz: 456c8d3f8543f42ede24cddf63aa3a268d06d3c2
4
+ data.tar.gz: 433cf3848255d0c1a77f25c360fd8987d1a99395
5
5
  SHA512:
6
- metadata.gz: 2e40198040a6e4046a5d8fa0e9dd04fb3c8ee5e2ea7fbac5ad47cc6cd22c3c0fa07a69960dc938ce695aaf22fa93f0260037b539ae5bb9d2703f4e92460cf1da
7
- data.tar.gz: 111757064ce64d1048684a1ea79a1cbdaa4c10b8bb81a20c113dbbee5612891c3a51f5e9ec0671c537a3e7c626b371d9b940ac346ecae7fe757b2bbec869937b
6
+ metadata.gz: 0484b8bbfb2ef76fe911bc36995351d7445110fe487e5cae68a17b2225745bd0a05dd839e8e57617a29ac0d6f90a8a386be77bf93bedc2b5da966dfcb1f0ec62
7
+ data.tar.gz: 6d61d61e6ce5797c6257e4a053c9284091815dcaab2f7304873cca62b8ddd81db495a9f25fc91e1d946a904514366ea6ee9b862e520f2d6885bfe2335bfee8cf
data/README.md CHANGED
@@ -22,7 +22,7 @@ Q let you know the sense of mathematics with Keyboard same as with a pen.
22
22
 
23
23
  ## Demo
24
24
 
25
- Below code is input and output for interpreter of q-lang
25
+ Below codes is input and output for interpreter of q-lang
26
26
 
27
27
  (you can try it by `qlang -i`)
28
28
 
@@ -32,18 +32,17 @@ Below code is input and output for interpreter of q-lang
32
32
  d/dx(cos(x))
33
33
  => ( - sin( x ) )
34
34
 
35
- d/dx(log(x))
36
- => ( 1 / x )
37
-
38
35
  # You can omit parentheses
39
36
 
40
- d/dy y^2
41
- => ( 2 * y )
37
+ d/dx log(x)
38
+ => ( 1 / x )
42
39
 
43
40
  d/dy xy
44
41
  => ( x )
45
- ```
46
42
 
43
+ d/dx e^x
44
+ => e ^ x
45
+ ```
47
46
 
48
47
  ### Integrate
49
48
 
@@ -58,6 +57,21 @@ S(cos(x)dx)[0..pi]
58
57
  => 0.0
59
58
  ```
60
59
 
60
+ ### Limit
61
+
62
+ ```
63
+ lim[x->oo] (1 + 1/x)^x
64
+ => 2.7182682371744895
65
+
66
+ lim[x->0] 1/x
67
+ => oo
68
+ ```
69
+
70
+ ### Sigma
71
+ ```
72
+ ∑[x=0,10] x
73
+ => 55.0
74
+ ```
61
75
 
62
76
  ### Matrix
63
77
 
@@ -6,34 +6,16 @@ require 'yaml'
6
6
 
7
7
  $:.unshift(File.dirname(__FILE__))
8
8
  # Q core
9
+ require 'qlang/meta_info'
9
10
  require 'qlang/utils/ruby_ext'
10
11
  require 'qlang/lexer'
11
12
  require 'qlang/parser'
12
13
 
13
14
  module Qlang
14
- # $meta_info indicate what and how to do.
15
- class MetaInfo
16
- include Singleton
17
- attr_accessor :lang, :opts, :mode
18
-
19
- LANGS_HASH = YAML.load_file("./lib/qlang/utils/langs.yml")['langs']
20
-
21
- def _load
22
- # compiles into R as default.
23
- lang = :r
24
- end
25
-
26
- def langs_hash
27
- LANGS_HASH
28
- end
29
-
30
- def lang_str
31
- LANGS_HASH[@lang.to_s]
32
- end
33
- end
34
15
  $meta_info = MetaInfo.instance
35
16
 
36
17
  class << self
18
+
37
19
  def compile(str)
38
20
  lexed = Lexer.execute(str)
39
21
  Kconv.tosjis(Parser.execute(lexed))
@@ -48,6 +30,7 @@ module Qlang
48
30
  end
49
31
 
50
32
  end
33
+
51
34
  end
52
35
 
53
36
  # Make alias as Q
@@ -0,0 +1,27 @@
1
+ # $meta_info indicate what and how to do.
2
+ require 'pry'
3
+ class MetaInfo
4
+ include Singleton
5
+ attr_accessor :lang, :opts, :mode
6
+
7
+ def _load
8
+ # compiles into R as default.
9
+ lang = :r
10
+ end
11
+
12
+ # TODO: YAML.load_file("./lib/qlang/utils/langs.yml")['langs']
13
+ def langs_hash
14
+ {
15
+ r:"R",
16
+ ruby: "Ruby",
17
+ python: "Pyhton",
18
+ haskell: "Haskell",
19
+ scala: "Scala",
20
+ js: "Javascript"
21
+ }
22
+ end
23
+
24
+ def lang_str
25
+ LANGS_HASH[@lang.to_s]
26
+ end
27
+ end
@@ -1,7 +1,7 @@
1
1
  langs:
2
- r: R
3
- ruby: Ruby
4
- python: Pyhton
5
- haskell: Haskell
6
- scala: Scala
7
- js: Javascript
2
+ :r: R
3
+ :ruby: Ruby
4
+ :python: Pyhton
5
+ :haskell: Haskell
6
+ :scala: Scala
7
+ :js: Javascript
@@ -1,3 +1,3 @@
1
1
  module Qlang
2
- VERSION = "0.0.27182120"
2
+ VERSION = "0.0.27182121"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qlang
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.27182120
4
+ version: 0.0.27182121
5
5
  platform: ruby
6
6
  authors:
7
7
  - gogotanaka
@@ -130,6 +130,7 @@ files:
130
130
  - lib/qlang/lexer/formula_lexer.rb
131
131
  - lib/qlang/lexer/main_lexer.rb
132
132
  - lib/qlang/lexer/tokens.rb
133
+ - lib/qlang/meta_info.rb
133
134
  - lib/qlang/parser.rb
134
135
  - lib/qlang/parser/base.rb
135
136
  - lib/qlang/parser/formula_parser.rb