tsql_parser 0.0.7 → 0.0.8
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/lib/parsing/model/flat_sql_container.rb +5 -13
- data/lib/parsing/tokenizer.rb +12 -11
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75691620d6ff57a073073f7438189fb9858a74f06737872ac0d38994fd9293ba
|
4
|
+
data.tar.gz: a5f2bdf884135c00ca792a0f6e8b321d5959295836072c5a9a182f641eced85e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '058f424ea22ebcf1e84ce1dcd0dacec6360210ab145ef71946a30bd989b71463b373526aebe01ba1a0d0e42c3701c2ad42f1e14f8a993fe93ff68cecf4708745'
|
7
|
+
data.tar.gz: 1a405f6ae5c149dd653179979fa17f9db0fd64804e5ef60f6bfbc4d1e4521f526796aee807714619e1547019bc8aeebd3b248d05aaf7469d2f2d0e659f770610
|
@@ -18,12 +18,16 @@ module TSqlParser::Parsing
|
|
18
18
|
class FlatSqlContainer
|
19
19
|
def initialize(token = nil)
|
20
20
|
@token = token
|
21
|
-
@children = []
|
22
21
|
@siblings = []
|
23
22
|
|
24
23
|
unless token.nil?
|
25
24
|
if token.has_nodes?
|
26
25
|
token.get_nodes.each do |n|
|
26
|
+
if n.get_token[:comment]
|
27
|
+
comment_token = n.get_token
|
28
|
+
comment_token[:value] = "#{comment_token[:value]}\n"
|
29
|
+
n.set_token comment_token
|
30
|
+
end
|
27
31
|
@siblings << n
|
28
32
|
end
|
29
33
|
end
|
@@ -46,26 +50,14 @@ module TSqlParser::Parsing
|
|
46
50
|
@siblings << token
|
47
51
|
end
|
48
52
|
|
49
|
-
def add_child(token)
|
50
|
-
@children << SqlContainer.new(token)
|
51
|
-
end
|
52
|
-
|
53
53
|
def has_siblings?
|
54
54
|
@siblings.size > 0
|
55
55
|
end
|
56
56
|
|
57
|
-
def has_children?
|
58
|
-
@children.size > 0
|
59
|
-
end
|
60
|
-
|
61
57
|
def get_siblings
|
62
58
|
@siblings
|
63
59
|
end
|
64
60
|
|
65
|
-
def get_children
|
66
|
-
@children
|
67
|
-
end
|
68
|
-
|
69
61
|
def get_token
|
70
62
|
@token.get_token
|
71
63
|
end
|
data/lib/parsing/tokenizer.rb
CHANGED
@@ -102,6 +102,17 @@ module TSqlParser::Parsing
|
|
102
102
|
next
|
103
103
|
end
|
104
104
|
|
105
|
+
if comment and c != "\n"
|
106
|
+
builder << c
|
107
|
+
next
|
108
|
+
elsif comment and c == "\n"
|
109
|
+
puts "comment builder: #{builder}"
|
110
|
+
specific_tokens << builder unless builder.empty?
|
111
|
+
builder = ""
|
112
|
+
comment = false
|
113
|
+
next
|
114
|
+
end
|
115
|
+
|
105
116
|
if c == "'" and not multiline_comment and not comment
|
106
117
|
if not string
|
107
118
|
string = true
|
@@ -125,17 +136,7 @@ module TSqlParser::Parsing
|
|
125
136
|
next
|
126
137
|
end
|
127
138
|
|
128
|
-
if
|
129
|
-
builder << c
|
130
|
-
next
|
131
|
-
elsif comment and c == "\n"
|
132
|
-
specific_tokens << builder unless builder.empty?
|
133
|
-
builder = ""
|
134
|
-
comment = false
|
135
|
-
next
|
136
|
-
end
|
137
|
-
|
138
|
-
if delimiters.include? c and !multiline_comment and !string
|
139
|
+
if delimiters.include? c and !multiline_comment and !string and !comment
|
139
140
|
specific_tokens << builder unless builder.empty?
|
140
141
|
specific_tokens << c unless skip_delimiters.include? c
|
141
142
|
builder = ""
|