linmeric 0.1.0 → 0.2.0

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.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.md +51 -0
  5. data/Rakefile +10 -0
  6. data/bin/help/Help.rb +184 -0
  7. data/bin/help/Help_inst.rb +244 -0
  8. data/bin/linguide +23 -0
  9. data/bin/linmeric +36 -70
  10. data/doc/Archive.html +352 -0
  11. data/doc/Calculator/Evaluator.html +477 -0
  12. data/doc/Calculator/Lexer.html +186 -0
  13. data/doc/Calculator/Token.html +257 -0
  14. data/doc/Calculator.html +181 -0
  15. data/doc/Dim.html +257 -0
  16. data/doc/Filename.html +246 -0
  17. data/doc/Fixnum.html +253 -0
  18. data/doc/Float.html +253 -0
  19. data/doc/Function.html +784 -0
  20. data/doc/InputError.html +102 -0
  21. data/doc/Instructions_en.txt +6 -7
  22. data/doc/Instructions_it.txt +6 -9
  23. data/doc/Integrators.html +436 -0
  24. data/doc/LU.html +435 -0
  25. data/doc/Lexer.html +261 -0
  26. data/doc/Linmeric.html +109 -0
  27. data/doc/Listener.html +605 -0
  28. data/doc/Matrix.html +1719 -0
  29. data/doc/MyArgError.html +102 -0
  30. data/doc/NilClass.html +202 -0
  31. data/doc/Numeric.html +251 -0
  32. data/doc/Parser.html +389 -0
  33. data/doc/PrintError.html +622 -0
  34. data/doc/README_md.html +142 -0
  35. data/doc/Scp.html +530 -0
  36. data/doc/Sizer.html +652 -0
  37. data/doc/String.html +540 -0
  38. data/doc/Token.html +341 -0
  39. data/doc/Tool.html +394 -0
  40. data/doc/created.rid +18 -0
  41. data/doc/css/fonts.css +167 -0
  42. data/doc/css/rdoc.css +590 -0
  43. data/doc/fonts/Lato-Light.ttf +0 -0
  44. data/doc/fonts/Lato-LightItalic.ttf +0 -0
  45. data/doc/fonts/Lato-Regular.ttf +0 -0
  46. data/doc/fonts/Lato-RegularItalic.ttf +0 -0
  47. data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
  48. data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
  49. data/doc/images/add.png +0 -0
  50. data/doc/images/arrow_up.png +0 -0
  51. data/doc/images/brick.png +0 -0
  52. data/doc/images/brick_link.png +0 -0
  53. data/doc/images/bug.png +0 -0
  54. data/doc/images/bullet_black.png +0 -0
  55. data/doc/images/bullet_toggle_minus.png +0 -0
  56. data/doc/images/bullet_toggle_plus.png +0 -0
  57. data/doc/images/date.png +0 -0
  58. data/doc/images/delete.png +0 -0
  59. data/doc/images/find.png +0 -0
  60. data/doc/images/loadingAnimation.gif +0 -0
  61. data/doc/images/macFFBgHack.png +0 -0
  62. data/doc/images/package.png +0 -0
  63. data/doc/images/page_green.png +0 -0
  64. data/doc/images/page_white_text.png +0 -0
  65. data/doc/images/page_white_width.png +0 -0
  66. data/doc/images/plugin.png +0 -0
  67. data/doc/images/ruby.png +0 -0
  68. data/doc/images/tag_blue.png +0 -0
  69. data/doc/images/tag_green.png +0 -0
  70. data/doc/images/transparent.png +0 -0
  71. data/doc/images/wrench.png +0 -0
  72. data/doc/images/wrench_orange.png +0 -0
  73. data/doc/images/zoom.png +0 -0
  74. data/doc/index.html +190 -0
  75. data/doc/js/darkfish.js +161 -0
  76. data/doc/js/jquery.js +9404 -0
  77. data/doc/js/navigation.js +142 -0
  78. data/doc/js/navigation.js.gz +0 -0
  79. data/doc/js/search.js +109 -0
  80. data/doc/js/search_index.js +1 -0
  81. data/doc/js/search_index.js.gz +0 -0
  82. data/doc/js/searcher.js +228 -0
  83. data/doc/js/searcher.js.gz +0 -0
  84. data/doc/table_of_contents.html +834 -0
  85. data/lib/linmeric/Archive.rb +22 -1
  86. data/lib/linmeric/Calculator.rb +252 -0
  87. data/lib/linmeric/CnGal_Matrix_class.rb +130 -49
  88. data/lib/linmeric/CnGal_new_classes.rb +139 -37
  89. data/lib/linmeric/CnGal_tools.rb +23 -40
  90. data/lib/linmeric/Error_print.rb +35 -1
  91. data/lib/linmeric/Function_class.rb +70 -11
  92. data/lib/linmeric/Integrators.rb +81 -35
  93. data/lib/linmeric/LU.rb +26 -5
  94. data/lib/linmeric/Lexer.rb +19 -1
  95. data/lib/linmeric/Listener.rb +25 -5
  96. data/lib/linmeric/Parser.rb +23 -1
  97. data/lib/linmeric/Scopify.rb +52 -31
  98. data/lib/linmeric/Sizer.rb +43 -10
  99. data/lib/linmeric/Token.rb +23 -4
  100. data/lib/linmeric/version.rb +3 -0
  101. data/lib/linmeric.rb +10 -8
  102. data/lib/linmeric_bin.rb +12 -0
  103. metadata +126 -22
  104. data/doc/Instructions_en.html +0 -231
  105. data/doc/Instructions_it.html +0 -231
  106. data/doc/README_en.html +0 -177
  107. data/doc/README_en.txt +0 -30
  108. data/doc/README_it.html +0 -187
  109. data/doc/README_it.txt +0 -32
