vorax 0.3.0 → 0.3.1
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.
- data/lib/vorax.rb +1 -1
- data/lib/vorax/parser/grammars/alias.rb +10 -9
- data/lib/vorax/parser/grammars/alias.rl +1 -0
- data/lib/vorax/parser/grammars/{package_spec.rb → declare.rb} +105 -105
- data/lib/vorax/parser/grammars/{package_spec.rl → declare.rl} +2 -2
- data/lib/vorax/parser/target_ref.rb +2 -2
- data/lib/vorax/version.rb +1 -1
- data/spec/{package_spec_spec.rb → declare_spec.rb} +3 -3
- data/spec/plsql_structure_spec.rb +16 -11
- data/spec/sql/test.pkg +2 -1
- data/spec/stmt_inspector_spec.rb +12 -0
- metadata +6 -6
data/lib/vorax.rb
CHANGED
@@ -55,6 +55,6 @@ require 'vorax/parser/plsql_structure.rb'
|
|
55
55
|
require 'vorax/parser/grammars/statement.rb'
|
56
56
|
require 'vorax/parser/grammars/alias.rb'
|
57
57
|
require 'vorax/parser/grammars/column.rb'
|
58
|
-
require 'vorax/parser/grammars/
|
58
|
+
require 'vorax/parser/grammars/declare.rb'
|
59
59
|
require 'vorax/parser/grammars/plsql_def.rb'
|
60
60
|
require 'vorax/parser/grammars/for_block.rb'
|
@@ -21,11 +21,12 @@ module Vorax
|
|
21
21
|
# @param data the statement
|
22
22
|
def walk(data)
|
23
23
|
@refs = [];
|
24
|
+
@start_columns = 0
|
24
25
|
@columns = nil;
|
25
26
|
data << "\n"
|
26
27
|
eof = data.length
|
27
28
|
|
28
|
-
# line
|
29
|
+
# line 30 "lib/vorax/parser/grammars/alias.rb"
|
29
30
|
class << self
|
30
31
|
attr_accessor :_alias_actions
|
31
32
|
private :_alias_actions, :_alias_actions=
|
@@ -544,9 +545,9 @@ end
|
|
544
545
|
self.alias_en_main = 131;
|
545
546
|
|
546
547
|
|
547
|
-
# line
|
548
|
+
# line 96 "lib/vorax/parser/grammars/alias.rl"
|
548
549
|
|
549
|
-
# line
|
550
|
+
# line 551 "lib/vorax/parser/grammars/alias.rb"
|
550
551
|
begin
|
551
552
|
p ||= 0
|
552
553
|
pe ||= data.length
|
@@ -556,9 +557,9 @@ begin
|
|
556
557
|
act = 0
|
557
558
|
end
|
558
559
|
|
559
|
-
# line
|
560
|
+
# line 97 "lib/vorax/parser/grammars/alias.rl"
|
560
561
|
|
561
|
-
# line
|
562
|
+
# line 563 "lib/vorax/parser/grammars/alias.rb"
|
562
563
|
begin
|
563
564
|
_klen, _trans, _keys, _acts, _nacts = nil
|
564
565
|
_goto_level = 0
|
@@ -588,7 +589,7 @@ begin
|
|
588
589
|
begin
|
589
590
|
ts = p
|
590
591
|
end
|
591
|
-
# line
|
592
|
+
# line 593 "lib/vorax/parser/grammars/alias.rb"
|
592
593
|
end # from state action switch
|
593
594
|
end
|
594
595
|
if _trigger_goto
|
@@ -812,7 +813,7 @@ end
|
|
812
813
|
end
|
813
814
|
end
|
814
815
|
end
|
815
|
-
# line
|
816
|
+
# line 817 "lib/vorax/parser/grammars/alias.rb"
|
816
817
|
end # action switch
|
817
818
|
end
|
818
819
|
end
|
@@ -832,7 +833,7 @@ when 8 then
|
|
832
833
|
# line 1 "NONE"
|
833
834
|
begin
|
834
835
|
ts = nil; end
|
835
|
-
# line
|
836
|
+
# line 837 "lib/vorax/parser/grammars/alias.rb"
|
836
837
|
end # to state action switch
|
837
838
|
end
|
838
839
|
if _trigger_goto
|
@@ -859,7 +860,7 @@ end
|
|
859
860
|
end
|
860
861
|
end
|
861
862
|
|
862
|
-
# line
|
863
|
+
# line 98 "lib/vorax/parser/grammars/alias.rl"
|
863
864
|
data.chop!
|
864
865
|
|
865
866
|
# needed to finalize the last pending tableref
|
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
|
-
# line 1 "lib/vorax/parser/grammars/
|
2
|
+
# line 1 "lib/vorax/parser/grammars/declare.rl"
|
3
3
|
|
4
|
-
# line 41 "lib/vorax/parser/grammars/
|
4
|
+
# line 41 "lib/vorax/parser/grammars/declare.rl"
|
5
5
|
|
6
6
|
|
7
7
|
require 'set'
|
@@ -11,7 +11,7 @@ module Vorax
|
|
11
11
|
module Parser
|
12
12
|
|
13
13
|
# A class used to parse a PLSQL package spec.
|
14
|
-
class
|
14
|
+
class Declare
|
15
15
|
|
16
16
|
attr_reader :constants, :types, :exceptions, :cursors, :variables, :functions, :procedures
|
17
17
|
|
@@ -29,12 +29,12 @@ module Vorax
|
|
29
29
|
if data
|
30
30
|
eof = data.length
|
31
31
|
|
32
|
-
# line 33 "lib/vorax/parser/grammars/
|
32
|
+
# line 33 "lib/vorax/parser/grammars/declare.rb"
|
33
33
|
class << self
|
34
|
-
attr_accessor :
|
35
|
-
private :
|
34
|
+
attr_accessor :_declare_actions
|
35
|
+
private :_declare_actions, :_declare_actions=
|
36
36
|
end
|
37
|
-
self.
|
37
|
+
self._declare_actions = [
|
38
38
|
0, 1, 0, 1, 1, 1, 2, 1,
|
39
39
|
3, 1, 4, 1, 15, 1, 16, 1,
|
40
40
|
17, 1, 18, 1, 19, 1, 20, 1,
|
@@ -51,10 +51,10 @@ self._package_spec_actions = [
|
|
51
51
|
]
|
52
52
|
|
53
53
|
class << self
|
54
|
-
attr_accessor :
|
55
|
-
private :
|
54
|
+
attr_accessor :_declare_key_offsets
|
55
|
+
private :_declare_key_offsets, :_declare_key_offsets=
|
56
56
|
end
|
57
|
-
self.
|
57
|
+
self._declare_key_offsets = [
|
58
58
|
0, 11, 12, 13, 14, 15, 17, 19,
|
59
59
|
24, 47, 48, 53, 54, 55, 56, 57,
|
60
60
|
59, 61, 63, 65, 67, 69, 71, 73,
|
@@ -88,10 +88,10 @@ self._package_spec_key_offsets = [
|
|
88
88
|
]
|
89
89
|
|
90
90
|
class << self
|
91
|
-
attr_accessor :
|
92
|
-
private :
|
91
|
+
attr_accessor :_declare_trans_keys
|
92
|
+
private :_declare_trans_keys, :_declare_trans_keys=
|
93
93
|
end
|
94
|
-
self.
|
94
|
+
self._declare_trans_keys = [
|
95
95
|
32, 45, 47, 65, 68, 73, 97, 100,
|
96
96
|
105, 9, 13, 45, 10, 42, 42, 42,
|
97
97
|
47, 83, 115, 32, 45, 47, 9, 13,
|
@@ -328,10 +328,10 @@ self._package_spec_trans_keys = [
|
|
328
328
|
]
|
329
329
|
|
330
330
|
class << self
|
331
|
-
attr_accessor :
|
332
|
-
private :
|
331
|
+
attr_accessor :_declare_single_lengths
|
332
|
+
private :_declare_single_lengths, :_declare_single_lengths=
|
333
333
|
end
|
334
|
-
self.
|
334
|
+
self._declare_single_lengths = [
|
335
335
|
9, 1, 1, 1, 1, 2, 2, 3,
|
336
336
|
15, 1, 3, 1, 1, 1, 1, 2,
|
337
337
|
2, 2, 2, 2, 2, 2, 2, 2,
|
@@ -365,10 +365,10 @@ self._package_spec_single_lengths = [
|
|
365
365
|
]
|
366
366
|
|
367
367
|
class << self
|
368
|
-
attr_accessor :
|
369
|
-
private :
|
368
|
+
attr_accessor :_declare_range_lengths
|
369
|
+
private :_declare_range_lengths, :_declare_range_lengths=
|
370
370
|
end
|
371
|
-
self.
|
371
|
+
self._declare_range_lengths = [
|
372
372
|
1, 0, 0, 0, 0, 0, 0, 1,
|
373
373
|
4, 0, 1, 0, 0, 0, 0, 0,
|
374
374
|
0, 0, 0, 0, 0, 0, 0, 0,
|
@@ -402,10 +402,10 @@ self._package_spec_range_lengths = [
|
|
402
402
|
]
|
403
403
|
|
404
404
|
class << self
|
405
|
-
attr_accessor :
|
406
|
-
private :
|
405
|
+
attr_accessor :_declare_index_offsets
|
406
|
+
private :_declare_index_offsets, :_declare_index_offsets=
|
407
407
|
end
|
408
|
-
self.
|
408
|
+
self._declare_index_offsets = [
|
409
409
|
0, 11, 13, 15, 17, 19, 22, 25,
|
410
410
|
30, 50, 52, 57, 59, 61, 63, 65,
|
411
411
|
68, 71, 74, 77, 80, 83, 86, 89,
|
@@ -439,10 +439,10 @@ self._package_spec_index_offsets = [
|
|
439
439
|
]
|
440
440
|
|
441
441
|
class << self
|
442
|
-
attr_accessor :
|
443
|
-
private :
|
442
|
+
attr_accessor :_declare_indicies
|
443
|
+
private :_declare_indicies, :_declare_indicies=
|
444
444
|
end
|
445
|
-
self.
|
445
|
+
self._declare_indicies = [
|
446
446
|
1, 2, 3, 4, 5, 4, 4, 5,
|
447
447
|
4, 1, 0, 6, 0, 1, 6, 7,
|
448
448
|
0, 8, 7, 8, 1, 7, 9, 9,
|
@@ -642,10 +642,10 @@ self._package_spec_indicies = [
|
|
642
642
|
]
|
643
643
|
|
644
644
|
class << self
|
645
|
-
attr_accessor :
|
646
|
-
private :
|
645
|
+
attr_accessor :_declare_trans_targs
|
646
|
+
private :_declare_trans_targs, :_declare_trans_targs=
|
647
647
|
end
|
648
|
-
self.
|
648
|
+
self._declare_trans_targs = [
|
649
649
|
183, 0, 1, 3, 6, 166, 2, 4,
|
650
650
|
5, 7, 8, 38, 40, 9, 37, 43,
|
651
651
|
84, 93, 108, 127, 9, 10, 185, 11,
|
@@ -687,10 +687,10 @@ self._package_spec_trans_targs = [
|
|
687
687
|
]
|
688
688
|
|
689
689
|
class << self
|
690
|
-
attr_accessor :
|
691
|
-
private :
|
690
|
+
attr_accessor :_declare_trans_actions
|
691
|
+
private :_declare_trans_actions, :_declare_trans_actions=
|
692
692
|
end
|
693
|
-
self.
|
693
|
+
self._declare_trans_actions = [
|
694
694
|
35, 0, 0, 0, 0, 0, 0, 0,
|
695
695
|
0, 0, 0, 0, 0, 1, 1, 1,
|
696
696
|
1, 1, 1, 1, 0, 0, 95, 3,
|
@@ -732,10 +732,10 @@ self._package_spec_trans_actions = [
|
|
732
732
|
]
|
733
733
|
|
734
734
|
class << self
|
735
|
-
attr_accessor :
|
736
|
-
private :
|
735
|
+
attr_accessor :_declare_to_state_actions
|
736
|
+
private :_declare_to_state_actions, :_declare_to_state_actions=
|
737
737
|
end
|
738
|
-
self.
|
738
|
+
self._declare_to_state_actions = [
|
739
739
|
0, 0, 0, 0, 0, 0, 0, 0,
|
740
740
|
0, 0, 0, 0, 0, 0, 0, 0,
|
741
741
|
0, 0, 0, 0, 0, 0, 0, 0,
|
@@ -769,10 +769,10 @@ self._package_spec_to_state_actions = [
|
|
769
769
|
]
|
770
770
|
|
771
771
|
class << self
|
772
|
-
attr_accessor :
|
773
|
-
private :
|
772
|
+
attr_accessor :_declare_from_state_actions
|
773
|
+
private :_declare_from_state_actions, :_declare_from_state_actions=
|
774
774
|
end
|
775
|
-
self.
|
775
|
+
self._declare_from_state_actions = [
|
776
776
|
0, 0, 0, 0, 0, 0, 0, 0,
|
777
777
|
0, 0, 0, 0, 0, 0, 0, 0,
|
778
778
|
0, 0, 0, 0, 0, 0, 0, 0,
|
@@ -806,10 +806,10 @@ self._package_spec_from_state_actions = [
|
|
806
806
|
]
|
807
807
|
|
808
808
|
class << self
|
809
|
-
attr_accessor :
|
810
|
-
private :
|
809
|
+
attr_accessor :_declare_eof_trans
|
810
|
+
private :_declare_eof_trans, :_declare_eof_trans=
|
811
811
|
end
|
812
|
-
self.
|
812
|
+
self._declare_eof_trans = [
|
813
813
|
1, 1, 1, 1, 1, 1, 1, 1,
|
814
814
|
1, 1, 1, 1, 1, 1, 1, 1,
|
815
815
|
1, 1, 1, 1, 1, 1, 1, 1,
|
@@ -843,39 +843,39 @@ self._package_spec_eof_trans = [
|
|
843
843
|
]
|
844
844
|
|
845
845
|
class << self
|
846
|
-
attr_accessor :
|
846
|
+
attr_accessor :declare_start
|
847
847
|
end
|
848
|
-
self.
|
848
|
+
self.declare_start = 183;
|
849
849
|
class << self
|
850
|
-
attr_accessor :
|
850
|
+
attr_accessor :declare_first_final
|
851
851
|
end
|
852
|
-
self.
|
852
|
+
self.declare_first_final = 183;
|
853
853
|
class << self
|
854
|
-
attr_accessor :
|
854
|
+
attr_accessor :declare_error
|
855
855
|
end
|
856
|
-
self.
|
856
|
+
self.declare_error = -1;
|
857
857
|
|
858
858
|
class << self
|
859
|
-
attr_accessor :
|
859
|
+
attr_accessor :declare_en_main
|
860
860
|
end
|
861
|
-
self.
|
861
|
+
self.declare_en_main = 183;
|
862
862
|
|
863
863
|
|
864
|
-
# line 68 "lib/vorax/parser/grammars/
|
864
|
+
# line 68 "lib/vorax/parser/grammars/declare.rl"
|
865
865
|
|
866
|
-
# line 867 "lib/vorax/parser/grammars/
|
866
|
+
# line 867 "lib/vorax/parser/grammars/declare.rb"
|
867
867
|
begin
|
868
868
|
p ||= 0
|
869
869
|
pe ||= data.length
|
870
|
-
cs =
|
870
|
+
cs = declare_start
|
871
871
|
ts = nil
|
872
872
|
te = nil
|
873
873
|
act = 0
|
874
874
|
end
|
875
875
|
|
876
|
-
# line 69 "lib/vorax/parser/grammars/
|
876
|
+
# line 69 "lib/vorax/parser/grammars/declare.rl"
|
877
877
|
|
878
|
-
# line 879 "lib/vorax/parser/grammars/
|
878
|
+
# line 879 "lib/vorax/parser/grammars/declare.rb"
|
879
879
|
begin
|
880
880
|
_klen, _trans, _keys, _acts, _nacts = nil
|
881
881
|
_goto_level = 0
|
@@ -893,27 +893,27 @@ begin
|
|
893
893
|
end
|
894
894
|
end
|
895
895
|
if _goto_level <= _resume
|
896
|
-
_acts =
|
897
|
-
_nacts =
|
896
|
+
_acts = _declare_from_state_actions[cs]
|
897
|
+
_nacts = _declare_actions[_acts]
|
898
898
|
_acts += 1
|
899
899
|
while _nacts > 0
|
900
900
|
_nacts -= 1
|
901
901
|
_acts += 1
|
902
|
-
case
|
902
|
+
case _declare_actions[_acts - 1]
|
903
903
|
when 3 then
|
904
904
|
# line 1 "NONE"
|
905
905
|
begin
|
906
906
|
ts = p
|
907
907
|
end
|
908
|
-
# line 909 "lib/vorax/parser/grammars/
|
908
|
+
# line 909 "lib/vorax/parser/grammars/declare.rb"
|
909
909
|
end # from state action switch
|
910
910
|
end
|
911
911
|
if _trigger_goto
|
912
912
|
next
|
913
913
|
end
|
914
|
-
_keys =
|
915
|
-
_trans =
|
916
|
-
_klen =
|
914
|
+
_keys = _declare_key_offsets[cs]
|
915
|
+
_trans = _declare_index_offsets[cs]
|
916
|
+
_klen = _declare_single_lengths[cs]
|
917
917
|
_break_match = false
|
918
918
|
|
919
919
|
begin
|
@@ -925,9 +925,9 @@ ts = p
|
|
925
925
|
break if _upper < _lower
|
926
926
|
_mid = _lower + ( (_upper - _lower) >> 1 )
|
927
927
|
|
928
|
-
if data[p].ord <
|
928
|
+
if data[p].ord < _declare_trans_keys[_mid]
|
929
929
|
_upper = _mid - 1
|
930
|
-
elsif data[p].ord >
|
930
|
+
elsif data[p].ord > _declare_trans_keys[_mid]
|
931
931
|
_lower = _mid + 1
|
932
932
|
else
|
933
933
|
_trans += (_mid - _keys)
|
@@ -939,16 +939,16 @@ ts = p
|
|
939
939
|
_keys += _klen
|
940
940
|
_trans += _klen
|
941
941
|
end
|
942
|
-
_klen =
|
942
|
+
_klen = _declare_range_lengths[cs]
|
943
943
|
if _klen > 0
|
944
944
|
_lower = _keys
|
945
945
|
_upper = _keys + (_klen << 1) - 2
|
946
946
|
loop do
|
947
947
|
break if _upper < _lower
|
948
948
|
_mid = _lower + (((_upper-_lower) >> 1) & ~1)
|
949
|
-
if data[p].ord <
|
949
|
+
if data[p].ord < _declare_trans_keys[_mid]
|
950
950
|
_upper = _mid - 2
|
951
|
-
elsif data[p].ord >
|
951
|
+
elsif data[p].ord > _declare_trans_keys[_mid+1]
|
952
952
|
_lower = _mid + 2
|
953
953
|
else
|
954
954
|
_trans += ((_mid - _keys) >> 1)
|
@@ -960,26 +960,26 @@ ts = p
|
|
960
960
|
_trans += _klen
|
961
961
|
end
|
962
962
|
end while false
|
963
|
-
_trans =
|
963
|
+
_trans = _declare_indicies[_trans]
|
964
964
|
end
|
965
965
|
if _goto_level <= _eof_trans
|
966
|
-
cs =
|
967
|
-
if
|
968
|
-
_acts =
|
969
|
-
_nacts =
|
966
|
+
cs = _declare_trans_targs[_trans]
|
967
|
+
if _declare_trans_actions[_trans] != 0
|
968
|
+
_acts = _declare_trans_actions[_trans]
|
969
|
+
_nacts = _declare_actions[_acts]
|
970
970
|
_acts += 1
|
971
971
|
while _nacts > 0
|
972
972
|
_nacts -= 1
|
973
973
|
_acts += 1
|
974
|
-
case
|
974
|
+
case _declare_actions[_acts - 1]
|
975
975
|
when 0 then
|
976
|
-
# line 7 "lib/vorax/parser/grammars/
|
976
|
+
# line 7 "lib/vorax/parser/grammars/declare.rl"
|
977
977
|
begin
|
978
978
|
|
979
979
|
@start = p
|
980
980
|
end
|
981
981
|
when 1 then
|
982
|
-
# line 11 "lib/vorax/parser/grammars/
|
982
|
+
# line 11 "lib/vorax/parser/grammars/declare.rl"
|
983
983
|
begin
|
984
984
|
|
985
985
|
@end = p - 1
|
@@ -990,121 +990,121 @@ when 4 then
|
|
990
990
|
te = p+1
|
991
991
|
end
|
992
992
|
when 5 then
|
993
|
-
# line 28 "lib/vorax/parser/grammars/
|
993
|
+
# line 28 "lib/vorax/parser/grammars/declare.rl"
|
994
994
|
begin
|
995
995
|
act = 1; end
|
996
996
|
when 6 then
|
997
|
-
# line 30 "lib/vorax/parser/grammars/
|
997
|
+
# line 30 "lib/vorax/parser/grammars/declare.rl"
|
998
998
|
begin
|
999
999
|
act = 3; end
|
1000
1000
|
when 7 then
|
1001
|
-
# line 31 "lib/vorax/parser/grammars/
|
1001
|
+
# line 31 "lib/vorax/parser/grammars/declare.rl"
|
1002
1002
|
begin
|
1003
1003
|
act = 4; end
|
1004
1004
|
when 8 then
|
1005
|
-
# line 32 "lib/vorax/parser/grammars/
|
1005
|
+
# line 32 "lib/vorax/parser/grammars/declare.rl"
|
1006
1006
|
begin
|
1007
1007
|
act = 5; end
|
1008
1008
|
when 9 then
|
1009
|
-
# line 33 "lib/vorax/parser/grammars/
|
1009
|
+
# line 33 "lib/vorax/parser/grammars/declare.rl"
|
1010
1010
|
begin
|
1011
1011
|
act = 6; end
|
1012
1012
|
when 10 then
|
1013
|
-
# line 34 "lib/vorax/parser/grammars/
|
1013
|
+
# line 34 "lib/vorax/parser/grammars/declare.rl"
|
1014
1014
|
begin
|
1015
1015
|
act = 7; end
|
1016
1016
|
when 11 then
|
1017
|
-
# line 35 "lib/vorax/parser/grammars/
|
1017
|
+
# line 35 "lib/vorax/parser/grammars/declare.rl"
|
1018
1018
|
begin
|
1019
1019
|
act = 8; end
|
1020
1020
|
when 12 then
|
1021
|
-
# line 36 "lib/vorax/parser/grammars/
|
1021
|
+
# line 36 "lib/vorax/parser/grammars/declare.rl"
|
1022
1022
|
begin
|
1023
1023
|
act = 9; end
|
1024
1024
|
when 13 then
|
1025
|
-
# line 37 "lib/vorax/parser/grammars/
|
1025
|
+
# line 37 "lib/vorax/parser/grammars/declare.rl"
|
1026
1026
|
begin
|
1027
1027
|
act = 10; end
|
1028
1028
|
when 14 then
|
1029
|
-
# line 38 "lib/vorax/parser/grammars/
|
1029
|
+
# line 38 "lib/vorax/parser/grammars/declare.rl"
|
1030
1030
|
begin
|
1031
1031
|
act = 11; end
|
1032
1032
|
when 15 then
|
1033
|
-
# line 29 "lib/vorax/parser/grammars/
|
1033
|
+
# line 29 "lib/vorax/parser/grammars/declare.rl"
|
1034
1034
|
begin
|
1035
1035
|
te = p+1
|
1036
1036
|
end
|
1037
1037
|
when 16 then
|
1038
|
-
# line 31 "lib/vorax/parser/grammars/
|
1038
|
+
# line 31 "lib/vorax/parser/grammars/declare.rl"
|
1039
1039
|
begin
|
1040
1040
|
te = p+1
|
1041
1041
|
begin @constants.add(data[(@start..@end)]) end
|
1042
1042
|
end
|
1043
1043
|
when 17 then
|
1044
|
-
# line 32 "lib/vorax/parser/grammars/
|
1044
|
+
# line 32 "lib/vorax/parser/grammars/declare.rl"
|
1045
1045
|
begin
|
1046
1046
|
te = p+1
|
1047
1047
|
begin @exceptions.add(data[(@start..@end)]) end
|
1048
1048
|
end
|
1049
1049
|
when 18 then
|
1050
|
-
# line 38 "lib/vorax/parser/grammars/
|
1050
|
+
# line 38 "lib/vorax/parser/grammars/declare.rl"
|
1051
1051
|
begin
|
1052
1052
|
te = p+1
|
1053
1053
|
end
|
1054
1054
|
when 19 then
|
1055
|
-
# line 28 "lib/vorax/parser/grammars/
|
1055
|
+
# line 28 "lib/vorax/parser/grammars/declare.rl"
|
1056
1056
|
begin
|
1057
1057
|
te = p
|
1058
1058
|
p = p - 1; end
|
1059
1059
|
when 20 then
|
1060
|
-
# line 31 "lib/vorax/parser/grammars/
|
1060
|
+
# line 31 "lib/vorax/parser/grammars/declare.rl"
|
1061
1061
|
begin
|
1062
1062
|
te = p
|
1063
1063
|
p = p - 1; begin @constants.add(data[(@start..@end)]) end
|
1064
1064
|
end
|
1065
1065
|
when 21 then
|
1066
|
-
# line 32 "lib/vorax/parser/grammars/
|
1066
|
+
# line 32 "lib/vorax/parser/grammars/declare.rl"
|
1067
1067
|
begin
|
1068
1068
|
te = p
|
1069
1069
|
p = p - 1; begin @exceptions.add(data[(@start..@end)]) end
|
1070
1070
|
end
|
1071
1071
|
when 22 then
|
1072
|
-
# line 33 "lib/vorax/parser/grammars/
|
1072
|
+
# line 33 "lib/vorax/parser/grammars/declare.rl"
|
1073
1073
|
begin
|
1074
1074
|
te = p
|
1075
1075
|
p = p - 1; begin @cursors.add(data[(@start..@end)]) end
|
1076
1076
|
end
|
1077
1077
|
when 23 then
|
1078
|
-
# line 34 "lib/vorax/parser/grammars/
|
1078
|
+
# line 34 "lib/vorax/parser/grammars/declare.rl"
|
1079
1079
|
begin
|
1080
1080
|
te = p
|
1081
1081
|
p = p - 1; begin @types.add(data[(@start..@end)]) end
|
1082
1082
|
end
|
1083
1083
|
when 24 then
|
1084
|
-
# line 35 "lib/vorax/parser/grammars/
|
1084
|
+
# line 35 "lib/vorax/parser/grammars/declare.rl"
|
1085
1085
|
begin
|
1086
1086
|
te = p
|
1087
1087
|
p = p - 1; begin @variables.add(data[(@start..@end)]) end
|
1088
1088
|
end
|
1089
1089
|
when 25 then
|
1090
|
-
# line 36 "lib/vorax/parser/grammars/
|
1090
|
+
# line 36 "lib/vorax/parser/grammars/declare.rl"
|
1091
1091
|
begin
|
1092
1092
|
te = p
|
1093
1093
|
p = p - 1; begin @functions.add(data[(@start..@end)]) end
|
1094
1094
|
end
|
1095
1095
|
when 26 then
|
1096
|
-
# line 37 "lib/vorax/parser/grammars/
|
1096
|
+
# line 37 "lib/vorax/parser/grammars/declare.rl"
|
1097
1097
|
begin
|
1098
1098
|
te = p
|
1099
1099
|
p = p - 1; begin @procedures.add(data[(@start..@end)]) end
|
1100
1100
|
end
|
1101
1101
|
when 27 then
|
1102
|
-
# line 38 "lib/vorax/parser/grammars/
|
1102
|
+
# line 38 "lib/vorax/parser/grammars/declare.rl"
|
1103
1103
|
begin
|
1104
1104
|
te = p
|
1105
1105
|
p = p - 1; end
|
1106
1106
|
when 28 then
|
1107
|
-
# line 38 "lib/vorax/parser/grammars/
|
1107
|
+
# line 38 "lib/vorax/parser/grammars/declare.rl"
|
1108
1108
|
begin
|
1109
1109
|
begin p = ((te))-1; end
|
1110
1110
|
end
|
@@ -1141,7 +1141,7 @@ end
|
|
1141
1141
|
end
|
1142
1142
|
end
|
1143
1143
|
end
|
1144
|
-
# line 1145 "lib/vorax/parser/grammars/
|
1144
|
+
# line 1145 "lib/vorax/parser/grammars/declare.rb"
|
1145
1145
|
end # action switch
|
1146
1146
|
end
|
1147
1147
|
end
|
@@ -1150,18 +1150,18 @@ end
|
|
1150
1150
|
end
|
1151
1151
|
end
|
1152
1152
|
if _goto_level <= _again
|
1153
|
-
_acts =
|
1154
|
-
_nacts =
|
1153
|
+
_acts = _declare_to_state_actions[cs]
|
1154
|
+
_nacts = _declare_actions[_acts]
|
1155
1155
|
_acts += 1
|
1156
1156
|
while _nacts > 0
|
1157
1157
|
_nacts -= 1
|
1158
1158
|
_acts += 1
|
1159
|
-
case
|
1159
|
+
case _declare_actions[_acts - 1]
|
1160
1160
|
when 2 then
|
1161
1161
|
# line 1 "NONE"
|
1162
1162
|
begin
|
1163
1163
|
ts = nil; end
|
1164
|
-
# line 1165 "lib/vorax/parser/grammars/
|
1164
|
+
# line 1165 "lib/vorax/parser/grammars/declare.rb"
|
1165
1165
|
end # to state action switch
|
1166
1166
|
end
|
1167
1167
|
if _trigger_goto
|
@@ -1175,8 +1175,8 @@ ts = nil; end
|
|
1175
1175
|
end
|
1176
1176
|
if _goto_level <= _test_eof
|
1177
1177
|
if p == eof
|
1178
|
-
if
|
1179
|
-
_trans =
|
1178
|
+
if _declare_eof_trans[cs] > 0
|
1179
|
+
_trans = _declare_eof_trans[cs] - 1;
|
1180
1180
|
_goto_level = _eof_trans
|
1181
1181
|
next;
|
1182
1182
|
end
|
@@ -1188,7 +1188,7 @@ end
|
|
1188
1188
|
end
|
1189
1189
|
end
|
1190
1190
|
|
1191
|
-
# line 70 "lib/vorax/parser/grammars/
|
1191
|
+
# line 70 "lib/vorax/parser/grammars/declare.rl"
|
1192
1192
|
end
|
1193
1193
|
end
|
1194
1194
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
%%{
|
2
2
|
|
3
|
-
machine
|
3
|
+
machine declare;
|
4
4
|
|
5
5
|
include common "common.rl";
|
6
6
|
|
@@ -47,7 +47,7 @@ module Vorax
|
|
47
47
|
module Parser
|
48
48
|
|
49
49
|
# A class used to parse a PLSQL package spec.
|
50
|
-
class
|
50
|
+
class Declare
|
51
51
|
|
52
52
|
attr_reader :constants, :types, :exceptions, :cursors, :variables, :functions, :procedures
|
53
53
|
|
@@ -74,9 +74,9 @@ module Vorax
|
|
74
74
|
inspector = StmtInspector.new(statement)
|
75
75
|
columns_data = inspector.query_fields
|
76
76
|
columns_data.each do |column|
|
77
|
-
if column =~ /([a-z0-9
|
77
|
+
if column =~ /([a-z0-9#$\_]+\.)?\*/i
|
78
78
|
#might be an alias
|
79
|
-
alias_name = column[/[a-z0-9
|
79
|
+
alias_name = column[/[a-z0-9#$\_]+/i]
|
80
80
|
ds = []
|
81
81
|
if alias_name
|
82
82
|
src = inspector.data_source.find do |r|
|
data/lib/vorax/version.rb
CHANGED
@@ -7,7 +7,7 @@ describe 'package_spec' do
|
|
7
7
|
|
8
8
|
it 'should work with a simple package' do
|
9
9
|
text = File.open("spec/sql/muci.spc", 'rb') { |file| file.read }
|
10
|
-
parser = Vorax::Parser::
|
10
|
+
parser = Vorax::Parser::Declare.new
|
11
11
|
parser.walk(text)
|
12
12
|
|
13
13
|
parser.constants.should eq(Set.new(["MY_CONSTANT1", "MY_CONSTANT2"]))
|
@@ -21,7 +21,7 @@ describe 'package_spec' do
|
|
21
21
|
|
22
22
|
it 'should work with a big package spec' do
|
23
23
|
text = File.open('spec/sql/dbms_stats.spc', 'rb') { |file| file.read }
|
24
|
-
parser = Vorax::Parser::
|
24
|
+
parser = Vorax::Parser::Declare.new
|
25
25
|
parser.walk(text)
|
26
26
|
parser.constants.should eq(Set.new(["AUTO_CASCADE", "AUTO_INVALIDATE", "AUTO_SAMPLE_SIZE", "DEFAULT_DEGREE", "AUTO_DEGREE", "DEFAULT_CASCADE", "DEFAULT_DEGREE_VALUE", "DEFAULT_ESTIMATE_PERCENT", "DEFAULT_METHOD_OPT", "DEFAULT_NO_INVALIDATE", "DEFAULT_GRANULARITY", "DEFAULT_PUBLISH", "DEFAULT_INCREMENTAL", "DEFAULT_STALE_PERCENT", "DEFAULT_AUTOSTATS_TARGET", "DEFAULT_STAT_CATEGORY", "PURGE_ALL"]))
|
27
27
|
parser.exceptions.should eq(Set.new([]))
|
@@ -34,7 +34,7 @@ describe 'package_spec' do
|
|
34
34
|
|
35
35
|
it 'should work with a SYS package spec' do
|
36
36
|
text = File.open('spec/sql/dbms_crypto.spc', 'rb') { |file| file.read }
|
37
|
-
parser = Vorax::Parser::
|
37
|
+
parser = Vorax::Parser::Declare.new
|
38
38
|
parser.walk(text)
|
39
39
|
parser.constants.should eq(Set.new(["HASH_MD4", "HASH_MD5", "HASH_SH1", "HMAC_MD5", "HMAC_SH1", "ENCRYPT_DES", "ENCRYPT_3DES_2KEY", "ENCRYPT_3DES", "ENCRYPT_AES", "ENCRYPT_PBE_MD5DES", "ENCRYPT_AES128", "ENCRYPT_AES192", "ENCRYPT_AES256", "CHAIN_CBC", "CHAIN_CFB", "CHAIN_ECB", "CHAIN_OFB", "PAD_PKCS5", "PAD_NONE", "PAD_ZERO", "PAD_ORCL", "ENCRYPT_RC4", "DES_CBC_PKCS5", "DES3_CBC_PKCS5", "AES_CBC_PKCS5"]))
|
40
40
|
parser.exceptions.should eq(Set.new(["CipherSuiteInvalid", "CipherSuiteNull", "KeyNull", "KeyBadSize", "DoubleEncryption"]))
|
@@ -28,25 +28,30 @@ describe 'plsql structure' do
|
|
28
28
|
text = File.open('spec/sql/test.pkg', 'rb') { |file| file.read }
|
29
29
|
structure = Parser::PlsqlStructure.new(text)
|
30
30
|
compute_tree(structure.tree)
|
31
|
-
puts @result
|
32
|
-
=begin
|
33
31
|
@result.should eq(<<STR
|
34
32
|
* root - -> begin=
|
35
33
|
|---+ test[SPEC]: 25 - 154 -> begin=0
|
36
34
|
| |---> test[PROCEDURE]: 61 - 61 -> begin=0
|
37
35
|
| +---> muci[FUNCTION]: 91 - 91 -> begin=0
|
38
|
-
+---+ test[BODY]: 180 -
|
39
|
-
|---+ private_proc[PROCEDURE]: 232 -
|
36
|
+
+---+ test[BODY]: 180 - 1672 -> begin=1635
|
37
|
+
|---+ private_proc[PROCEDURE]: 232 - 1373 -> begin=454
|
40
38
|
| |---> abc[FUNCTION]: 325 - 392 -> begin=360
|
41
|
-
|
|
42
|
-
|
43
|
-
|
|
44
|
-
|
39
|
+
| |---> xyz[PROCEDURE]: 403 - 449 -> begin=424
|
40
|
+
| |---+ for[FOR_BLOCK]: 485 - 1042 -> begin=530
|
41
|
+
| |---> if[IF_BLOCK]: 563 - 636 -> begin=564
|
42
|
+
| +---+ if[IF_BLOCK]: 645 - 1016 -> begin=646
|
43
|
+
|---+ if[IF_BLOCK]: 667 - 924 -> begin=668
|
44
|
+
| +---> for[FOR_BLOCK]: 691 - 858 -> begin=736
|
45
|
+
+---> if[IF_BLOCK]: 935 - 1002 -> begin=936
|
46
|
+
| |---> if[IF_BLOCK]: 1088 - 1167 -> begin=1089
|
47
|
+
| +---> loop[LOOP_BLOCK]: 1223 - 1318 -> begin=1224
|
48
|
+
|---+ test[PROCEDURE]: 1378 - 1544 -> begin=1410
|
49
|
+
| +---> anonymous[BLOCK]: 1466 - 1537 -> begin=1461
|
50
|
+
+---> muci[FUNCTION]: 1549 - 1632 -> begin=1603
|
45
51
|
STR
|
46
52
|
)
|
47
|
-
=end
|
48
53
|
end# }}}
|
49
|
-
|
54
|
+
|
50
55
|
it 'should work for a function' do# {{{
|
51
56
|
text = File.open('spec/sql/test.fnc', 'rb') { |file| file.read }
|
52
57
|
structure = Parser::PlsqlStructure.new(text)
|
@@ -58,6 +63,6 @@ STR
|
|
58
63
|
STR
|
59
64
|
)
|
60
65
|
end# }}}
|
61
|
-
|
66
|
+
|
62
67
|
end
|
63
68
|
|
data/spec/sql/test.pkg
CHANGED
data/spec/stmt_inspector_spec.rb
CHANGED
@@ -5,6 +5,18 @@ include Parser
|
|
5
5
|
|
6
6
|
describe 'stmt_inspector' do
|
7
7
|
|
8
|
+
it 'should work with delete statements' do
|
9
|
+
text = "\n delete from bskcmptre d where itmidn = d.\n end loop;"
|
10
|
+
inspector = StmtInspector.new(text)
|
11
|
+
inspector.find_alias('d', 0).columns.should == ['bskcmptre.*']
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should work with hierarchical queries' do
|
15
|
+
text = "select * from (select level as lvl, bskcmptre_tbl.*\n from bskcmptre_tbl\n start with itmidn = pi_nodidn\n connect by prior itmidn = bskprnidn\n order by itmidn desc) v_crtrec"
|
16
|
+
inspector = StmtInspector.new(text)
|
17
|
+
inspector.find_alias('v_crtrec', 0).columns.should == ["lvl", "bskcmptre_tbl.*"]
|
18
|
+
end
|
19
|
+
|
8
20
|
it 'should work with a complex query' do# {{{
|
9
21
|
text = '
|
10
22
|
with
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vorax
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -104,10 +104,10 @@ files:
|
|
104
104
|
- lib/vorax/parser/grammars/column.rb
|
105
105
|
- lib/vorax/parser/grammars/column.rl
|
106
106
|
- lib/vorax/parser/grammars/common.rl
|
107
|
+
- lib/vorax/parser/grammars/declare.rb
|
108
|
+
- lib/vorax/parser/grammars/declare.rl
|
107
109
|
- lib/vorax/parser/grammars/for_block.rb
|
108
110
|
- lib/vorax/parser/grammars/for_block.rl
|
109
|
-
- lib/vorax/parser/grammars/package_spec.rb
|
110
|
-
- lib/vorax/parser/grammars/package_spec.rl
|
111
111
|
- lib/vorax/parser/grammars/plsql_def.rb
|
112
112
|
- lib/vorax/parser/grammars/plsql_def.rl
|
113
113
|
- lib/vorax/parser/grammars/statement.rb
|
@@ -123,7 +123,7 @@ files:
|
|
123
123
|
- lib/vorax/vorax_io.rb
|
124
124
|
- spec/column_spec.rb
|
125
125
|
- spec/conn_string_spec.rb
|
126
|
-
- spec/
|
126
|
+
- spec/declare_spec.rb
|
127
127
|
- spec/pagezip_spec.rb
|
128
128
|
- spec/parser_spec.rb
|
129
129
|
- spec/plsql_structure_spec.rb
|
@@ -169,7 +169,7 @@ summary: Vorax ruby code companion.
|
|
169
169
|
test_files:
|
170
170
|
- spec/column_spec.rb
|
171
171
|
- spec/conn_string_spec.rb
|
172
|
-
- spec/
|
172
|
+
- spec/declare_spec.rb
|
173
173
|
- spec/pagezip_spec.rb
|
174
174
|
- spec/parser_spec.rb
|
175
175
|
- spec/plsql_structure_spec.rb
|