csv_plus_plus 0.1.0 → 0.1.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -1
- data/README.md +18 -62
- data/lib/csv_plus_plus/benchmarked_compiler.rb +62 -0
- data/lib/csv_plus_plus/can_define_references.rb +88 -0
- data/lib/csv_plus_plus/can_resolve_references.rb +8 -0
- data/lib/csv_plus_plus/cell.rb +3 -3
- data/lib/csv_plus_plus/cli.rb +24 -7
- data/lib/csv_plus_plus/color.rb +12 -6
- data/lib/csv_plus_plus/compiler.rb +156 -0
- data/lib/csv_plus_plus/data_validation.rb +138 -0
- data/lib/csv_plus_plus/{language → entities}/ast_builder.rb +5 -7
- data/lib/csv_plus_plus/entities/boolean.rb +31 -0
- data/lib/csv_plus_plus/{language → entities}/builtins.rb +2 -4
- data/lib/csv_plus_plus/entities/cell_reference.rb +60 -0
- data/lib/csv_plus_plus/entities/date.rb +30 -0
- data/lib/csv_plus_plus/entities/entity.rb +84 -0
- data/lib/csv_plus_plus/entities/function.rb +33 -0
- data/lib/csv_plus_plus/entities/function_call.rb +35 -0
- data/lib/csv_plus_plus/entities/number.rb +34 -0
- data/lib/csv_plus_plus/entities/runtime_value.rb +26 -0
- data/lib/csv_plus_plus/entities/string.rb +29 -0
- data/lib/csv_plus_plus/entities/variable.rb +25 -0
- data/lib/csv_plus_plus/entities.rb +33 -0
- data/lib/csv_plus_plus/error/error.rb +10 -0
- data/lib/csv_plus_plus/error/formula_syntax_error.rb +36 -0
- data/lib/csv_plus_plus/error/modifier_syntax_error.rb +27 -0
- data/lib/csv_plus_plus/error/modifier_validation_error.rb +49 -0
- data/lib/csv_plus_plus/{language → error}/syntax_error.rb +6 -14
- data/lib/csv_plus_plus/error/writer_error.rb +9 -0
- data/lib/csv_plus_plus/error.rb +9 -2
- data/lib/csv_plus_plus/expand.rb +3 -1
- data/lib/csv_plus_plus/google_api_client.rb +4 -0
- data/lib/csv_plus_plus/lexer/lexer.rb +19 -11
- data/lib/csv_plus_plus/modifier/conditional_formatting.rb +17 -0
- data/lib/csv_plus_plus/modifier.rb +73 -70
- data/lib/csv_plus_plus/options.rb +3 -0
- data/lib/csv_plus_plus/parser/cell_value.tab.rb +305 -0
- data/lib/csv_plus_plus/parser/code_section.tab.rb +410 -0
- data/lib/csv_plus_plus/parser/modifier.tab.rb +484 -0
- data/lib/csv_plus_plus/references.rb +68 -0
- data/lib/csv_plus_plus/row.rb +0 -3
- data/lib/csv_plus_plus/runtime.rb +199 -0
- data/lib/csv_plus_plus/scope.rb +196 -0
- data/lib/csv_plus_plus/template.rb +21 -5
- data/lib/csv_plus_plus/validated_modifier.rb +164 -0
- data/lib/csv_plus_plus/version.rb +1 -1
- data/lib/csv_plus_plus/writer/file_backer_upper.rb +6 -4
- data/lib/csv_plus_plus/writer/google_sheet_builder.rb +24 -29
- data/lib/csv_plus_plus/writer/google_sheet_modifier.rb +33 -12
- data/lib/csv_plus_plus/writer/rubyxl_builder.rb +3 -6
- data/lib/csv_plus_plus.rb +41 -16
- metadata +34 -24
- data/lib/csv_plus_plus/code_section.rb +0 -68
- data/lib/csv_plus_plus/language/benchmarked_compiler.rb +0 -65
- data/lib/csv_plus_plus/language/cell_value.tab.rb +0 -332
- data/lib/csv_plus_plus/language/code_section.tab.rb +0 -442
- data/lib/csv_plus_plus/language/compiler.rb +0 -157
- data/lib/csv_plus_plus/language/entities/boolean.rb +0 -33
- data/lib/csv_plus_plus/language/entities/cell_reference.rb +0 -33
- data/lib/csv_plus_plus/language/entities/entity.rb +0 -86
- data/lib/csv_plus_plus/language/entities/function.rb +0 -35
- data/lib/csv_plus_plus/language/entities/function_call.rb +0 -26
- data/lib/csv_plus_plus/language/entities/number.rb +0 -36
- data/lib/csv_plus_plus/language/entities/runtime_value.rb +0 -28
- data/lib/csv_plus_plus/language/entities/string.rb +0 -31
- data/lib/csv_plus_plus/language/entities/variable.rb +0 -25
- data/lib/csv_plus_plus/language/entities.rb +0 -28
- data/lib/csv_plus_plus/language/references.rb +0 -70
- data/lib/csv_plus_plus/language/runtime.rb +0 -205
- data/lib/csv_plus_plus/language/scope.rb +0 -188
- data/lib/csv_plus_plus/modifier.tab.rb +0 -907
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
#
|
|
2
|
+
# DO NOT MODIFY!!!!
|
|
3
|
+
# This file is automatically generated by Racc 1.6.2
|
|
4
|
+
# from Racc grammar file "".
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
require 'racc/parser.rb'
|
|
8
|
+
|
|
9
|
+
require_relative '../lexer'
|
|
10
|
+
require_relative '../entities/ast_builder'
|
|
11
|
+
|
|
12
|
+
module CSVPlusPlus
|
|
13
|
+
module Parser
|
|
14
|
+
class CellValue < Racc::Parser
|
|
15
|
+
|
|
16
|
+
module_eval(<<'...end cell_value.y/module_eval...', 'cell_value.y', 49)
|
|
17
|
+
include ::CSVPlusPlus::Entities::ASTBuilder
|
|
18
|
+
include ::CSVPlusPlus::Lexer
|
|
19
|
+
|
|
20
|
+
protected
|
|
21
|
+
|
|
22
|
+
def anything_to_parse?(input)
|
|
23
|
+
input.strip.start_with?('=')
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def parse_subject
|
|
27
|
+
'cell value'
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def return_value
|
|
31
|
+
@ast
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def tokenizer
|
|
35
|
+
::CSVPlusPlus::Lexer::Tokenizer.new(
|
|
36
|
+
catchall: /[\{\}\(\),=]/,
|
|
37
|
+
ignore: /\s+/,
|
|
38
|
+
tokens: [
|
|
39
|
+
TOKEN_LIBRARY[:TRUE],
|
|
40
|
+
TOKEN_LIBRARY[:FALSE],
|
|
41
|
+
TOKEN_LIBRARY[:NUMBER],
|
|
42
|
+
TOKEN_LIBRARY[:STRING],
|
|
43
|
+
TOKEN_LIBRARY[:INFIX_OP],
|
|
44
|
+
TOKEN_LIBRARY[:VAR_REF],
|
|
45
|
+
TOKEN_LIBRARY[:ID]
|
|
46
|
+
]
|
|
47
|
+
)
|
|
48
|
+
end
|
|
49
|
+
...end cell_value.y/module_eval...
|
|
50
|
+
##### State transition tables begin ###
|
|
51
|
+
|
|
52
|
+
racc_action_table = [
|
|
53
|
+
7, 21, 15, 25, 2, 16, 3, 7, 14, 18,
|
|
54
|
+
19, 16, 16, 16, 7, 12, 13, 16, 10, 9,
|
|
55
|
+
11, 8, 12, 13, 26, 10, 9, 11, 8, 12,
|
|
56
|
+
13, nil, 10, 9, 11, 8, 7, 23, nil, nil,
|
|
57
|
+
nil, nil, nil, 7, nil, nil, nil, nil, nil, nil,
|
|
58
|
+
nil, 12, 13, nil, 10, 9, 11, 8, 12, 13,
|
|
59
|
+
nil, 10, 9, 11, 8 ]
|
|
60
|
+
|
|
61
|
+
racc_action_check = [
|
|
62
|
+
2, 17, 4, 22, 0, 4, 1, 7, 3, 8,
|
|
63
|
+
13, 20, 24, 27, 16, 2, 2, 17, 2, 2,
|
|
64
|
+
2, 2, 7, 7, 22, 7, 7, 7, 7, 16,
|
|
65
|
+
16, nil, 16, 16, 16, 16, 19, 19, nil, nil,
|
|
66
|
+
nil, nil, nil, 26, nil, nil, nil, nil, nil, nil,
|
|
67
|
+
nil, 19, 19, nil, 19, 19, 19, 19, 26, 26,
|
|
68
|
+
nil, 26, 26, 26, 26 ]
|
|
69
|
+
|
|
70
|
+
racc_action_pointer = [
|
|
71
|
+
-6, 6, -2, 8, -14, nil, nil, 5, -9, nil,
|
|
72
|
+
nil, nil, nil, 8, nil, nil, 12, -2, nil, 34,
|
|
73
|
+
-8, nil, 0, nil, -7, nil, 41, -6 ]
|
|
74
|
+
|
|
75
|
+
racc_action_default = [
|
|
76
|
+
-16, -16, -16, -16, -16, -2, -3, -16, -16, -6,
|
|
77
|
+
-7, -8, -9, -10, 28, -1, -16, -16, -5, -16,
|
|
78
|
+
-15, -4, -16, -12, -14, -11, -16, -13 ]
|
|
79
|
+
|
|
80
|
+
racc_goto_table = [
|
|
81
|
+
4, 1, 22, nil, nil, 17, nil, nil, nil, nil,
|
|
82
|
+
nil, nil, nil, nil, 20, nil, nil, 24, nil, nil,
|
|
83
|
+
nil, nil, nil, nil, 27 ]
|
|
84
|
+
|
|
85
|
+
racc_goto_check = [
|
|
86
|
+
2, 1, 5, nil, nil, 2, nil, nil, nil, nil,
|
|
87
|
+
nil, nil, nil, nil, 2, nil, nil, 2, nil, nil,
|
|
88
|
+
nil, nil, nil, nil, 2 ]
|
|
89
|
+
|
|
90
|
+
racc_goto_pointer = [
|
|
91
|
+
nil, 1, -2, nil, nil, -17 ]
|
|
92
|
+
|
|
93
|
+
racc_goto_default = [
|
|
94
|
+
nil, nil, nil, 5, 6, nil ]
|
|
95
|
+
|
|
96
|
+
racc_reduce_table = [
|
|
97
|
+
0, 0, :racc_error,
|
|
98
|
+
3, 26, :_reduce_1,
|
|
99
|
+
1, 27, :_reduce_none,
|
|
100
|
+
1, 27, :_reduce_none,
|
|
101
|
+
3, 27, :_reduce_4,
|
|
102
|
+
2, 27, :_reduce_5,
|
|
103
|
+
1, 27, :_reduce_6,
|
|
104
|
+
1, 27, :_reduce_7,
|
|
105
|
+
1, 27, :_reduce_8,
|
|
106
|
+
1, 27, :_reduce_9,
|
|
107
|
+
1, 27, :_reduce_10,
|
|
108
|
+
4, 28, :_reduce_11,
|
|
109
|
+
3, 28, :_reduce_12,
|
|
110
|
+
3, 30, :_reduce_13,
|
|
111
|
+
1, 30, :_reduce_14,
|
|
112
|
+
3, 29, :_reduce_15 ]
|
|
113
|
+
|
|
114
|
+
racc_reduce_n = 16
|
|
115
|
+
|
|
116
|
+
racc_shift_n = 28
|
|
117
|
+
|
|
118
|
+
racc_token_table = {
|
|
119
|
+
false => 0,
|
|
120
|
+
:error => 1,
|
|
121
|
+
"(" => 2,
|
|
122
|
+
")" => 3,
|
|
123
|
+
"^" => 4,
|
|
124
|
+
"*" => 5,
|
|
125
|
+
"/" => 6,
|
|
126
|
+
"+" => 7,
|
|
127
|
+
"-" => 8,
|
|
128
|
+
"&" => 9,
|
|
129
|
+
"=" => 10,
|
|
130
|
+
"<" => 11,
|
|
131
|
+
">" => 12,
|
|
132
|
+
"<=" => 13,
|
|
133
|
+
">=" => 14,
|
|
134
|
+
"<>" => 15,
|
|
135
|
+
:EOL => 16,
|
|
136
|
+
:FALSE => 17,
|
|
137
|
+
:ID => 18,
|
|
138
|
+
:INFIX_OP => 19,
|
|
139
|
+
:NUMBER => 20,
|
|
140
|
+
:STRING => 21,
|
|
141
|
+
:TRUE => 22,
|
|
142
|
+
:VAR_REF => 23,
|
|
143
|
+
"," => 24 }
|
|
144
|
+
|
|
145
|
+
racc_nt_base = 25
|
|
146
|
+
|
|
147
|
+
racc_use_result_var = true
|
|
148
|
+
|
|
149
|
+
Racc_arg = [
|
|
150
|
+
racc_action_table,
|
|
151
|
+
racc_action_check,
|
|
152
|
+
racc_action_default,
|
|
153
|
+
racc_action_pointer,
|
|
154
|
+
racc_goto_table,
|
|
155
|
+
racc_goto_check,
|
|
156
|
+
racc_goto_default,
|
|
157
|
+
racc_goto_pointer,
|
|
158
|
+
racc_nt_base,
|
|
159
|
+
racc_reduce_table,
|
|
160
|
+
racc_token_table,
|
|
161
|
+
racc_shift_n,
|
|
162
|
+
racc_reduce_n,
|
|
163
|
+
racc_use_result_var ]
|
|
164
|
+
|
|
165
|
+
Racc_token_to_s_table = [
|
|
166
|
+
"$end",
|
|
167
|
+
"error",
|
|
168
|
+
"\"(\"",
|
|
169
|
+
"\")\"",
|
|
170
|
+
"\"^\"",
|
|
171
|
+
"\"*\"",
|
|
172
|
+
"\"/\"",
|
|
173
|
+
"\"+\"",
|
|
174
|
+
"\"-\"",
|
|
175
|
+
"\"&\"",
|
|
176
|
+
"\"=\"",
|
|
177
|
+
"\"<\"",
|
|
178
|
+
"\">\"",
|
|
179
|
+
"\"<=\"",
|
|
180
|
+
"\">=\"",
|
|
181
|
+
"\"<>\"",
|
|
182
|
+
"EOL",
|
|
183
|
+
"FALSE",
|
|
184
|
+
"ID",
|
|
185
|
+
"INFIX_OP",
|
|
186
|
+
"NUMBER",
|
|
187
|
+
"STRING",
|
|
188
|
+
"TRUE",
|
|
189
|
+
"VAR_REF",
|
|
190
|
+
"\",\"",
|
|
191
|
+
"$start",
|
|
192
|
+
"cell_value",
|
|
193
|
+
"exp",
|
|
194
|
+
"fn_call",
|
|
195
|
+
"infix_fn_call",
|
|
196
|
+
"fn_call_args" ]
|
|
197
|
+
|
|
198
|
+
Racc_debug_parser = false
|
|
199
|
+
|
|
200
|
+
##### State transition tables end #####
|
|
201
|
+
|
|
202
|
+
# reduce 0 omitted
|
|
203
|
+
|
|
204
|
+
module_eval(<<'.,.,', 'cell_value.y', 21)
|
|
205
|
+
def _reduce_1(val, _values, result)
|
|
206
|
+
@ast = val[1]
|
|
207
|
+
result
|
|
208
|
+
end
|
|
209
|
+
.,.,
|
|
210
|
+
|
|
211
|
+
# reduce 2 omitted
|
|
212
|
+
|
|
213
|
+
# reduce 3 omitted
|
|
214
|
+
|
|
215
|
+
module_eval(<<'.,.,', 'cell_value.y', 25)
|
|
216
|
+
def _reduce_4(val, _values, result)
|
|
217
|
+
result = val[1]
|
|
218
|
+
result
|
|
219
|
+
end
|
|
220
|
+
.,.,
|
|
221
|
+
|
|
222
|
+
module_eval(<<'.,.,', 'cell_value.y', 26)
|
|
223
|
+
def _reduce_5(val, _values, result)
|
|
224
|
+
result = variable(val[1])
|
|
225
|
+
result
|
|
226
|
+
end
|
|
227
|
+
.,.,
|
|
228
|
+
|
|
229
|
+
module_eval(<<'.,.,', 'cell_value.y', 27)
|
|
230
|
+
def _reduce_6(val, _values, result)
|
|
231
|
+
result = string(val[0])
|
|
232
|
+
result
|
|
233
|
+
end
|
|
234
|
+
.,.,
|
|
235
|
+
|
|
236
|
+
module_eval(<<'.,.,', 'cell_value.y', 28)
|
|
237
|
+
def _reduce_7(val, _values, result)
|
|
238
|
+
result = number(val[0])
|
|
239
|
+
result
|
|
240
|
+
end
|
|
241
|
+
.,.,
|
|
242
|
+
|
|
243
|
+
module_eval(<<'.,.,', 'cell_value.y', 29)
|
|
244
|
+
def _reduce_8(val, _values, result)
|
|
245
|
+
result = boolean(true)
|
|
246
|
+
result
|
|
247
|
+
end
|
|
248
|
+
.,.,
|
|
249
|
+
|
|
250
|
+
module_eval(<<'.,.,', 'cell_value.y', 30)
|
|
251
|
+
def _reduce_9(val, _values, result)
|
|
252
|
+
result = boolean(false)
|
|
253
|
+
result
|
|
254
|
+
end
|
|
255
|
+
.,.,
|
|
256
|
+
|
|
257
|
+
module_eval(<<'.,.,', 'cell_value.y', 31)
|
|
258
|
+
def _reduce_10(val, _values, result)
|
|
259
|
+
result = cell_reference(val[0])
|
|
260
|
+
result
|
|
261
|
+
end
|
|
262
|
+
.,.,
|
|
263
|
+
|
|
264
|
+
module_eval(<<'.,.,', 'cell_value.y', 33)
|
|
265
|
+
def _reduce_11(val, _values, result)
|
|
266
|
+
result = function_call(val[0], val[2])
|
|
267
|
+
result
|
|
268
|
+
end
|
|
269
|
+
.,.,
|
|
270
|
+
|
|
271
|
+
module_eval(<<'.,.,', 'cell_value.y', 34)
|
|
272
|
+
def _reduce_12(val, _values, result)
|
|
273
|
+
result = function_call(val[0], [])
|
|
274
|
+
result
|
|
275
|
+
end
|
|
276
|
+
.,.,
|
|
277
|
+
|
|
278
|
+
module_eval(<<'.,.,', 'cell_value.y', 36)
|
|
279
|
+
def _reduce_13(val, _values, result)
|
|
280
|
+
result = val[0] << val[2]
|
|
281
|
+
result
|
|
282
|
+
end
|
|
283
|
+
.,.,
|
|
284
|
+
|
|
285
|
+
module_eval(<<'.,.,', 'cell_value.y', 37)
|
|
286
|
+
def _reduce_14(val, _values, result)
|
|
287
|
+
result = [val[0]]
|
|
288
|
+
result
|
|
289
|
+
end
|
|
290
|
+
.,.,
|
|
291
|
+
|
|
292
|
+
module_eval(<<'.,.,', 'cell_value.y', 39)
|
|
293
|
+
def _reduce_15(val, _values, result)
|
|
294
|
+
result = function_call(val[1], [val[0], val[2]], infix: true)
|
|
295
|
+
result
|
|
296
|
+
end
|
|
297
|
+
.,.,
|
|
298
|
+
|
|
299
|
+
def _reduce_none(val, _values, result)
|
|
300
|
+
val[0]
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
end # class CellValue
|
|
304
|
+
end # module Parser
|
|
305
|
+
end # module CSVPlusPlus
|
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
#
|
|
2
|
+
# DO NOT MODIFY!!!!
|
|
3
|
+
# This file is automatically generated by Racc 1.6.2
|
|
4
|
+
# from Racc grammar file "".
|
|
5
|
+
#
|
|
6
|
+
|
|
7
|
+
require 'racc/parser.rb'
|
|
8
|
+
|
|
9
|
+
require_relative '../lexer'
|
|
10
|
+
require_relative '../entities/ast_builder'
|
|
11
|
+
|
|
12
|
+
module CSVPlusPlus
|
|
13
|
+
module Parser
|
|
14
|
+
class CodeSection < Racc::Parser
|
|
15
|
+
|
|
16
|
+
module_eval(<<'...end code_section.y/module_eval...', 'code_section.y', 69)
|
|
17
|
+
include ::CSVPlusPlus::Lexer
|
|
18
|
+
include ::CSVPlusPlus::Entities::ASTBuilder
|
|
19
|
+
|
|
20
|
+
def initialize(scope)
|
|
21
|
+
super()
|
|
22
|
+
@scope = scope
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
protected
|
|
26
|
+
|
|
27
|
+
def anything_to_parse?(input)
|
|
28
|
+
@rest = input.strip
|
|
29
|
+
|
|
30
|
+
return !@rest.index(::CSVPlusPlus::Lexer::END_OF_CODE_SECTION).nil?
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def parse_subject
|
|
34
|
+
'code section'
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def tokenizer
|
|
38
|
+
::CSVPlusPlus::Lexer::Tokenizer.new(
|
|
39
|
+
catchall: /[\{\}\(\),]/, # TODO: do I even need this (oh I think brackets are for arrays
|
|
40
|
+
ignore: /\s+|\#[^\n]+\n/,
|
|
41
|
+
stop_fn: lambda do |scanner|
|
|
42
|
+
return false unless scanner.scan(/#{::CSVPlusPlus::Lexer::END_OF_CODE_SECTION}/)
|
|
43
|
+
|
|
44
|
+
@tokens << [:END_OF_CODE, scanner.matched]
|
|
45
|
+
@rest = scanner.rest.strip
|
|
46
|
+
true
|
|
47
|
+
end,
|
|
48
|
+
tokens: [
|
|
49
|
+
[/:=/, :ASSIGN],
|
|
50
|
+
[/def/, :FN_DEF],
|
|
51
|
+
TOKEN_LIBRARY[:TRUE],
|
|
52
|
+
TOKEN_LIBRARY[:FALSE],
|
|
53
|
+
TOKEN_LIBRARY[:NUMBER],
|
|
54
|
+
TOKEN_LIBRARY[:STRING],
|
|
55
|
+
TOKEN_LIBRARY[:INFIX_OP],
|
|
56
|
+
TOKEN_LIBRARY[:VAR_REF],
|
|
57
|
+
TOKEN_LIBRARY[:ID]
|
|
58
|
+
],
|
|
59
|
+
)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def return_value
|
|
63
|
+
@rest
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
private
|
|
67
|
+
|
|
68
|
+
def def_function(id, arguments, body)
|
|
69
|
+
fn_def = function(id, arguments, body)
|
|
70
|
+
@scope.def_function(fn_def.id, fn_def)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def def_variable(id, ast)
|
|
74
|
+
@scope.def_variable(id, ast)
|
|
75
|
+
end
|
|
76
|
+
...end code_section.y/module_eval...
|
|
77
|
+
##### State transition tables begin ###
|
|
78
|
+
|
|
79
|
+
racc_action_table = [
|
|
80
|
+
20, 38, 9, 12, 13, 14, 16, 20, 31, 33,
|
|
81
|
+
34, 31, 42, 31, 20, 31, 29, 25, 26, 31,
|
|
82
|
+
23, 22, 24, 21, 25, 26, 20, 23, 22, 24,
|
|
83
|
+
21, 25, 26, 30, 23, 22, 24, 21, 20, 41,
|
|
84
|
+
31, nil, 35, 25, 26, 20, 23, 22, 24, 21,
|
|
85
|
+
3, 10, nil, 7, 7, 25, 26, 36, 23, 22,
|
|
86
|
+
24, 21, 25, 26, 43, 23, 22, 24, 21, 8,
|
|
87
|
+
8, nil, nil, nil, nil, nil, nil, nil, nil, 44 ]
|
|
88
|
+
|
|
89
|
+
racc_action_check = [
|
|
90
|
+
13, 32, 1, 7, 8, 9, 12, 15, 17, 21,
|
|
91
|
+
26, 27, 36, 37, 20, 39, 16, 13, 13, 32,
|
|
92
|
+
13, 13, 13, 13, 15, 15, 31, 15, 15, 15,
|
|
93
|
+
15, 20, 20, 16, 20, 20, 20, 20, 34, 34,
|
|
94
|
+
45, nil, 28, 31, 31, 44, 31, 31, 31, 31,
|
|
95
|
+
0, 2, nil, 0, 2, 34, 34, 28, 34, 34,
|
|
96
|
+
34, 34, 44, 44, 40, 44, 44, 44, 44, 0,
|
|
97
|
+
2, nil, nil, nil, nil, nil, nil, nil, nil, 40 ]
|
|
98
|
+
|
|
99
|
+
racc_action_pointer = [
|
|
100
|
+
48, 2, 49, nil, nil, nil, nil, -18, -2, 5,
|
|
101
|
+
nil, nil, 3, -3, nil, 4, 12, -14, nil, nil,
|
|
102
|
+
11, -12, nil, nil, nil, nil, 7, -11, 38, nil,
|
|
103
|
+
nil, 23, -3, nil, 35, nil, -9, -9, nil, -7,
|
|
104
|
+
60, nil, nil, nil, 42, 18 ]
|
|
105
|
+
|
|
106
|
+
racc_action_default = [
|
|
107
|
+
-27, -27, -27, -2, -4, -5, -6, -27, -27, -27,
|
|
108
|
+
-1, -3, -27, -27, 46, -27, -27, -12, -13, -14,
|
|
109
|
+
-27, -27, -17, -18, -19, -20, -21, -7, -27, -9,
|
|
110
|
+
-11, -27, -27, -16, -27, -8, -27, -22, -15, -26,
|
|
111
|
+
-27, -24, -10, -23, -27, -25 ]
|
|
112
|
+
|
|
113
|
+
racc_goto_table = [
|
|
114
|
+
17, 4, 27, 11, 1, 2, 15, 32, 28, 40,
|
|
115
|
+
nil, nil, nil, nil, nil, nil, nil, nil, 37, nil,
|
|
116
|
+
nil, 39, nil, nil, nil, nil, nil, nil, nil, nil,
|
|
117
|
+
nil, 45 ]
|
|
118
|
+
|
|
119
|
+
racc_goto_check = [
|
|
120
|
+
7, 3, 7, 3, 1, 2, 6, 7, 8, 11,
|
|
121
|
+
nil, nil, nil, nil, nil, nil, nil, nil, 7, nil,
|
|
122
|
+
nil, 7, nil, nil, nil, nil, nil, nil, nil, nil,
|
|
123
|
+
nil, 7 ]
|
|
124
|
+
|
|
125
|
+
racc_goto_pointer = [
|
|
126
|
+
nil, 4, 5, 1, nil, nil, -6, -13, -8, nil,
|
|
127
|
+
nil, -25 ]
|
|
128
|
+
|
|
129
|
+
racc_goto_default = [
|
|
130
|
+
nil, nil, nil, nil, 5, 6, nil, nil, nil, 18,
|
|
131
|
+
19, nil ]
|
|
132
|
+
|
|
133
|
+
racc_reduce_table = [
|
|
134
|
+
0, 0, :racc_error,
|
|
135
|
+
2, 28, :_reduce_none,
|
|
136
|
+
1, 28, :_reduce_none,
|
|
137
|
+
2, 29, :_reduce_none,
|
|
138
|
+
1, 29, :_reduce_none,
|
|
139
|
+
1, 30, :_reduce_none,
|
|
140
|
+
1, 30, :_reduce_none,
|
|
141
|
+
4, 31, :_reduce_7,
|
|
142
|
+
3, 33, :_reduce_8,
|
|
143
|
+
2, 33, :_reduce_9,
|
|
144
|
+
3, 35, :_reduce_10,
|
|
145
|
+
1, 35, :_reduce_11,
|
|
146
|
+
3, 32, :_reduce_12,
|
|
147
|
+
1, 34, :_reduce_none,
|
|
148
|
+
1, 34, :_reduce_none,
|
|
149
|
+
3, 34, :_reduce_15,
|
|
150
|
+
2, 34, :_reduce_16,
|
|
151
|
+
1, 34, :_reduce_17,
|
|
152
|
+
1, 34, :_reduce_18,
|
|
153
|
+
1, 34, :_reduce_19,
|
|
154
|
+
1, 34, :_reduce_20,
|
|
155
|
+
1, 34, :_reduce_21,
|
|
156
|
+
3, 37, :_reduce_22,
|
|
157
|
+
4, 36, :_reduce_23,
|
|
158
|
+
3, 36, :_reduce_24,
|
|
159
|
+
3, 38, :_reduce_25,
|
|
160
|
+
1, 38, :_reduce_26 ]
|
|
161
|
+
|
|
162
|
+
racc_reduce_n = 27
|
|
163
|
+
|
|
164
|
+
racc_shift_n = 46
|
|
165
|
+
|
|
166
|
+
racc_token_table = {
|
|
167
|
+
false => 0,
|
|
168
|
+
:error => 1,
|
|
169
|
+
:END_OF_CODE => 2,
|
|
170
|
+
"(" => 3,
|
|
171
|
+
")" => 4,
|
|
172
|
+
:FN_DEF => 5,
|
|
173
|
+
:ASSIGN => 6,
|
|
174
|
+
"^" => 7,
|
|
175
|
+
"*" => 8,
|
|
176
|
+
"/" => 9,
|
|
177
|
+
"+" => 10,
|
|
178
|
+
"-" => 11,
|
|
179
|
+
"&" => 12,
|
|
180
|
+
"=" => 13,
|
|
181
|
+
"<" => 14,
|
|
182
|
+
">" => 15,
|
|
183
|
+
"<=" => 16,
|
|
184
|
+
">=" => 17,
|
|
185
|
+
"<>" => 18,
|
|
186
|
+
"," => 19,
|
|
187
|
+
:FALSE => 20,
|
|
188
|
+
:ID => 21,
|
|
189
|
+
:INFIX_OP => 22,
|
|
190
|
+
:NUMBER => 23,
|
|
191
|
+
:STRING => 24,
|
|
192
|
+
:TRUE => 25,
|
|
193
|
+
:VAR_REF => 26 }
|
|
194
|
+
|
|
195
|
+
racc_nt_base = 27
|
|
196
|
+
|
|
197
|
+
racc_use_result_var = true
|
|
198
|
+
|
|
199
|
+
Racc_arg = [
|
|
200
|
+
racc_action_table,
|
|
201
|
+
racc_action_check,
|
|
202
|
+
racc_action_default,
|
|
203
|
+
racc_action_pointer,
|
|
204
|
+
racc_goto_table,
|
|
205
|
+
racc_goto_check,
|
|
206
|
+
racc_goto_default,
|
|
207
|
+
racc_goto_pointer,
|
|
208
|
+
racc_nt_base,
|
|
209
|
+
racc_reduce_table,
|
|
210
|
+
racc_token_table,
|
|
211
|
+
racc_shift_n,
|
|
212
|
+
racc_reduce_n,
|
|
213
|
+
racc_use_result_var ]
|
|
214
|
+
|
|
215
|
+
Racc_token_to_s_table = [
|
|
216
|
+
"$end",
|
|
217
|
+
"error",
|
|
218
|
+
"END_OF_CODE",
|
|
219
|
+
"\"(\"",
|
|
220
|
+
"\")\"",
|
|
221
|
+
"FN_DEF",
|
|
222
|
+
"ASSIGN",
|
|
223
|
+
"\"^\"",
|
|
224
|
+
"\"*\"",
|
|
225
|
+
"\"/\"",
|
|
226
|
+
"\"+\"",
|
|
227
|
+
"\"-\"",
|
|
228
|
+
"\"&\"",
|
|
229
|
+
"\"=\"",
|
|
230
|
+
"\"<\"",
|
|
231
|
+
"\">\"",
|
|
232
|
+
"\"<=\"",
|
|
233
|
+
"\">=\"",
|
|
234
|
+
"\"<>\"",
|
|
235
|
+
"\",\"",
|
|
236
|
+
"FALSE",
|
|
237
|
+
"ID",
|
|
238
|
+
"INFIX_OP",
|
|
239
|
+
"NUMBER",
|
|
240
|
+
"STRING",
|
|
241
|
+
"TRUE",
|
|
242
|
+
"VAR_REF",
|
|
243
|
+
"$start",
|
|
244
|
+
"code_section",
|
|
245
|
+
"code",
|
|
246
|
+
"def",
|
|
247
|
+
"fn_def",
|
|
248
|
+
"var_def",
|
|
249
|
+
"fn_def_args_or_not",
|
|
250
|
+
"exp",
|
|
251
|
+
"fn_def_args",
|
|
252
|
+
"fn_call",
|
|
253
|
+
"infix_fn_call",
|
|
254
|
+
"fn_call_args" ]
|
|
255
|
+
|
|
256
|
+
Racc_debug_parser = false
|
|
257
|
+
|
|
258
|
+
##### State transition tables end #####
|
|
259
|
+
|
|
260
|
+
# reduce 0 omitted
|
|
261
|
+
|
|
262
|
+
# reduce 1 omitted
|
|
263
|
+
|
|
264
|
+
# reduce 2 omitted
|
|
265
|
+
|
|
266
|
+
# reduce 3 omitted
|
|
267
|
+
|
|
268
|
+
# reduce 4 omitted
|
|
269
|
+
|
|
270
|
+
# reduce 5 omitted
|
|
271
|
+
|
|
272
|
+
# reduce 6 omitted
|
|
273
|
+
|
|
274
|
+
module_eval(<<'.,.,', 'code_section.y', 33)
|
|
275
|
+
def _reduce_7(val, _values, result)
|
|
276
|
+
def_function(val[1], val[2], val[3])
|
|
277
|
+
result
|
|
278
|
+
end
|
|
279
|
+
.,.,
|
|
280
|
+
|
|
281
|
+
module_eval(<<'.,.,', 'code_section.y', 35)
|
|
282
|
+
def _reduce_8(val, _values, result)
|
|
283
|
+
result = val[1]
|
|
284
|
+
result
|
|
285
|
+
end
|
|
286
|
+
.,.,
|
|
287
|
+
|
|
288
|
+
module_eval(<<'.,.,', 'code_section.y', 36)
|
|
289
|
+
def _reduce_9(val, _values, result)
|
|
290
|
+
result = []
|
|
291
|
+
result
|
|
292
|
+
end
|
|
293
|
+
.,.,
|
|
294
|
+
|
|
295
|
+
module_eval(<<'.,.,', 'code_section.y', 38)
|
|
296
|
+
def _reduce_10(val, _values, result)
|
|
297
|
+
result = val[0] << val[2]
|
|
298
|
+
result
|
|
299
|
+
end
|
|
300
|
+
.,.,
|
|
301
|
+
|
|
302
|
+
module_eval(<<'.,.,', 'code_section.y', 39)
|
|
303
|
+
def _reduce_11(val, _values, result)
|
|
304
|
+
result = [val[0]]
|
|
305
|
+
result
|
|
306
|
+
end
|
|
307
|
+
.,.,
|
|
308
|
+
|
|
309
|
+
module_eval(<<'.,.,', 'code_section.y', 41)
|
|
310
|
+
def _reduce_12(val, _values, result)
|
|
311
|
+
def_variable(val[0], val[2])
|
|
312
|
+
result
|
|
313
|
+
end
|
|
314
|
+
.,.,
|
|
315
|
+
|
|
316
|
+
# reduce 13 omitted
|
|
317
|
+
|
|
318
|
+
# reduce 14 omitted
|
|
319
|
+
|
|
320
|
+
module_eval(<<'.,.,', 'code_section.y', 45)
|
|
321
|
+
def _reduce_15(val, _values, result)
|
|
322
|
+
result = val[1]
|
|
323
|
+
result
|
|
324
|
+
end
|
|
325
|
+
.,.,
|
|
326
|
+
|
|
327
|
+
module_eval(<<'.,.,', 'code_section.y', 46)
|
|
328
|
+
def _reduce_16(val, _values, result)
|
|
329
|
+
result = variable(val[1])
|
|
330
|
+
result
|
|
331
|
+
end
|
|
332
|
+
.,.,
|
|
333
|
+
|
|
334
|
+
module_eval(<<'.,.,', 'code_section.y', 47)
|
|
335
|
+
def _reduce_17(val, _values, result)
|
|
336
|
+
result = string(val[0])
|
|
337
|
+
result
|
|
338
|
+
end
|
|
339
|
+
.,.,
|
|
340
|
+
|
|
341
|
+
module_eval(<<'.,.,', 'code_section.y', 48)
|
|
342
|
+
def _reduce_18(val, _values, result)
|
|
343
|
+
result = number(val[0])
|
|
344
|
+
result
|
|
345
|
+
end
|
|
346
|
+
.,.,
|
|
347
|
+
|
|
348
|
+
module_eval(<<'.,.,', 'code_section.y', 49)
|
|
349
|
+
def _reduce_19(val, _values, result)
|
|
350
|
+
result = boolean(true)
|
|
351
|
+
result
|
|
352
|
+
end
|
|
353
|
+
.,.,
|
|
354
|
+
|
|
355
|
+
module_eval(<<'.,.,', 'code_section.y', 50)
|
|
356
|
+
def _reduce_20(val, _values, result)
|
|
357
|
+
result = boolean(false)
|
|
358
|
+
result
|
|
359
|
+
end
|
|
360
|
+
.,.,
|
|
361
|
+
|
|
362
|
+
module_eval(<<'.,.,', 'code_section.y', 51)
|
|
363
|
+
def _reduce_21(val, _values, result)
|
|
364
|
+
result = cell_reference(val[0])
|
|
365
|
+
result
|
|
366
|
+
end
|
|
367
|
+
.,.,
|
|
368
|
+
|
|
369
|
+
module_eval(<<'.,.,', 'code_section.y', 53)
|
|
370
|
+
def _reduce_22(val, _values, result)
|
|
371
|
+
result = function_call(val[1], [val[0], val[2]], infix: true)
|
|
372
|
+
result
|
|
373
|
+
end
|
|
374
|
+
.,.,
|
|
375
|
+
|
|
376
|
+
module_eval(<<'.,.,', 'code_section.y', 55)
|
|
377
|
+
def _reduce_23(val, _values, result)
|
|
378
|
+
result = function_call(val[0], val[2])
|
|
379
|
+
result
|
|
380
|
+
end
|
|
381
|
+
.,.,
|
|
382
|
+
|
|
383
|
+
module_eval(<<'.,.,', 'code_section.y', 56)
|
|
384
|
+
def _reduce_24(val, _values, result)
|
|
385
|
+
result = function_call(val[0], [])
|
|
386
|
+
result
|
|
387
|
+
end
|
|
388
|
+
.,.,
|
|
389
|
+
|
|
390
|
+
module_eval(<<'.,.,', 'code_section.y', 58)
|
|
391
|
+
def _reduce_25(val, _values, result)
|
|
392
|
+
result = val[0] << val[2]
|
|
393
|
+
result
|
|
394
|
+
end
|
|
395
|
+
.,.,
|
|
396
|
+
|
|
397
|
+
module_eval(<<'.,.,', 'code_section.y', 59)
|
|
398
|
+
def _reduce_26(val, _values, result)
|
|
399
|
+
result = [val[0]]
|
|
400
|
+
result
|
|
401
|
+
end
|
|
402
|
+
.,.,
|
|
403
|
+
|
|
404
|
+
def _reduce_none(val, _values, result)
|
|
405
|
+
val[0]
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
end # class CodeSection
|
|
409
|
+
end # module Parser
|
|
410
|
+
end # module CSVPlusPlus
|