@@ -5,11 +5,28 @@ require_relative 'Lexer.rb'
5
5
  require_relative 'Error_print.rb'
6
6
  require_relative 'CnGal_new_classes.rb'
7
7
 
8
+ ##
9
+ # Sizer analyzes the sintax of the inserted commands printing
10
+ # errors if they are found, before the string is manipulated by Scp
11
+ # and parsed by Parser.
12
+ #
13
+ #
14
+ # Author:: Massimiliano Dal Mas (mailto:max.codeware@gmail.com)
15
+ # License:: Distributed under MIT license
8
16
  class Sizer
17
+
18
+ # Builds a new lexer
9
19
  def initialize()
10
20
  @lexer = Lexer.new
11
21
  end
12
22
 
23
+ # Analyzes the stream of tokens to check the sintax. It uses
24
+ # a turing machine to find errors.
25
+ #
26
+ # * **argument**: input comand string to analyze or stream of tokens (array)
27
+ # * **argument**: boolean value which identifies the possibility to find the
28
+ # assign symbol `=`. +true+ is default (`=` is allowed)
29
+ # * **returns**: +true+ if the sintax is correct; +false+ else
13
30
  def analyze(string, equal = true)
14
31
  @i = 0
15
32
  state = 0
@@ -24,7 +41,7 @@ class Sizer
24
41
  token = @lexer.tokenize(string) unless string.is_a? Array
25
42
  token = string if string.is_a? Array
26
43
  while @i < token.size
27
- #puts "#{token[@i].me}";puts
44
+
28
45
  case state
29
46
  # beginning state
30
47
  when 0
@@ -76,7 +93,7 @@ class Sizer
76
93
  return false
77
94
  end
78
95
 
79
- # expecting numbers,variables, keywords (
96
+ # expecting numbers,variables, keywords, (
80
97
  when 1
81
98
  case token[@i].attribute
82
99
  when "NUMBER"
@@ -171,7 +188,7 @@ class Sizer
171
188
  PrintError.default(token[@i],@@string)
172
189
  return false
173
190
 
174
- # checking mx arguments (full)
191
+ # checking mx arguments (full check)
175
192
  when 6
176
193
  case token[@i].attribute
177
194
  when "KEYWORD"
@@ -192,10 +209,10 @@ class Sizer
192
209
  unless @i+1 >= token.size
193
210
  if token[@i+1].attribute == "KEYWORD" then
