EFL 1.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/EFL.rb CHANGED
@@ -212,12 +212,13 @@ class Generator
212
212
  delta_length = 0
213
213
  result_str = source_str.dup
214
214
  replace_list.each { |rep|
215
+ text_without_the_quote_problem = @sub_hash[rep[2]].text.gsub(/"/, '\"')
215
216
  str1 = result_str[0, rep[0] + delta_length]
216
217
  str2 = result_str[rep[0] + delta_length, rep[1] - rep[0] +1]
217
218
  str3 = result_str[rep[1] + 1 + delta_length, result_str.length - 1]
218
219
  str2 =~ @sub_hash[rep[2]].reg_exp.zoom_list.last
219
- str = ''
220
- eval("str = " + '"' + @sub_hash[rep[2]].text + '"')
220
+ str = ''
221
+ eval("str = " + '"' + text_without_the_quote_problem + '"')
221
222
  result_str = str1 + str + str3
222
223
  delta_length = result_str.length - source_str.length
223
224
  }
@@ -227,47 +228,54 @@ class Generator
227
228
  def mix_subs(sub_list, i_file) #:nodoc:
228
229
  result = []
229
230
  sub_list.each { |s|
230
- # local substitutions
231
- if /local/ =~ @sub_hash[s].scope then
232
- if /before/ =~ @sub_hash[s].scope then
233
- element = @sub_hash[s].match_hash[i_file][0].dup
234
- element[1] = element[0] - 1
235
- element << s
236
- result << element
237
- elsif /after/ =~ @sub_hash[s].scope then
238
- element = @sub_hash[s].match_hash[i_file][0].dup
239
- element[0] = element[1] + 1
240
- element << s
241
- result << element
242
- else
243
- element = @sub_hash[s].match_hash[i_file][0].dup
244
- element << s
245
- result << element
246
- end
247
- # global substitutions
248
- else
249
- if /before/ =~ @sub_hash[s].scope then
250
- @sub_hash[s].match_hash[i_file].each { |m|
251
- element = m.dup
252
- element[1] = element[0] - 1
253
- element << s
254
- result << element
255
- }
256
- elsif /after/ =~ @sub_hash[s].scope then
257
- @sub_hash[s].match_hash[i_file].each { |m|
258
- element = m.dup
259
- element[0] = element[1] + 1
260
- element << s
261
- result << element
262
- }
263
- else
264
- @sub_hash[s].match_hash[i_file].each { |m|
265
- element = m.dup
266
- element << s
267
- result << element
268
- }
269
- end
270
- end
231
+ begin
232
+
233
+ # local substitutions
234
+ if /local/ =~ @sub_hash[s].scope then
235
+ if /before/ =~ @sub_hash[s].scope then
236
+ element = @sub_hash[s].match_hash[i_file][0].dup
237
+ element[1] = element[0] - 1
238
+ element << s
239
+ result << element
240
+ elsif /after/ =~ @sub_hash[s].scope then
241
+ element = @sub_hash[s].match_hash[i_file][0].dup
242
+ element[0] = element[1] + 1
243
+ element << s
244
+ result << element
245
+ else
246
+ element = @sub_hash[s].match_hash[i_file][0].dup
247
+ element << s
248
+ result << element
249
+ end
250
+
251
+ # global substitutions
252
+ else
253
+ if /before/ =~ @sub_hash[s].scope then
254
+ @sub_hash[s].match_hash[i_file].each { |m|
255
+ element = m.dup
256
+ element[1] = element[0] - 1
257
+ element << s
258
+ result << element
259
+ }
260
+ elsif /after/ =~ @sub_hash[s].scope then
261
+ @sub_hash[s].match_hash[i_file].each { |m|
262
+ element = m.dup
263
+ element[0] = element[1] + 1
264
+ element << s
265
+ result << element
266
+ }
267
+ else
268
+ @sub_hash[s].match_hash[i_file].each { |m|
269
+ element = m.dup
270
+ element << s
271
+ result << element
272
+ }
273
+ end
274
+ end
275
+
276
+ rescue
277
+ Error.unable_to_match(s, @sub_hash[s].reg_exp, i_file)
278
+ end #exception
271
279
  }
272
280
  result.sort! { |e1, e2|
273
281
  if e1[0] == e2[0] then
@@ -40,9 +40,13 @@ module Error #:nodoc: all
40
40
  }
41
41
  <<-CODE
42
42
  if !#{receiver}?(#{c[receiver].at(0).join(', ')})
43
- raise "Collision between #{c[receiver].at(1)}s"
43
+ raise "\nCollision between #{c[receiver].at(1)}s\n"
44
44
  end
45
45
  CODE
46
46
  end #Error.collision
47
+
48
+ def Error.unable_to_match(substitution_name, reg_exp, file)
49
+ raise "\nERROR: No matching for the regular expression <<#{reg_exp}>> of the substitution <<#{substitution_name}>> against the file <<#{file}>>\n"
50
+ end #unable_to_match
47
51
 
48
52
  end #Error
@@ -67,4 +67,3 @@ def inside_nested_symbols(beginSymbol, endSymbol, levels=50)
67
67
  quit_begin_and_end_symbols = /[^#{beginSymbol}].*(?=#{endSymbol})/xm
68
68
  return (nested_symbols(beginSymbol, endSymbol, levels) > quit_begin_and_end_symbols)
69
69
  end #nestedSymbols
70
-
@@ -109,25 +109,25 @@ def get_match_pos(str, reg_exp, scope)
109
109
  # zoom matching
110
110
  ############################
111
111
  reg_exp.zoom_list = [reg_exp.dup] unless reg_exp.zoom_list
112
- pos1 = match_pos(str, reg_exp.zoom_list[0], scope)
113
- pos2, pos3 = [], []
114
- i = 1
115
- while i<reg_exp.zoom_list.length
116
- j = 0
117
- pos1.each {|aux|
118
- pos2 = match_pos(str[aux[0], aux[1]-aux[0]+1], reg_exp.zoom_list[i], scope)
119
- pos2.map! {|e|
120
- e[0] = e[0] + pos1[j][0]
121
- e[1] = e[1] + pos1[j][0]
122
- e
123
- }
124
- pos3 << pos2.dup
125
- j += 1
126
- }
127
- pos1 = format_array(pos3)
128
- pos3 = []
129
- i += 1
130
- end #while
112
+ pos1 = match_pos(str, reg_exp.zoom_list[0], scope)
113
+ pos2, pos3 = [], []
114
+ i = 1
115
+ while i<reg_exp.zoom_list.length
116
+ j = 0
117
+ pos1.each {|aux|
118
+ pos2 = match_pos(str[aux[0], aux[1]-aux[0]+1], reg_exp.zoom_list[i], scope)
119
+ pos2.map! {|e|
120
+ e[0] = e[0] + pos1[j][0]
121
+ e[1] = e[1] + pos1[j][0]
122
+ e
123
+ }
124
+ pos3 << pos2.dup
125
+ j += 1
126
+ }
127
+ pos1 = format_array(pos3)
128
+ pos3 = []
129
+ i += 1
130
+ end #while
131
131
 
132
132
  ############################
133
133
  # minus matching
@@ -166,9 +166,11 @@ def crash?(substitution, i_file)
166
166
  File.open(i_file) { |f| i_string = f.read }
167
167
 
168
168
  self.match_hash[i_file] = get_match_pos(i_string, self.reg_exp, self.scope) unless self.match_hash[i_file]
169
-
169
+ #Error.unable_to_match(self, i_file, self.match_hash[i_file])
170
+
170
171
  substitution.match_hash[i_file] = get_match_pos(i_string, substitution.reg_exp, substitution.scope) unless substitution.match_hash[i_file]
171
-
172
+ #Error.unable_to_match(substitution, i_file, substitution.match_hash[i_file])
173
+
172
174
  crash = false
173
175
 
174
176
  if (/before/ =~ self.scope) or (/after/ =~ self.scope) or
Binary file
Binary file
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: EFL
5
5
  version: !ruby/object:Gem::Version
6
- version: "1.0"
7
- date: 2007-11-16 00:00:00 +01:00
6
+ version: 1.0.1
7
+ date: 2008-02-19 00:00:00 +01:00
8
8
  summary: A Ruby implementation of the Exemplar Flexibilization Language
9
9
  require_paths:
10
10
  - lib
@@ -77,6 +77,7 @@ files:
77
77
  - lib/doc/fr_file_index.html
78
78
  - lib/doc/fr_method_index.html
79
79
  - lib/doc/index.html
80
+ - lib/doc.zip
80
81
  - lib/EFL.rb
81
82
  - lib/EFL_array.rb
82
83
  - lib/EFL_errors.rb
@@ -87,6 +88,7 @@ files:
87
88
  - lib/EFL_substitution.rb
88
89
  - lib/EFL_syntactic_sugar.rb
89
90
  - lib/Hash Doc.doc
91
+ - lib/lib.zip
90
92
  - lib/Limitaciones.txt
91
93
  - tests/Add_Sup_1.rb
92
94
  - tests/Add_Sup_1.rb.bak