rossoc 0.9.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.
@@ -0,0 +1,455 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Original source code
4
+ # sql-parser
5
+ # https://github.com/cryodex/sql-parser
6
+ #
7
+
8
+ module SQLParser
9
+ module Statement
10
+ class Node
11
+ def accept(visitor)
12
+ klass = self.class.ancestors.find do |ancestor|
13
+ visitor.respond_to?("visit_#{demodulize(ancestor.name)}")
14
+ end
15
+
16
+ raise "No visitor for #{self.class.name}" unless klass
17
+
18
+ visitor.__send__("visit_#{demodulize(klass.name)}", self)
19
+ end
20
+
21
+ def to_sql
22
+ SQLVisitor.new.visit(self)
23
+ end
24
+
25
+ private
26
+
27
+ def demodulize(str)
28
+ str.split('::')[-1]
29
+ end
30
+ end
31
+
32
+ class Insert < Node
33
+ def initialize(table_reference, column_list, in_value_list)
34
+ @table_reference = table_reference
35
+ @column_list = column_list
36
+ @in_value_list = in_value_list
37
+ end
38
+
39
+ attr_reader :table_reference, :column_list, :in_value_list
40
+ end
41
+
42
+ class DirectSelect < Node
43
+ def initialize(query_expression, order_by, rsleep = nil, rspeed = nil)
44
+ @query_expression = query_expression
45
+ @order_by = order_by
46
+ @rsleep = rsleep
47
+ @rspeed = rspeed
48
+ end
49
+
50
+ attr_reader :query_expression, :order_by, :rsleep, :rspeed
51
+ end
52
+
53
+ class OrderBy < Node
54
+ def initialize(sort_specification)
55
+ @sort_specification = Array(sort_specification)
56
+ end
57
+
58
+ attr_reader :sort_specification
59
+ end
60
+
61
+ class Rsleep < Node
62
+ def initialize(rsleep_specification)
63
+ @rsleep_specification = rsleep_specification
64
+ end
65
+
66
+ attr_reader :rsleep_specification
67
+ end
68
+
69
+ class Rspeed < Node
70
+ def initialize(rspeed_specification)
71
+ @rspeed_specification = rspeed_specification
72
+ end
73
+
74
+ attr_reader :rspeed_specification
75
+ end
76
+
77
+ class Subquery < Node
78
+ def initialize(query_specification)
79
+ @query_specification = query_specification
80
+ end
81
+
82
+ attr_reader :query_specification
83
+ end
84
+
85
+ class Select < Node
86
+ def initialize(list, table_expression = nil)
87
+ @list = list
88
+ @table_expression = table_expression
89
+ end
90
+
91
+ attr_reader :list, :table_expression
92
+ end
93
+
94
+ class SelectList < Node
95
+ def initialize(columns)
96
+ @columns = Array(columns)
97
+ end
98
+
99
+ attr_reader :columns
100
+ end
101
+
102
+ class Distinct < Node
103
+ def initialize(column)
104
+ @column = column
105
+ end
106
+
107
+ attr_reader :column
108
+ end
109
+
110
+ class All < Node
111
+ end
112
+
113
+ class TableExpression < Node
114
+ def initialize(from_clause, where_clause = nil, group_by_clause = nil, having_clause = nil)
115
+ @from_clause = from_clause
116
+ @where_clause = where_clause
117
+ @group_by_clause = group_by_clause
118
+ @having_clause = having_clause
119
+ end
120
+
121
+ attr_reader :from_clause, :where_clause, :group_by_clause, :having_clause
122
+ end
123
+
124
+ class FromClause < Node
125
+ def initialize(tables)
126
+ @tables = Array(tables)
127
+ end
128
+
129
+ attr_reader :tables
130
+ end
131
+
132
+ class OrderClause < Node
133
+ def initialize(columns)
134
+ @columns = Array(columns)
135
+ end
136
+
137
+ attr_reader :columns
138
+ end
139
+
140
+ class OrderSpecification < Node
141
+ def initialize(column)
142
+ @column = column
143
+ end
144
+
145
+ attr_reader :column
146
+ end
147
+
148
+ class Ascending < OrderSpecification
149
+ end
150
+
151
+ class Descending < OrderSpecification
152
+ end
153
+
154
+ class HavingClause < Node
155
+ def initialize(search_condition)
156
+ @search_condition = search_condition
157
+ end
158
+
159
+ attr_reader :search_condition
160
+ end
161
+
162
+ class GroupByClause < Node
163
+ def initialize(columns)
164
+ @columns = Array(columns)
165
+ end
166
+
167
+ attr_reader :columns
168
+ end
169
+
170
+ class WhereClause < Node
171
+ def initialize(search_condition)
172
+ @search_condition = search_condition
173
+ end
174
+
175
+ attr_reader :search_condition
176
+ end
177
+
178
+ class On < Node
179
+ def initialize(search_condition)
180
+ @search_condition = search_condition
181
+ end
182
+
183
+ attr_reader :search_condition
184
+ end
185
+
186
+ class SearchCondition < Node
187
+ def initialize(left, right)
188
+ @left = left
189
+ @right = right
190
+ end
191
+
192
+ attr_reader :left, :right
193
+ end
194
+
195
+ class Using < Node
196
+ def initialize(columns)
197
+ @columns = Array(columns)
198
+ end
199
+
200
+ attr_reader :columns
201
+ end
202
+
203
+ class Or < SearchCondition
204
+ end
205
+
206
+ class And < SearchCondition
207
+ end
208
+
209
+ class Exists < Node
210
+ def initialize(table_subquery)
211
+ @table_subquery = table_subquery
212
+ end
213
+
214
+ attr_reader :table_subquery
215
+ end
216
+
217
+ class ComparisonPredicate < Node
218
+ def initialize(left, right)
219
+ @left = left
220
+ @right = right
221
+ end
222
+
223
+ attr_reader :left, :right
224
+ end
225
+
226
+ class Is < ComparisonPredicate
227
+ end
228
+
229
+ class Like < ComparisonPredicate
230
+ end
231
+
232
+ class In < ComparisonPredicate
233
+ end
234
+
235
+ class InValueList < Node
236
+ def initialize(values)
237
+ @values = values
238
+ end
239
+
240
+ attr_reader :values
241
+ end
242
+
243
+ class InColumnList < Node
244
+ def initialize(columns)
245
+ @columns = columns
246
+ end
247
+
248
+ attr_reader :columns
249
+ end
250
+
251
+ class Between < Node
252
+ def initialize(left, min, max)
253
+ @left = left
254
+ @min = min
255
+ @max = max
256
+ end
257
+
258
+ attr_reader :left, :min, :max
259
+ end
260
+
261
+ class GreaterOrEquals < ComparisonPredicate
262
+ end
263
+
264
+ class LessOrEquals < ComparisonPredicate
265
+ end
266
+
267
+ class Greater < ComparisonPredicate
268
+ end
269
+
270
+ class Less < ComparisonPredicate
271
+ end
272
+
273
+ class Equals < ComparisonPredicate
274
+ end
275
+
276
+ class Aggregate < Node
277
+ def initialize(column)
278
+ @column = column
279
+ end
280
+
281
+ attr_reader :column
282
+ end
283
+
284
+ class Sum < Aggregate
285
+ end
286
+
287
+ class Minimum < Aggregate
288
+ end
289
+
290
+ class Maximum < Aggregate
291
+ end
292
+
293
+ class Average < Aggregate
294
+ end
295
+
296
+ class Count < Aggregate
297
+ end
298
+
299
+ class JoinedTable < Node
300
+ def initialize(left, right)
301
+ @left = left
302
+ @right = right
303
+ end
304
+
305
+ attr_reader :left, :right
306
+ end
307
+
308
+ class CrossJoin < JoinedTable
309
+ end
310
+
311
+ class QualifiedJoin < JoinedTable
312
+ def initialize(left, right, search_condition)
313
+ super(left, right)
314
+ @search_condition = search_condition
315
+ end
316
+
317
+ attr_reader :search_condition
318
+ end
319
+
320
+ class InnerJoin < QualifiedJoin
321
+ end
322
+
323
+ class LeftJoin < QualifiedJoin
324
+ end
325
+
326
+ class LeftOuterJoin < QualifiedJoin
327
+ end
328
+
329
+ class RightJoin < QualifiedJoin
330
+ end
331
+
332
+ class RightOuterJoin < QualifiedJoin
333
+ end
334
+
335
+ class FullJoin < QualifiedJoin
336
+ end
337
+
338
+ class FullOuterJoin < QualifiedJoin
339
+ end
340
+
341
+ class QualifiedColumn < Node
342
+ def initialize(table, column)
343
+ @table = table
344
+ @column = column
345
+ end
346
+
347
+ attr_reader :table, :column
348
+ end
349
+
350
+ class Identifier < Node
351
+ def initialize(name)
352
+ @name = name
353
+ end
354
+
355
+ attr_reader :name
356
+ end
357
+
358
+ class Table < Identifier
359
+ end
360
+
361
+ class Column < Identifier
362
+ end
363
+
364
+ class As < Node
365
+ def initialize(value, column)
366
+ @value = value
367
+ @column = column
368
+ end
369
+
370
+ attr_reader :value, :column
371
+ end
372
+
373
+ class Arithmetic < Node
374
+ def initialize(left, right)
375
+ @left = left
376
+ @right = right
377
+ end
378
+
379
+ attr_reader :left, :right
380
+ end
381
+
382
+ class Multiply < Arithmetic
383
+ end
384
+
385
+ class Divide < Arithmetic
386
+ end
387
+
388
+ class Add < Arithmetic
389
+ end
390
+
391
+ class Subtract < Arithmetic
392
+ end
393
+
394
+ class Unary < Node
395
+ def initialize(value)
396
+ @value = value
397
+ end
398
+
399
+ attr_reader :value
400
+ end
401
+
402
+ class Not < Unary
403
+ end
404
+
405
+ class UnaryPlus < Unary
406
+ end
407
+
408
+ class UnaryMinus < Unary
409
+ end
410
+
411
+ class CurrentUser < Node
412
+ end
413
+
414
+ class True < Node
415
+ end
416
+
417
+ class False < Node
418
+ end
419
+
420
+ class Null < Node
421
+ end
422
+
423
+ class Literal < Node
424
+ def initialize(value)
425
+ @value = value
426
+ end
427
+
428
+ attr_reader :value
429
+ end
430
+
431
+ class DateTime < Literal
432
+ end
433
+
434
+ class Date < Literal
435
+ end
436
+
437
+ class String < Literal
438
+ end
439
+
440
+ class ApproximateFloat < Node
441
+ def initialize(mantissa, exponent)
442
+ @mantissa = mantissa
443
+ @exponent = exponent
444
+ end
445
+
446
+ attr_reader :mantissa, :exponent
447
+ end
448
+
449
+ class Float < Literal
450
+ end
451
+
452
+ class Integer < Literal
453
+ end
454
+ end
455
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rossoc
4
+ VERSION = '0.9.0'
5
+ end
@@ -0,0 +1,41 @@
1
+ // <%= ast.to_sql %>
2
+
3
+ void setup() {
4
+ Serial.begin(<%= speed %>);
5
+ <%
6
+ din_pins.each do |pin| %>
7
+ pinMode(<%= pin %>, INPUT);<%
8
+ end
9
+ %>
10
+ }
11
+
12
+ void loop() {
13
+ <%
14
+ din_pins.each do |pin| %>
15
+ int din<%= pin %> = digitalRead(<%= pin %>);<%
16
+ end
17
+ %>
18
+ <%
19
+ ain_pins.each do |pin| %>
20
+ int ain<%= pin %> = analogRead(<%= pin %>);<%
21
+ end
22
+ %>
23
+
24
+ if(<%= where %>) {
25
+ <%
26
+ dout_pins.each do |pin| %>
27
+ Serial.print("din<%= pin %>=");
28
+ Serial.println(din<%= pin %>);<%
29
+ end
30
+ %>
31
+ <%
32
+ aout_pins.each do |pin| %>
33
+ Serial.print("ain<%= pin %>=");
34
+ Serial.println(ain<%= pin %>);<%
35
+ end
36
+ %>
37
+ }
38
+ <% if sleep.positive? %>
39
+ delay(<%= sleep.millisecond %>);
40
+ <% end%>
41
+ }
@@ -0,0 +1,32 @@
1
+ # <%= ast.to_sql %>
2
+
3
+ while 1 do
4
+ <%
5
+ din_pins.each do |pin| %>
6
+ din<%= pin %> = rand(0..1)<%
7
+ end
8
+ %>
9
+
10
+ <%
11
+ ain_pins.each do |pin| %>
12
+ ain<%= pin %> = rand(0..1023)<%
13
+ end
14
+ %>
15
+
16
+ if <%= where %>
17
+ <%
18
+ dout_pins.each do |pin| %>
19
+ puts("din<%= pin %>=#{din<%= pin %>}")<%
20
+ end
21
+ %>
22
+ <%
23
+ aout_pins.each do |pin| %>
24
+ puts("ain<%= pin %>=#{ain<%= pin %>}")<%
25
+ end
26
+ %>
27
+ end
28
+
29
+ <% if sleep.positive? %>
30
+ sleep(<%= sleep.second() %>)
31
+ <% end%>
32
+ end
@@ -0,0 +1,44 @@
1
+ # <%= ast.to_sql %>
2
+ <%
3
+ din_pins.each do |pin| %>
4
+ GPIO.setmode(<%= pin %>, GPIO::IN)<%
5
+ end
6
+ %>
7
+ <%
8
+ ain_pins.each do |pin| %>
9
+ k_ain<%= pin%> = ADC.new(<%= pin%>)<%
10
+ end
11
+ %>
12
+
13
+ uart1 = UART.new(1)
14
+
15
+ while 1 do
16
+ <%
17
+ din_pins.each do |pin| %>
18
+ din<%= pin %> = GPIO.read(<%= pin %>)<%
19
+ end
20
+ %>
21
+
22
+ <%
23
+ ain_pins.each do |pin| %>
24
+ ain<%= pin %> = k_ain<%= pin %>.read_voltage()<%
25
+ end
26
+ %>
27
+
28
+ if <%= where %>
29
+ <%
30
+ dout_pins.each do |pin| %>
31
+ uart1.puts("din<%= pin %>=#{din<%= pin %>}")<%
32
+ end
33
+ %>
34
+ <%
35
+ aout_pins.each do |pin| %>
36
+ uart1.puts("ain<%= pin %>=#{ain<%= pin %>}")<%
37
+ end
38
+ %>
39
+ end
40
+
41
+ <% if sleep.positive? %>
42
+ sleep(<%= sleep.second() %>)
43
+ <% end%>
44
+ end
data/lib/rossoc.rb ADDED
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'rossoc/version'
4
+ require 'strscan'
5
+ require 'date'
6
+ require 'racc/parser'
7
+ require_relative 'rossoc/statement'
8
+ require_relative 'rossoc/sql_visitor'
9
+ require_relative 'rossoc/parser.racc'
10
+ require 'rossoc/cli'
11
+ require 'rossoc/frontend'
12
+ require 'rossoc/backend'
13
+ require 'rossoc/ir'
14
+ require 'active_support/all'
15
+ require 'erb'
16
+ require 'set'
17
+
18
+ module Rossoc
19
+ class Error < StandardError; end
20
+ # Your code goes here...
21
+ end
data/sig/rossoc.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Rossoc
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end