194
211
  @i += 1
195
- unless @i < token.size
196
- PrintError.missing(token[@i-1],@@string)
197
- return false
198
- end
212
+ # unless @i < token.size
213
+ # PrintError.missing(token[@i-1],@@string)
214
+ # return false
215
+ # end
199
216
  unless token[@i].me == "as:"
200
217
  PrintError.missmatch(token[@i],@@string,"keyword 'as:' or operator")
201
218
  return false
@@ -205,13 +222,20 @@ class Sizer
205
222
  PrintError.missing_general_string(token[@i-1].position+token[@i-1],@@string)
206
223
  return false
207
224
  end
208
- return false unless check_block(token)
225
+ if token[@i].attribute == "QUOTES"
226
+ return false unless check_block(token)
227
+ else
228
+ unless token[@i].attribute == "VARIABLE"
229
+ PrintError.default(token[@i],@@string)
230
+ return false
231
+ end
232
+ end
209
233
  end
210
234
  end
211
235
  state = 2
212
236
  end
213
237
 
214
- # checking integ arguments (full)
238
+ # checking integ arguments (full check)
215
239
  when 7
216
240
  unless @i < token.size
217
241
  PrintError.missing(token[@i-1],@@string)
@@ -242,7 +266,7 @@ class Sizer
242
266
  end
243
267
  state = 2
244
268
 
245
- # checking solve args (full)
269
+ # checking solve args (full check)
246
270
  when 8
247
271
  inner_state = 0
248
272
  while !(token[@i].attribute == "EQUALS_TO") and @i < token.size
@@ -290,6 +314,11 @@ class Sizer
290
314
  end
291
315
 
292
316
  private
317
+
318
+ # checks if the input expression has balanced brackets
319
+ #
320
+ # * **argument**: expression (string) to check
321
+ # * **returns**: +true+ if brackets are balanced; +false+ else
293
322
  def balanced_brackets?(exp)
294
323
  open_b = 0
295
324
  for i in 0...exp.size
@@ -299,6 +328,10 @@ class Sizer
299
328
  open_b == 0 ? (return true) : (return false)
300
329
  end
301
330
 
331
+ # Checks the sintax of a block, that is: QUOTES-STRING-QUOTES
332
+ #
333
+ # * **argument**: stream of tokens
334
+ # * **returns**: +true+ if the sintax is correct; +false+ else
302
335
  def check_block(token)
303
336
  unless token[@i].attribute == "QUOTES" then
304
337
  PrintError.missmatch(token[@i],@@string,"quotes for block")
@@ -3,12 +3,28 @@
3
3
  require_relative 'CnGal_tools.rb'
4
4
  require_relative 'CnGal_new_classes.rb'
5
5
 
6
+ ##
7
+ # This class generates a token object with three parameters:
8
+ # * Attribute
9
+ # * Position
10
+ # * Value
11
+ #
12
+ #
13
+ # Author:: Massimiliano Dal Mas (mailto:max.codeware@gmail.com)
14
+ # License:: Distributed under MIT license
6
15
  class Token
16
+
7
17
  OPERATORS = Tool.operators
8
18
  VARIABLE = /[a-zA-Z_][a-zA-Z0-9_]*/
19
+
20
+ # Creates a new token object
21
+ #
22
+ # * **argument**: token value to name
23
+ # * **argument**: token position
24
+ # * **argument**: 'suggestion' (string) to force a specific attribute. "" default
9
25
  def initialize(to_token,pos,sugg = "")
10
26
  @My_pos = pos
11
- if OPERATORS.include? to_token then
27
+ if OPERATORS.include? to_token then
12
28
  @My_att = "OPERATOR" unless [">","=","+","-"].include? to_token
13
29
  @My_att = "EQUAL_OP" if to_token == "="
14
30
  @My_att = "TO_FILE_OP" if to_token == ">"
@@ -35,19 +51,22 @@ class Token
35
51
  @My_self = (to_token.include? ':') ? (to_token.downcase) : (to_token)
36
52
  end
37
53
 
54
+ # * **returns**: token attribute
38
55
  def attribute
39
56
  return @My_att
