piggly-nsd 2.3.3

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.
Files changed (96) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +170 -0
  3. data/Rakefile +33 -0
  4. data/bin/piggly +8 -0
  5. data/lib/piggly/command/base.rb +148 -0
  6. data/lib/piggly/command/report.rb +162 -0
  7. data/lib/piggly/command/trace.rb +90 -0
  8. data/lib/piggly/command/untrace.rb +78 -0
  9. data/lib/piggly/command.rb +8 -0
  10. data/lib/piggly/compiler/cache_dir.rb +119 -0
  11. data/lib/piggly/compiler/coverage_report.rb +63 -0
  12. data/lib/piggly/compiler/trace_compiler.rb +117 -0
  13. data/lib/piggly/compiler.rb +7 -0
  14. data/lib/piggly/config.rb +80 -0
  15. data/lib/piggly/dumper/index.rb +121 -0
  16. data/lib/piggly/dumper/qualified_name.rb +36 -0
  17. data/lib/piggly/dumper/qualified_type.rb +141 -0
  18. data/lib/piggly/dumper/reified_procedure.rb +172 -0
  19. data/lib/piggly/dumper/skeleton_procedure.rb +112 -0
  20. data/lib/piggly/dumper.rb +9 -0
  21. data/lib/piggly/installer.rb +137 -0
  22. data/lib/piggly/parser/grammar.tt +748 -0
  23. data/lib/piggly/parser/nodes.rb +378 -0
  24. data/lib/piggly/parser/traversal.rb +50 -0
  25. data/lib/piggly/parser/treetop_ruby19_patch.rb +21 -0
  26. data/lib/piggly/parser.rb +69 -0
  27. data/lib/piggly/profile.rb +108 -0
  28. data/lib/piggly/reporter/base.rb +106 -0
  29. data/lib/piggly/reporter/html_dsl.rb +63 -0
  30. data/lib/piggly/reporter/index.rb +114 -0
  31. data/lib/piggly/reporter/procedure.rb +129 -0
  32. data/lib/piggly/reporter/resources/highlight.js +38 -0
  33. data/lib/piggly/reporter/resources/piggly.css +515 -0
  34. data/lib/piggly/reporter/resources/sortable.js +493 -0
  35. data/lib/piggly/reporter.rb +8 -0
  36. data/lib/piggly/tags.rb +280 -0
  37. data/lib/piggly/task.rb +215 -0
  38. data/lib/piggly/util/blankslate.rb +114 -0
  39. data/lib/piggly/util/cacheable.rb +19 -0
  40. data/lib/piggly/util/enumerable.rb +44 -0
  41. data/lib/piggly/util/file.rb +17 -0
  42. data/lib/piggly/util/process_queue.rb +96 -0
  43. data/lib/piggly/util/thunk.rb +39 -0
  44. data/lib/piggly/util.rb +9 -0
  45. data/lib/piggly/version.rb +15 -0
  46. data/lib/piggly.rb +20 -0
  47. data/spec/examples/compiler/cacheable_spec.rb +190 -0
  48. data/spec/examples/compiler/report_spec.rb +25 -0
  49. data/spec/examples/compiler/trace_spec.rb +123 -0
  50. data/spec/examples/config_spec.rb +63 -0
  51. data/spec/examples/dumper/index_spec.rb +199 -0
  52. data/spec/examples/dumper/procedure_spec.rb +116 -0
  53. data/spec/examples/grammar/expression_spec.rb +302 -0
  54. data/spec/examples/grammar/statements/assignment_spec.rb +70 -0
  55. data/spec/examples/grammar/statements/declaration_spec.rb +21 -0
  56. data/spec/examples/grammar/statements/exception_spec.rb +78 -0
  57. data/spec/examples/grammar/statements/if_spec.rb +191 -0
  58. data/spec/examples/grammar/statements/loop_spec.rb +41 -0
  59. data/spec/examples/grammar/statements/sql_spec.rb +71 -0
  60. data/spec/examples/grammar/tokens/comment_spec.rb +58 -0
  61. data/spec/examples/grammar/tokens/datatype_spec.rb +58 -0
  62. data/spec/examples/grammar/tokens/identifier_spec.rb +74 -0
  63. data/spec/examples/grammar/tokens/keyword_spec.rb +44 -0
  64. data/spec/examples/grammar/tokens/label_spec.rb +40 -0
  65. data/spec/examples/grammar/tokens/literal_spec.rb +30 -0
  66. data/spec/examples/grammar/tokens/lval_spec.rb +50 -0
  67. data/spec/examples/grammar/tokens/number_spec.rb +34 -0
  68. data/spec/examples/grammar/tokens/sqlkeywords_spec.rb +45 -0
  69. data/spec/examples/grammar/tokens/string_spec.rb +54 -0
  70. data/spec/examples/grammar/tokens/whitespace_spec.rb +40 -0
  71. data/spec/examples/installer_spec.rb +59 -0
  72. data/spec/examples/parser/nodes_spec.rb +73 -0
  73. data/spec/examples/parser/traversal_spec.rb +14 -0
  74. data/spec/examples/parser_spec.rb +118 -0
  75. data/spec/examples/profile_spec.rb +153 -0
  76. data/spec/examples/reporter/html/dsl_spec.rb +0 -0
  77. data/spec/examples/reporter/html/index_spec.rb +0 -0
  78. data/spec/examples/reporter/html_spec.rb +1 -0
  79. data/spec/examples/reporter_spec.rb +0 -0
  80. data/spec/examples/tags_spec.rb +285 -0
  81. data/spec/examples/task_spec.rb +0 -0
  82. data/spec/examples/util/cacheable_spec.rb +41 -0
  83. data/spec/examples/util/enumerable_spec.rb +64 -0
  84. data/spec/examples/util/file_spec.rb +40 -0
  85. data/spec/examples/util/process_queue_spec.rb +16 -0
  86. data/spec/examples/util/thunk_spec.rb +59 -0
  87. data/spec/examples/version_spec.rb +0 -0
  88. data/spec/issues/007_spec.rb +25 -0
  89. data/spec/issues/008_spec.rb +73 -0
  90. data/spec/issues/018_spec.rb +25 -0
  91. data/spec/issues/028_spec.rb +48 -0
  92. data/spec/issues/032_spec.rb +98 -0
  93. data/spec/issues/036_spec.rb +41 -0
  94. data/spec/spec_helper.rb +312 -0
  95. data/spec/spec_suite.rb +5 -0
  96. metadata +162 -0
