tsql_parser 0.0.7 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/parsing/model/flat_sql_container.rb +5 -13
- data/lib/parsing/tokenizer.rb +11 -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: 3e2633fba3d6e5113119872e1fad4618da4a7f404436e2e5d86137ae82516db3
|
4
|
+
data.tar.gz: a27d777e1a54c8eba9803158b121d7c74b39ca004d4d0e49b242194f9095e125
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71667cfc1e258bcf400ce64af5a5f49747eec77e4fa4399444bc7f2b41e1757a2dc920b7273564fbf7b430928299bbf5f2a06074c6ed5e786baae44774051e2b
|
7
|
+
data.tar.gz: 7dc006e6d915670337661dd6829e95942984d48d6ddc28ebfc3ae6332a348337fbd629fa50da81882ac2a717e9a9bf9c17507b93b8db69bb4a26ed7e2ba9094c
|
@@ -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,16 @@ 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
|
+
specific_tokens << builder unless builder.empty?
|
110
|
+
builder = ""
|
111
|
+
comment = false
|
112
|
+
next
|
113
|
+
end
|
114
|
+
|
105
115
|
if c == "'" and not multiline_comment and not comment
|
106
116
|
if not string
|
107
117
|
string = true
|
@@ -125,17 +135,7 @@ module TSqlParser::Parsing
|
|
125
135
|
next
|
126
136
|
end
|
127
137
|
|
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
|
138
|
+
if delimiters.include? c and !multiline_comment and !string and !comment
|
139
139
|
specific_tokens << builder unless builder.empty?
|
140
140
|
specific_tokens << c unless skip_delimiters.include? c
|
141
141
|
builder = ""
|