40
57
  end
41
58
 
59
+ # * **returns**: token position
42
60
  def position
43
61
  return @My_pos
44
62
  end
45
63
 
64
+ # * **returns**: token value
46
65
  def me
47
66
  return @My_self
48
67
  end
49
68
 
50
- def show
51
- return [@My_att,@My_pos,@My_self]
52
- end
69
+ # def to_s
70
+ # return [@My_att,@My_pos,@My_self]
71
+ # end
53
72
  end
@@ -0,0 +1,3 @@
1
+ module Linmeric
2
+ VERSION = "0.2.0"
3
+ end
data/lib/linmeric.rb CHANGED
@@ -1,10 +1,12 @@
1
1
  #! /usr/bin/env ruby
2
2
 
3
- require "linmeric/CnGal_new_classes.rb"
4
- require "linmeric/CnGal_tools.rb"
5
- require "linmeric/CnGal_Matrix_class.rb"
6
- require "linmeric/Parser.rb"
7
- require "linmeric/Scopify.rb"
8
- require "linmeric/Listener.rb"
9
- require "linmeric/Sizer.rb"
10
- require "linmeric/LU.rb"
3
+ %w|linmeric/Archive.rb linmeric/Calculator.rb
4
+ linmeric/CnGal_Matrix_class.rb linmeric/CnGal_new_classes.rb
5
+ linmeric/CnGal_tools.rb linmeric/Error_print.rb
6
+ linmeric/Function_class.rb linmeric/Integrators.rb
7
+ linmeric/Lexer.rb linmeric/Listener.rb linmeric/LU.rb
8
+ linmeric/Parser.rb linmeric/Scopify.rb linmeric/Sizer.rb
9
+ linmeric/Token.rb|.each do |f|
10
+ require_relative f
11
+ end
12
+
@@ -0,0 +1,12 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ %w|linmeric/CnGal_new_classes.rb
4
+ linmeric/CnGal_tools.rb
5
+ linmeric/CnGal_Matrix_class.rb
6
+ linmeric/Parser.rb
7
+ linmeric/Scopify.rb
8
+ linmeric/Listener.rb
9
+ linmeric/Sizer.rb
10
+ linmeric/LU.rb|.each do |f|
11
+ require_relative f
12
+ end
metadata CHANGED
@@ -1,41 +1,142 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linmeric
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Massimiliano Dal Mas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-02 00:00:00.000000000 Z
12
- dependencies: []
13
- description: Simple calculator to make operations on matrices and functions
14
- email: max.codeware@gmail.com
11
+ date: 2017-08-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Simple command line calculator to make operations on matrices and functions
42
+ email:
43
+ - max.codeware@gmail.com
15
44
  executables:
16
45
  - linmeric
46
+ - linguide
17
47
  extensions: []
18
48
  extra_rdoc_files:
19
- - doc/Instructions_it.txt
20
- - doc/Instructions_en.txt
21
- - doc/Instructions_it.html
22
- - doc/Instructions_en.html
23
- - doc/README_en.txt
24
- - doc/README_it.txt
25
- - doc/README_en.html
26
- - doc/README_it.html
49
+ - README.md
50
+ - Gemfile
51
+ - Rakefile
52
+ - LICENSE.txt
27
53
  files:
54
+ - Gemfile
55
+ - LICENSE.txt
56
+ - README.md
57
+ - Rakefile
58
+ - bin/help/Help.rb
59
+ - bin/help/Help_inst.rb
60
+ - bin/linguide
28
61
  - bin/linmeric
29
- - doc/Instructions_en.html
62
+ - doc/Archive.html
63
+ - doc/Calculator.html
64
+ - doc/Calculator/Evaluator.html
65
+ - doc/Calculator/Lexer.html
66
+ - doc/Calculator/Token.html
67
+ - doc/Dim.html
68
+ - doc/Filename.html
69
+ - doc/Fixnum.html
70
+ - doc/Float.html
71
+ - doc/Function.html
72
+ - doc/InputError.html
30
73
  - doc/Instructions_en.txt
31
- - doc/Instructions_it.html
32
74
  - doc/Instructions_it.txt