@@ -0,0 +1,748 @@
1
+ # encoding: UTF-8
2
+
3
+ grammar PigglyParser
4
+
5
+ rule start
6
+ tSpace?
7
+ block ';'?
8
+ tSpace?
9
+ end
10
+
11
+ rule block
12
+ label_open:tLabelDefinition tSpace
13
+ blockDeclarations:stmtDeclare*
14
+ kwBEGIN
15
+ bodySpace:tSpace
16
+ bodyStub:stubNode
17
+ body:statement*
18
+ blockExceptions?
19
+ kwEND
20
+ ( tSpace label_close:tLabel )?
21
+ tSpace? <Piggly::Parser::Nodes::Block>
22
+ /
23
+ blockDeclarations:stmtDeclare*
24
+ kwBEGIN
25
+ bodySpace:tSpace
26
+ bodyStub:stubNode
27
+ body:statement*
28
+ blockExceptions?
29
+ kwEND
30
+ tSpace? <Piggly::Parser::Nodes::Block>
31
+ end
32
+
33
+ rule statement
34
+ inner:( block ';'
35
+ / stmtAssignment
36
+ / stmtIf
37
+ / stmtCase
38
+ / stmtLoop
39
+ / stmtWhileLoop
40
+ / stmtForLoop
41
+ / stmtForEachLoop
42
+ / stmtExit
43
+ / stmtContinue
44
+ / stmtReturn
45
+ / stmtRaise
46
+ / stmtExecSql
47
+ / stmtNull
48
+ / stmtGetDiag )
49
+ tail:tSpace? <Piggly::Parser::Nodes::Statement>
50
+ end
51
+
52
+ rule stmtAssignment
53
+ lval:lValue tSpace? kwASSIGN ws?
54
+ rval:expressionUntilSemiColon ';' <Piggly::Parser::Nodes::Assignment>
55
+ end
56
+
57
+ rule stmtCase
58
+ kwCASE tSpace
59
+ cases:condWhen+
60
+ else:stmtElse?
61
+ kwEND tSpace kwCASE
62
+ tSpace? ';' <Piggly::Parser::Nodes::Cond>
63
+ /
64
+ kwCASE tSpace
65
+ expr:expressionUntilWhen
66
+ cases:caseWhen+
67
+ else:stmtElse?
68
+ kwEND tSpace kwCASE
69
+ tSpace? ';' <Piggly::Parser::Nodes::Case>
70
+ end
71
+
72
+ rule stmtIf
73
+ kwIF
74
+ condSpace:tSpace?
75
+ condStub:stubNode
76
+ cond:expressionUntilThen
77
+ kwTHEN
78
+ bodySpace:tSpace
79
+ bodyStub:stubNode
80
+ body:statement*
81
+ else:stmtElse?
82
+ kwEND tSpace kwIF tSpace? ';' <Piggly::Parser::Nodes::If>
83
+ end
84
+
85
+ rule stmtElse
86
+ kwELSIF
87
+ condSpace:tSpace?
88
+ condStub:stubNode
89
+ cond:expressionUntilThen
90
+ kwTHEN
91
+ bodySpace:tSpace
92
+ bodyStub:stubNode
93
+ body:statement*
94
+ else:stmtElse? <Piggly::Parser::Nodes::If>
95
+ /
96
+ kwELSE
97
+ bodySpace:tSpace
98
+ bodyStub:stubNode
99
+ body:statement* <Piggly::Parser::Nodes::Else>
100
+ end
101
+
102
+ rule stmtLoop
103
+ label_open:tLabelDefinition tSpace
104
+ cond:kwLOOP
105
+ bodySpace:tSpace
106
+ bodyStub:stubNode
107
+ body:statement*
108
+ doneStub:stubNode
109
+ kwEND tSpace kwLOOP
110
+ ( tSpace label_close:tLabel <Piggly::Parser::Nodes::TLabel> )?
111
+ tSpace? ';' exitStub:stubNode <Piggly::Parser::Nodes::Loop>
112
+ /
113
+ cond:kwLOOP
114
+ bodySpace:tSpace
115
+ bodyStub:stubNode
116
+ body:statement*
117
+ doneStub:stubNode
118
+ kwEND tSpace kwLOOP
119
+ tSpace? ';' exitStub:stubNode <Piggly::Parser::Nodes::Loop>
120
+ end
121
+
122
+ rule stmtWhileLoop
123
+ label_open:tLabelDefinition tSpace
124
+ kwWHILE
125
+ condSpace:tSpace?
126
+ condStub:stubNode
127
+ cond:expressionUntilLoop
128
+ kwLOOP
129
+ bodySpace:tSpace
130
+ bodyStub:stubNode
131
+ body:statement*
132
+ kwEND tSpace kwLOOP
133
+ ( tSpace label_close:tLabel <Piggly::Parser::Nodes::TLabel> )?
134
+ tSpace? ';' <Piggly::Parser::Nodes::WhileLoop>
135
+ /
136
+ kwWHILE
137
+ condSpace:tSpace?
138
+ condStub:stubNode
139
+ cond:expressionUntilLoop
140
+ kwLOOP
141
+ bodySpace:tSpace
142
+ bodyStub:stubNode
143
+ body:statement*
144
+ kwEND tSpace kwLOOP
145
+ tSpace? ';' <Piggly::Parser::Nodes::WhileLoop>
146
+ end
147
+
148
+ rule stmtForEachLoop
149
+ label_open:tLabelDefinition tSpace
150
+ kwFOREACH tSpace tIdentifier tSpace
151
+ kwIN tSpace kwARRAY
152
+ condSpace:tSpace
153
+ cond:expressionUntilLoop
154
+ kwLOOP
155
+ bodySpace:tSpace
156
+ bodyStub:stubNode
157
+ body:statement*
158
+ doneStub:stubNode
159
+ kwEND tSpace kwLOOP
160
+ ( tSpace label_close:tLabel <Piggly::Parser::Nodes::TLabel> )?
161
+ tSpace? ';' exitStub:stubNode <Piggly::Parser::Nodes::ForEachLoop>
162
+ /
163
+ kwFOREACH tSpace tIdentifier tSpace
164
+ kwIN tSpace kwARRAY
165
+ condSpace:tSpace
166
+ cond:expressionUntilLoop
167
+ kwLOOP
168
+ bodySpace:tSpace
169
+ bodyStub:stubNode
170
+ body:statement*
171
+ doneStub:stubNode
172
+ kwEND tSpace kwLOOP
173
+ tSpace? ';' exitStub:stubNode <Piggly::Parser::Nodes::ForEachLoop>
174
+ end
175
+
176
+ rule stmtForLoop
177
+ label_open:tLabelDefinition tSpace
178
+ kwFOR tSpace identifierList tSpace
179
+ kwIN
180
+ condSpace:tSpace
181
+ cond:( stmtForSql / expressionUntilLoop )
182
+ kwLOOP
183
+ bodySpace:tSpace
184
+ bodyStub:stubNode
185
+ body:statement*
186
+ doneStub:stubNode
187
+ kwEND tSpace kwLOOP
188
+ ( tSpace label_close:tLabel <Piggly::Parser::Nodes::TLabel> )?
189
+ tSpace? ';' exitStub:stubNode <Piggly::Parser::Nodes::ForLoop>
190
+ /
191
+ kwFOR tSpace identifierList tSpace
192
+ kwIN
193
+ condSpace:tSpace
194
+ cond:( stmtForSql / expressionUntilLoop )
195
+ kwLOOP
196
+ bodySpace:tSpace
197
+ bodyStub:stubNode
198
+ body:statement*
199
+ doneStub:stubNode
200
+ kwEND tSpace kwLOOP
201
+ tSpace? ';' exitStub:stubNode <Piggly::Parser::Nodes::ForLoop>
202
+ end
203
+
204
+ rule stmtForSql
205
+ sqlKeyword tSpace expressionUntilLoop <Piggly::Parser::Nodes::Sql>
206
+ end
207
+
208
+ rule stmtExit
209
+ bodyStub:stubNode
210
+ body:( kwEXIT (tSpace label:tLabel <Piggly::Parser::Nodes::TLabel> )? )
211
+ tSpace? ';' <Piggly::Parser::Nodes::Exit>
212
+ /
213
+ body:( kwEXIT (tSpace label:tLabel <Piggly::Parser::Nodes::TLabel> )? )
214
+ tSpace
215
+ kwWHEN
216
+ condSpace:tSpace
217
+ condStub:stubNode
218
+ cond:expressionUntilSemiColon ';' <Piggly::Parser::Nodes::ExitWhen>
219
+ end
220
+
221
+ rule stmtContinue
222
+ bodyStub:stubNode
223
+ body:( kwCONTINUE (tSpace label:tLabel <Piggly::Parser::Nodes::TLabel> )? )
224
+ tSpace? ';' <Piggly::Parser::Nodes::Continue>
225
+ /
226
+ body:( kwCONTINUE (tSpace label:tLabel <Piggly::Parser::Nodes::TLabel> )? )
227
+ tSpace
228
+ kwWHEN
229
+ condSpace:tSpace
230
+ condStub:stubNode
231
+ cond:expressionUntilSemiColon ';' <Piggly::Parser::Nodes::ContinueWhen>
232
+ end
233
+
234
+ rule stmtReturn
235
+ bodyStub:stubNode
236
+ body:(kwRETURN ( tSpace? &';'
237
+ / tSpace kwNEXT tSpace expressionUntilSemiColon tSpace?
238
+ / tSpace kwQUERY tSpace expressionUntilSemiColon
239
+ / expressionUntilSemiColon )) ';' <Piggly::Parser::Nodes::Return>
240
+ end
241
+
242
+ rule stmtRaise
243
+ kwRAISE tSpace
244
+ level:( kwWARNING
245
+ / kwNOTICE
246
+ / kwINFO
247
+ / kwLOG
248
+ / kwDEBUG )
249
+ ( tSpace expr:expressionUntilSemiColon )? ';' <Piggly::Parser::Nodes::Raise>
250
+ /
251
+ bodyStub:stubNode
252
+ body:(kwRAISE ( tSpace level:kwEXCEPTION tSpace? )? expr:expressionUntilSemiColon) ';' <Piggly::Parser::Nodes::Throw>
253
+ end
254
+
255
+ rule stmtExecSql
256
+ sqlKeyword tSpace expressionUntilSemiColon ';' <Piggly::Parser::Nodes::Sql>
257
+ end
258
+
259
+ rule stmtGetDiag
260
+ kwGET tSpace ( kwSTACKED tSpace )? kwDIAGNOSTICS tSpace expressionUntilSemiColon ';' <Piggly::Parser::Nodes::Expression>
261
+ end
262
+
263
+ rule stmtNull
264
+ kwNULL tSpace? ';'
265
+ end
266
+
267
+ #############################################################################
268
+
269
+ rule stmtDeclare
270
+ kwDECLARE tSpace varDeclaration*
271
+ end
272
+
273
+ rule varDeclaration
274
+ varDeclarationMisc / varDeclarationCursor
275
+ end
276
+
277
+ rule varDeclarationMisc
278
+ name:tIdentifier tSpace ( kwCONSTANT tSpace )?
279
+ type:tType ( tSpace kwCOLLATE name:tIdentifier )?
280
+ ( tSpace kwNOT tSpace kwNULL )?
281
+ ( tSpace? ( kwASSIGN / kwDEFAULT ) tSpace? rval:expressionUntilSemiColon )?
282
+ tSpace?
283
+ ';' tSpace?
284
+ end
285
+
286
+ rule varDeclarationCursor
287
+ name:tIdentifier tSpace ( ( kwNO tSpace )? kwSCROLL tSpace )? kwCURSOR tSpace
288
+ rval:expressionUntilSemiColon
289
+ tSpace?
290
+ ';' tSpace?
291
+ end
292
+
293
+ rule identifierList
294
+ tIdentifier ( tSpace? ',' tSpace? tIdentifier )*
295
+ end
296
+
297
+ rule blockExceptions
298
+ kwEXCEPTION tSpace cases:exceptionCase*
299
+ end
300
+
301
+ rule exceptionCase
302
+ # cannot provide branch-coverage on cond
303
+ kwWHEN
304
+ condSpace:tSpace
305
+ cond:expressionUntilThen
306
+ kwTHEN
307
+ bodySpace:tSpace
308
+ bodyStub:stubNode
309
+ body:statement* <Piggly::Parser::Nodes::Catch>
310
+ end
311
+
312
+ rule caseWhen
313
+ # cannot provide branch-coverage on cond
314
+ kwWHEN
315
+ condSpace:tSpace
316
+ cond:expressionUntilThen
317
+ kwTHEN
318
+ bodySpace:tSpace
319
+ bodyStub:stubNode
320
+ body:statement* <Piggly::Parser::Nodes::CaseWhen>
321
+ end
322
+
323
+ rule condWhen
324
+ kwWHEN
325
+ condSpace:tSpace
326
+ condStub:stubNode
327
+ cond:expressionUntilThen
328
+ kwTHEN
329
+ bodySpace:tSpace
330
+ bodyStub:stubNode
331
+ body:statement* <Piggly::Parser::Nodes::CondWhen>
332
+ end
333
+
334
+ ## EXPRESSIONS
335
+ #############################################################################
336
+
337
+ rule expressionUntilSemiColon
338
+ head:tSpace? expr:( tString / skipWords / tSpace !';' / !tSpace [^;] )*
339
+ tail:tSpace? &';' <Piggly::Parser::Nodes::Expression>
340
+ end
341
+
342
+ rule expressionUntilClosingBracket
343
+ head:tSpace? expr:( tString / skipWords / tSpace !']' / !tSpace [^\]] )+
344
+ tail:tSpace? &']' <Piggly::Parser::Nodes::Expression>
345
+ end
346
+
347
+ rule expressionUntilThen
348
+ head:tSpace? expr:( tString / skipWords / tSpace !kwTHEN / !tSpace !kwTHEN . )+
349
+ tail:tSpace &kwTHEN <Piggly::Parser::Nodes::Expression>
350
+ end
351
+
352
+ rule expressionUntilWhen
353
+ head:tSpace? expr:( tString / skipWords / tSpace !kwWHEN / !tSpace !kwWHEN . )+
354
+ tail:tSpace &kwWHEN <Piggly::Parser::Nodes::Expression>
355
+ end
356
+
357
+ rule expressionUntilLoop
358
+ head:tSpace? expr:( tString / skipWords / tSpace !kwLOOP / !tSpace !kwLOOP . )+
359
+ tail:tSpace &kwLOOP <Piggly::Parser::Nodes::Expression>
360
+ end
361
+
362
+ rule skipWords
363
+ [a-z0-9_]+ <Piggly::Parser::Nodes::TextNode>
364
+ end
365
+
366
+ #############################################################################
367
+
368
+ rule ws
369
+ [ \t\n\v\f\r]+ <Piggly::Parser::Nodes::TextNode>
370
+ end
371
+
372
+ rule dollarQuoteMarker
373
+ '$' tag:( [a-zа-яё_] [a-zа-яё_0-9]* )? '$' <Piggly::Parser::Nodes::TDollarQuoteMarker>
374
+ end
375
+
376
+ rule stubNode
377
+ '' <Piggly::Parser::Nodes::StubNode>
378
+ end
379
+
380
+ rule notImplemented
381
+ '' <Piggly::Parser::Nodes::NotImplemented>
382
+ end
383
+
384
+ rule lValue
385
+ tIdentifier
386
+ ( '[' expressionUntilClosingBracket ']' )*
387
+ ( [.] lValue )*
388
+
389
+ <Piggly::Parser::Nodes::Assignable>
390
+ end
391
+
392
+ ## BASIC TOKENS
393
+ #############################################################################
394
+
395
+ rule tEOF
396
+ !.
397
+ end
398
+
399
+ rule tLabelDefinition
400
+ '<<' tSpace? tLabel tSpace? '>>' <Piggly::Parser::Nodes::TLabel>
401
+ end
402
+
403
+ rule tLabel
404
+ tIdentifier
405
+ end
406
+
407
+ rule tIdentifier
408
+ ( '"' [^"]+ '"' )+ <Piggly::Parser::Nodes::TIdentifier>
409
+ / !keyword ( [a-zа-яё_] [a-zа-яё_0-9$]* ) <Piggly::Parser::Nodes::TIdentifier>
410
+ end
411
+
412
+ # not context sensitive so opening and closing tag might not match
413
+ rule tString
414
+ openTag:dollarQuoteMarker content:(!dollarQuoteMarker .)* closeTag:dollarQuoteMarker <Piggly::Parser::Nodes::TString> /
415
+ "E'" content:("''" / [^'])* "'" <Piggly::Parser::Nodes::TString> /
416
+ "'" content:("''" / [^'])* "'" <Piggly::Parser::Nodes::TString>
417
+ end
418
+
419
+ # beware this is quite broad and might match things it shouldn't
420
+ rule tType
421
+ [a-zа-яё_]
422
+ ( '(' rType ')' /
423
+ '[' rType ']' /
424
+ [a-zа-яё_0-9$%]+ '.'? /
425
+ ws !( kwAS / kwNOT / kwASSIGN / kwDEFAULT ) )* <Piggly::Parser::Nodes::TDatatype>
426
+ end
427
+
428
+ rule rType
429
+ ( '(' rType ')' /
430
+ '[' rType ']' /
431
+ [^\(\)\[\]]+ )*
432
+ end
433
+
434
+ rule tSpace
435
+ ws !tComment <Piggly::Parser::Nodes::TextNode>
436
+ /
437
+ ( ws / tComment )+
438
+ end
439
+
440
+ rule tComment
441
+ '/*' content:(!'*/' .)* '*/' <Piggly::Parser::Nodes::TComment> /
442
+ '--' content:[^\n]* ("\n" / tEOF) <Piggly::Parser::Nodes::TComment>
443
+ end
444
+
445
+ ##
446
+ #############################################################################
447
+
448
+ rule tBinary
449
+ "b'" [01]+ "'"
450
+ end
451
+
452
+ rule tHex
453
+ "x'" [0123456789abcdef]+ "'"
454
+ end
455
+
456
+ rule tNumber
457
+ tBinary / tHex /
458
+ sign:[+-]? '.' [0-9]+ exponent:('e' [+-]? [0-9]+)? /
459
+ sign:[+-]? [0-9]+ '.' [0-9]* exponent:('e' [+-]? [0-9]+)? /
460
+ sign:[+-]? [0-9]+ '.'? exponent:('e' [+-]? [0-9]+)?
461
+ end
462
+
463
+ rule tLiteral
464
+ tString (tSpace? '::' tSpace? tType) /
465
+ tString /
466
+ tNumber (tSpace? '::' tSpace? tType) /
467
+ tNumber /
468
+ 'cast' tSpace? '(' tSpace? tString tSpace kwAS tSpace tType tSpace? ')' /
469
+ 'cast' tSpace? '(' tSpace? tNumber tSpace kwAS tSpace tType tSpace? ')'
470
+ end
471
+
472
+ ## KEYWORDS
473
+ #############################################################################
474
+
475
+ rule sqlKeyword
476
+ ( 'insert'
477
+ / 'select'
478
+ / 'update'
479
+ / 'delete'
480
+ / 'perform'
481
+ / 'execute'
482
+ / 'open'
483
+ / 'close'
484
+ / 'lock'
485
+ / 'fetch'
486
+ / 'move'
487
+ / 'truncate'
488
+ / 'create'
489
+ / 'drop'
490
+ / 'alter'
491
+ / 'commit'
492
+ / 'copy'
493
+ / 'create'
494
+ / 'set'
495
+ / 'start'
496
+ / 'notify'
497
+ / 'call'
498
+ / 'with' ) ![a-z0-9] <Piggly::Parser::Nodes::TKeyword>
499
+ end
500
+
501
+ rule keyword
502
+ # WHEN is checked first as a minor optimization to distinguish
503
+ # CONTINUE tIdentifier WHEN cond;
504
+ # EXIT tIdentifier WHEN cond;
505
+ #
506
+ # CONTINUE WHEN cond;
507
+ # EXIT WHEN cond;
508
+
509
+ kwWHEN / kwAS / kwASSIGN / kwALIAS / kwBEGIN / kwBY / kwCASE / kwARRAY
510
+ / kwCOLLATE / kwCONSTANT / kwCONTINUE / kwCURSOR / kwDEBUG / kwDECLARE / kwDEFAULT
511
+ / kwDIAGNOSTICS / kwELSE / kwELSIF / kwEND / kwEXCEPTION / kwEXECUTE / kwEXIT
512
+ / kwFOR / kwFROM / kwGET / kwIF / kwIN / kwINFO / kwINSERT / kwINTO
513
+ / kwIS / kwLOG / kwLOOP / kwNOT / kwNOTICE / kwNULL / kwFOREACH
514
+ / kwOR / kwRAISE / kwRENAME / kwRESULTOID / kwRETURN
515
+ / kwREVERSE / kwROWCOUNT / kwSCROLL / kwSTRICT / kwTHEN / kwTO / kwTYPE
516
+ / kwWARNING / kwWHILE
517
+ end
518
+
519
+ # this terminates keywords
520
+ rule x
521
+ [^a-z0-9_]
522
+ end
523
+
524
+ rule kwAS
525
+ 'as' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
526
+ end
527
+
528
+ rule kwASSIGN
529
+ ':=' <Piggly::Parser::Nodes::TKeyword> / '=' <Piggly::Parser::Nodes::TKeyword>
530
+ end
531
+
532
+ rule kwALIAS
533
+ 'alias' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
534
+ end
535
+
536
+ rule kwARRAY
537
+ 'array' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
538
+ end
539
+
540
+ rule kwBEGIN
541
+ 'begin' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
542
+ end
543
+
544
+ rule kwBY
545
+ 'by' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
546
+ end
547
+
548
+ rule kwCASE
549
+ 'case' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
550
+ end
551
+
552
+ rule kwCOLLATE
553
+ 'collate' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
554
+ end
555
+
556
+ rule kwCONSTANT
557
+ 'constant' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
558
+ end
559
+
560
+ rule kwCONTINUE
561
+ 'continue' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
562
+ end
563
+
564
+ rule kwCURSOR
565
+ 'cursor' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
566
+ end
567
+
568
+ rule kwDEBUG
569
+ 'debug' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
570
+ end
571
+
572
+ rule kwDECLARE
573
+ 'declare' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
574
+ end
575
+
576
+ rule kwDEFAULT
577
+ 'default' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
578
+ end
579
+
580
+ rule kwDIAGNOSTICS
581
+ 'diagnostics' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
582
+ end
583
+
584
+ rule kwELSE
585
+ 'else' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
586
+ end
587
+
588
+ rule kwELSIF
589
+ ('elsif'/'elseif') ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
590
+ end
591
+
592
+ rule kwEND
593
+ 'end' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
594
+ end
595
+
596
+ rule kwEXCEPTION
597
+ 'exception' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
598
+ end
599
+
600
+ rule kwEXECUTE
601
+ 'execute' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
602
+ end
603
+
604
+ rule kwEXIT
605
+ 'exit' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
606
+ end
607
+
608
+ rule kwFOR
609
+ 'for' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
610
+ end
611
+
612
+ rule kwFOREACH
613
+ 'foreach' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
614
+ end
615
+
616
+ rule kwFROM
617
+ 'from' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
618
+ end
619
+
620
+ rule kwGET
621
+ 'get' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
622
+ end
623
+
624
+ rule kwIF
625
+ 'if' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
626
+ end
627
+
628
+ rule kwIN
629
+ 'in' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
630
+ end
631
+
632
+ rule kwINFO
633
+ 'info' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
634
+ end
635
+
636
+ rule kwINSERT
637
+ 'insert' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
638
+ end
639
+
640
+ rule kwINTO
641
+ 'into' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
642
+ end
643
+
644
+ rule kwIS
645
+ 'is' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
646
+ end
647
+
648
+ rule kwLOG
649
+ 'log' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
650
+ end
651
+
652
+ rule kwLOOP
653
+ 'loop' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
654
+ end
655
+
656
+ rule kwNEXT
657
+ 'next' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
658
+ end
659
+
660
+ rule kwNO
661
+ 'no' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
662
+ end
663
+
664
+ rule kwNOT
665
+ 'not' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
666
+ end
667
+
668
+ rule kwNOTICE
669
+ 'notice' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
670
+ end
671
+
672
+ rule kwNULL
673
+ 'null' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
674
+ end
675
+
676
+ rule kwOR
677
+ 'or' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
678
+ end
679
+
680
+ rule kwPERFORM
681
+ 'perform' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
682
+ end
683
+
684
+ rule kwQUERY
685
+ 'query' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
686
+ end
687
+
688
+ rule kwRAISE
689
+ 'raise' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
690
+ end
691
+
692
+ rule kwRENAME
693
+ 'rename' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
694
+ end
695
+
696
+ rule kwRESULTOID
697
+ 'result_oid' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
698
+ end
699
+
700
+ rule kwRETURN
701
+ 'return' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
702
+ end
703
+
704
+ rule kwREVERSE
705
+ 'reverse' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
706
+ end
707
+
708
+ rule kwROWCOUNT
709
+ 'row_count' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
710
+ end
711
+
712
+ rule kwSCROLL
713
+ 'scroll' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
714
+ end
715
+
716
+ rule kwSTACKED
717
+ 'stacked' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
718
+ end
719
+
720
+ rule kwSTRICT
721
+ 'strict' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
722
+ end
723
+
724
+ rule kwTHEN
725
+ 'then' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
726
+ end
727
+
728
+ rule kwTO
729
+ 'to' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
730
+ end
731
+
732
+ rule kwTYPE
733
+ 'type' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
734
+ end
735
+
736
+ rule kwWARNING
737
+ 'warning' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
738
+ end
739
+
740
+ rule kwWHEN
741
+ 'when' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
742
+ end
743
+
744
+ rule kwWHILE
745
+ 'while' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
746
+ end
747
+
748
+ end