alphalang 0.1.7 → 0.1.8

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
  SHA256:
3
- metadata.gz: 1f69af7ab6e40605d9118d7125caf0c99ea961bd20108210a91d77ea790e0489
4
- data.tar.gz: 0bd9593abf719ba7e5704a873f3d5d14aff15a20d424bcc858e7d9a7e45b22f4
3
+ metadata.gz: a9264317b60fae6805130ff9692189ba73bf08530c025d8a732c0c520b19a466
4
+ data.tar.gz: e7bff4ae6de5fbade8cbc6b0a779ddd06259fad639b3650239fbb5f39d0adff9
5
5
  SHA512:
6
- metadata.gz: 34c909f692a34e3eae601ec4eddcb6361e46480d74a857b277fdbe652d65b2cfa99b6c427661fea5c64720a2122b28e8644f079df2e76b267e53c9bf11c8d26f
7
- data.tar.gz: 0aebab81771209c1f955abd3954e0ba7b9d4c8544fe2d308779d56d19669085b8cb925e6fbdda1cedd3c6b4a7755b95caa17b509bc9f948e85359025aefaf530
6
+ metadata.gz: 9c8f5078f5f91b224847c2c43134e84fb053d3ba6b5eb456104ae7a4f0f267009ee78077fc8e338e1bb5002616d16627491469df240492f045546b20d4a18c5a
7
+ data.tar.gz: daf389f2da9e82cd86a921639b5d8843ef4c45b33ef294d2c93a3281d64dfb0d6674c36f16aac04e76ef2f75c160865554e8325e57bb3c5864462a4739fc9f4f
@@ -37,7 +37,7 @@ class ScopeManager
37
37
  return @@scopes[temp_scope_lvl][name]
38
38
  end
39
39
  end
40
- raise ArgumentError, "Variable '#{name}' is not defined" unless @value
40
+ raise SyntaxError, "Variable '#{name}' is not defined" unless @value
41
41
  end
42
42
 
43
43
  def self.increment_scope_level
@@ -51,7 +51,7 @@ class ScopeManager
51
51
  end
52
52
 
53
53
  def self.lookup_func(name)
54
- raise ArgumentError, "Function '#{name}' is not defined" if @@scopes[0][name].is_a?(NilClass)
54
+ raise SyntaxError, "Function '#{name}' is not defined" if @@scopes[0][name].is_a?(NilClass)
55
55
  return @@scopes[0][name]
56
56
  end
57
57
 
data/lib/rdparse.rb CHANGED
@@ -188,6 +188,9 @@ class Parser
188
188
  end
189
189
 
190
190
  def find_faulty_expression_within_block(block_start_line, block_end_line, problematic_token)
191
+ if block_start_line == nil || block_end_line == nil
192
+ raise ParseError, "Error with <#{problematic_token}> somewhere around line #{block_end_line}#{block_start_line}"
193
+ end
191
194
  index = 0
192
195
  result = []
193
196
  @file_string.each_line do |line|
@@ -212,28 +215,33 @@ class Parser
212
215
  end
213
216
 
214
217
  def find_faulty_line
218
+ if @tokens[@max_pos-0].is_a?(NilClass)
219
+ if @max_pos >= 3
220
+ puts "Problem is in the end of the file after:\n #{@tokens[@max_pos - 3]}#{@tokens[@max_pos - 2]}#{@tokens[@max_pos - 1]}"
221
+ else
222
+ puts "Problem is right in the beginning of the file."
223
+ end
224
+ raise ParseError
225
+ end
226
+
215
227
  problematic_token = "#{@tokens[@max_pos - 1].downcase}"
216
228
  before_problem = "#{@tokens[@max_pos - 2].downcase}"
217
229
  after_problem = "#{@tokens[@max_pos - 0].downcase}"
218
230
 
219
- if @max_pos - 5 <= 0
220
- puts 'problem in the beginning of file, figure it out'
221
- return
222
- elsif @max_pos + 5 < @max_pos
223
- puts 'problem in the end of file, figure it out'
224
- return
225
- end
231
+ after_problem = "[" + after_problem + "]" if !after_problem.match?(/[a-z]/)
232
+ before_problem = "[" + before_problem + "]" if !before_problem.match?(/[a-z]/)
226
233
 
227
234
  translated_problematic_token = @token_list[problematic_token]
228
235
 
229
236
  if translated_problematic_token.is_a?(NilClass)
230
- raise ParseError, "Faulty expression likely between two '#{@token_list['END'.downcase]}' tokens."
237
+ raise ParseError, "Faulty expression likely between two '#{@token_list['end']}' tokens."
231
238
  end
232
239
 
233
240
  index = 0
234
241
  problem_match_hash = {}
235
242
  found_end = false
236
243
  @file_string.each_line do |line|
244
+
237
245
  if line.match?(before_problem) && found_end == false
238
246
  problem_match_hash[before_problem] = index
239
247
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alphalang
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - mattias, victor