excel_to_code 0.2.15 → 0.2.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/excel_to_c +4 -0
- data/src/commands/excel_to_c.rb +2 -2
- data/src/commands/excel_to_x.rb +25 -6
- data/src/compile/c/a.out +0 -0
- data/src/compile/c/compile_to_c.rb +6 -0
- data/src/compile/c/excel_to_c_runtime.c +131 -8
- data/src/compile/c/excel_to_c_runtime_test.c +475 -434
- data/src/compile/c/map_formulae_to_c.rb +4 -0
- data/src/compile/c/map_values_to_c.rb +4 -0
- data/src/compile/ruby/map_formulae_to_ruby.rb +7 -1
- data/src/compile/ruby/map_values_to_ruby.rb +4 -0
- data/src/excel/area.rb +6 -1
- data/src/excel/excel_functions.rb +2 -0
- data/src/excel/excel_functions/ensure_is_number.rb +7 -0
- data/src/excel/excel_functions/excel_if.rb +1 -0
- data/src/excel/excel_functions/left.rb +1 -0
- data/src/excel/excel_functions/right.rb +2 -1
- data/src/excel/formula_peg.rb +2 -2
- data/src/excel/formula_peg.txt +2 -2
- data/src/excel/reference.rb +1 -0
- data/src/excel_to_code.rb +1 -1
- data/src/extract/extract_data_from_worksheet.rb +4 -0
- data/src/simplify/inline_formulae.rb +3 -1
- data/src/simplify/map_formulae_to_values.rb +52 -17
- data/src/simplify/replace_arithmetic_on_ranges.rb +51 -2
- data/src/simplify/replace_arrays_with_single_cells.rb +60 -4
- data/src/simplify/replace_ranges_with_array_literals.rb +2 -2
- data/src/simplify/simplify_arithmetic.rb +3 -8
- metadata +3 -2
@@ -53,8 +53,8 @@ class ReplaceRangesWithArrayLiteralsAst
|
|
53
53
|
check_range, criteria, sum_range = ast[2], ast[3], ast[4]
|
54
54
|
return map_args(ast) unless [:area, :sheet_reference, :cell].include?(check_range.first)
|
55
55
|
return map_args(ast) unless [:area, :sheet_reference, :cell].include?(sum_range.first)
|
56
|
-
check_area = area_for(check_range)
|
57
|
-
sum_area = area_for(sum_range)
|
56
|
+
check_area = area_for(check_range).unfix
|
57
|
+
sum_area = area_for(sum_range).unfix
|
58
58
|
|
59
59
|
check_area.calculate_excel_variables
|
60
60
|
sum_area.calculate_excel_variables
|
@@ -1,11 +1,10 @@
|
|
1
1
|
class SimplifyArithmeticAst
|
2
2
|
|
3
|
-
attr_accessor :map_count
|
4
|
-
|
5
3
|
def map(ast)
|
6
4
|
@brackets_to_remove = []
|
7
5
|
simplify_arithmetic(ast)
|
8
|
-
remove_brackets
|
6
|
+
remove_brackets
|
7
|
+
ast
|
9
8
|
end
|
10
9
|
|
11
10
|
def simplify_arithmetic(ast)
|
@@ -15,15 +14,13 @@ class SimplifyArithmeticAst
|
|
15
14
|
when :arithmetic; arithmetic(ast)
|
16
15
|
when :brackets; @brackets_to_remove << ast
|
17
16
|
end
|
18
|
-
ast
|
19
17
|
end
|
20
18
|
|
21
|
-
def remove_brackets
|
19
|
+
def remove_brackets
|
22
20
|
@brackets_to_remove.uniq.each do |ast|
|
23
21
|
raise NotSupportedException.new("Multiple arguments not supported in brackets #{ast.inspect}") if ast.size > 2
|
24
22
|
ast.replace(ast[1])
|
25
23
|
end
|
26
|
-
ast
|
27
24
|
end
|
28
25
|
|
29
26
|
# This sets the operator precedence
|
@@ -42,8 +39,6 @@ class SimplifyArithmeticAst
|
|
42
39
|
while i = ast.find_index { |a| a[0] == :operator && op.has_key?(a[1])}
|
43
40
|
# Now we need to wrap that operation in its own arithmetic clause
|
44
41
|
old_clause = ast[(i-1)..(i+1)]
|
45
|
-
# Make sure we do any mapping
|
46
|
-
#old_clause.each { |a| map(a) }
|
47
42
|
# Now create a new clause
|
48
43
|
new_clause = [:arithmetic, *old_clause]
|
49
44
|
# And insert it back into the ast
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: excel_to_code
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Counsell, Green on Black Ltd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubypeg
|
@@ -149,6 +149,7 @@ files:
|
|
149
149
|
- src/excel/excel_functions/count.rb
|
150
150
|
- src/excel/excel_functions/counta.rb
|
151
151
|
- src/excel/excel_functions/divide.rb
|
152
|
+
- src/excel/excel_functions/ensure_is_number.rb
|
152
153
|
- src/excel/excel_functions/excel_equal.rb
|
153
154
|
- src/excel/excel_functions/excel_if.rb
|
154
155
|
- src/excel/excel_functions/excel_match.rb
|