33
- - doc/README_en.html
34
- - doc/README_en.txt
35
- - doc/README_it.html
36
- - doc/README_it.txt
75
+ - doc/Integrators.html
76
+ - doc/LU.html
77
+ - doc/Lexer.html
78
+ - doc/Linmeric.html
79
+ - doc/Listener.html
80
+ - doc/Matrix.html
81
+ - doc/MyArgError.html
82
+ - doc/NilClass.html
83
+ - doc/Numeric.html
84
+ - doc/Parser.html
85
+ - doc/PrintError.html
86
+ - doc/README_md.html
87
+ - doc/Scp.html
88
+ - doc/Sizer.html
89
+ - doc/String.html
90
+ - doc/Token.html
91
+ - doc/Tool.html
92
+ - doc/created.rid
93
+ - doc/css/fonts.css
94
+ - doc/css/rdoc.css
95
+ - doc/fonts/Lato-Light.ttf
96
+ - doc/fonts/Lato-LightItalic.ttf
97
+ - doc/fonts/Lato-Regular.ttf
98
+ - doc/fonts/Lato-RegularItalic.ttf
99
+ - doc/fonts/SourceCodePro-Bold.ttf
100
+ - doc/fonts/SourceCodePro-Regular.ttf
101
+ - doc/images/add.png
102
+ - doc/images/arrow_up.png
103
+ - doc/images/brick.png
104
+ - doc/images/brick_link.png
105
+ - doc/images/bug.png
106
+ - doc/images/bullet_black.png
107
+ - doc/images/bullet_toggle_minus.png
108
+ - doc/images/bullet_toggle_plus.png
109
+ - doc/images/date.png
110
+ - doc/images/delete.png
111
+ - doc/images/find.png
112
+ - doc/images/loadingAnimation.gif
113
+ - doc/images/macFFBgHack.png
114
+ - doc/images/package.png
115
+ - doc/images/page_green.png
116
+ - doc/images/page_white_text.png
117
+ - doc/images/page_white_width.png
118
+ - doc/images/plugin.png
119
+ - doc/images/ruby.png
120
+ - doc/images/tag_blue.png
121
+ - doc/images/tag_green.png
122
+ - doc/images/transparent.png
123
+ - doc/images/wrench.png
124
+ - doc/images/wrench_orange.png
125
+ - doc/images/zoom.png
126
+ - doc/index.html
127
+ - doc/js/darkfish.js
128
+ - doc/js/jquery.js
129
+ - doc/js/navigation.js
130
+ - doc/js/navigation.js.gz
131
+ - doc/js/search.js
132
+ - doc/js/search_index.js
133
+ - doc/js/search_index.js.gz
134
+ - doc/js/searcher.js
135
+ - doc/js/searcher.js.gz
136
+ - doc/table_of_contents.html
37
137
  - lib/linmeric.rb
38
138
  - lib/linmeric/Archive.rb
139
+ - lib/linmeric/Calculator.rb
39
140
  - lib/linmeric/CnGal_Matrix_class.rb
40
141
  - lib/linmeric/CnGal_new_classes.rb
41
142
  - lib/linmeric/CnGal_tools.rb
@@ -49,10 +150,13 @@ files:
49
150
  - lib/linmeric/Scopify.rb
50
151
  - lib/linmeric/Sizer.rb
51
152
  - lib/linmeric/Token.rb
52
- homepage: http://rubygems.org/gems/linmeric
153
+ - lib/linmeric/version.rb
154
+ - lib/linmeric_bin.rb
155
+ homepage: https://max-codeware.github.io/linmeric/
53
156
  licenses:
54
157
  - MIT
55
- metadata: {}
158
+ metadata:
159
+ allowed_push_host: https://rubygems.org
56
160
  post_install_message:
57
161
  rdoc_options: []
58
162
  require_paths:
@@ -72,5 +176,5 @@ rubyforge_project:
72
176
  rubygems_version: 2.4.5.2
73
177
  signing_key:
74
178
  specification_version: 4
75
- summary: Numeric calculator
179
+ summary: Simple numeric calculator
76
180
  test_files: []