rubyang 0.1.1 → 0.1.2
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 +5 -5
- data/.travis.yml +13 -2
- data/README.md +2 -3
- data/lib/rubyang/database/data_tree.rb +494 -130
- data/lib/rubyang/database/schema_tree.rb +541 -293
- data/lib/rubyang/database.rb +10 -0
- data/lib/rubyang/logger.rb +19 -0
- data/lib/rubyang/model/parser/parser.tab.rb +919 -901
- data/lib/rubyang/model/parser/parser.y +9 -1
- data/lib/rubyang/model/parser.rb +48 -18
- data/lib/rubyang/model.rb +16 -1
- data/lib/rubyang/version.rb +1 -1
- data/lib/rubyang/xpath/parser/parser.tab.rb +561 -548
- data/lib/rubyang/xpath/parser/parser.y +74 -78
- data/lib/rubyang/xpath/parser.rb +12 -2
- data/lib/rubyang/xpath.rb +342 -105
- data/lib/rubyang.rb +1 -0
- data/rubyang.gemspec +2 -2
- metadata +8 -7
@@ -442,6 +442,14 @@ rule
|
|
442
442
|
{
|
443
443
|
result = [val[0]]
|
444
444
|
}
|
445
|
+
| "fraction-digits-stmt" "range-stmt"
|
446
|
+
{
|
447
|
+
result = [val[0], val[1]]
|
448
|
+
}
|
449
|
+
| "range-stmt" "fraction-digits-stmt"
|
450
|
+
{
|
451
|
+
result = [val[1], val[0]]
|
452
|
+
}
|
445
453
|
|
446
454
|
"fraction-digits-stmt" : "fraction-digits-keyword" "fraction-digits-arg-str" "stmtend"
|
447
455
|
{
|
@@ -1433,7 +1441,7 @@ rule
|
|
1433
1441
|
|
1434
1442
|
"integer-value" : "string"
|
1435
1443
|
{
|
1436
|
-
unless /^[1-9][0-9]
|
1444
|
+
unless /^[0-9]|[1-9][0-9]+$/ =~ val[0]
|
1437
1445
|
raise ParseError, "bad integer-value, but '#{val[0]}'"
|
1438
1446
|
end
|
1439
1447
|
result = val[0]
|
data/lib/rubyang/model/parser.rb
CHANGED
@@ -129,18 +129,22 @@ module Rubyang
|
|
129
129
|
|
130
130
|
scanre = Regexp.union( scanre_list.map{ |scanre| scanre[1] } )
|
131
131
|
|
132
|
+
next_to_kw = false
|
132
133
|
until s.eos?
|
133
134
|
token = s.scan( scanre )
|
134
135
|
#p token
|
135
136
|
case token
|
136
|
-
when scanres["slcomment"] then
|
137
|
-
|
137
|
+
when scanres["slcomment"] then
|
138
|
+
;
|
139
|
+
when scanres["blcomment"] then
|
140
|
+
;
|
138
141
|
when scanres["dqstr"] then
|
139
142
|
token_ = token.gsub(/^"/,'').gsub(/"$/,'').gsub(/\\n/,"\n").gsub(/\\t/,"\t").gsub(/\\"/,"\"").gsub(/\\\\/,"\\")
|
140
143
|
#if 0 == (token_ =~ URI.regexp)
|
141
144
|
#@tokens.push [:URI, token_]
|
142
145
|
#else
|
143
146
|
@tokens.push [:STRING, token_]
|
147
|
+
next_to_kw = false
|
144
148
|
#end
|
145
149
|
when scanres["sqstr"] then
|
146
150
|
token_ = token.gsub(/^'/,'').gsub(/'$/,'')
|
@@ -149,24 +153,50 @@ module Rubyang
|
|
149
153
|
#else @tokens.push [:STRING, token_]
|
150
154
|
#end
|
151
155
|
@tokens.push [:STRING, token_]
|
156
|
+
next_to_kw = false
|
152
157
|
when scanres["nqstr"] then
|
153
|
-
|
154
|
-
|
155
|
-
|
158
|
+
if (! next_to_kw) and keywords.values.include?(token)
|
159
|
+
@tokens.push [keywords.key(token), token]
|
160
|
+
next_to_kw = true
|
161
|
+
else
|
162
|
+
@tokens.push [:STRING, token]
|
163
|
+
next_to_kw = false
|
156
164
|
end
|
157
|
-
when scanres["+"]
|
158
|
-
|
159
|
-
|
160
|
-
when scanres["
|
161
|
-
|
162
|
-
|
163
|
-
when scanres["
|
164
|
-
|
165
|
-
|
166
|
-
when scanres["
|
167
|
-
|
168
|
-
|
169
|
-
|
165
|
+
when scanres["+"] then
|
166
|
+
@tokens.push ["+", token]
|
167
|
+
next_to_kw = false
|
168
|
+
when scanres[";"] then
|
169
|
+
@tokens.push [";", token]
|
170
|
+
next_to_kw = false
|
171
|
+
when scanres[":"] then
|
172
|
+
@tokens.push [":", token]
|
173
|
+
next_to_kw = false
|
174
|
+
when scanres["/"] then
|
175
|
+
@tokens.push ["/", token]
|
176
|
+
next_to_kw = false
|
177
|
+
when scanres["|"] then
|
178
|
+
@tokens.push ["|", token]
|
179
|
+
next_to_kw = false
|
180
|
+
when scanres[".."] then
|
181
|
+
@tokens.push ["..", token]
|
182
|
+
next_to_kw = false
|
183
|
+
when scanres["="] then
|
184
|
+
@tokens.push ["=", token]
|
185
|
+
next_to_kw = false
|
186
|
+
when scanres["{"] then
|
187
|
+
@tokens.push ["{", token]
|
188
|
+
next_to_kw = false
|
189
|
+
when scanres["}"] then
|
190
|
+
@tokens.push ["}", token]
|
191
|
+
next_to_kw = false
|
192
|
+
when scanres["wsp"] then
|
193
|
+
; #@tokens.push [:WSP, token]
|
194
|
+
when scanres["newline"] then
|
195
|
+
; #@tokens.push [:NEWLINE, token]
|
196
|
+
when scanres["return"] then
|
197
|
+
; #@tokens.push [:RETURN, token]
|
198
|
+
else
|
199
|
+
raise "token not match to any scanres: #{token.inspect}"
|
170
200
|
end
|
171
201
|
end
|
172
202
|
|
data/lib/rubyang/model.rb
CHANGED
@@ -62,7 +62,7 @@ module Rubyang
|
|
62
62
|
}
|
63
63
|
# raise if received susstatements does not satisfy defined substatements' cardinality
|
64
64
|
self.substatements.each{ |k, v|
|
65
|
-
unless v.include? substmts.
|
65
|
+
unless v.include? substmts.count{ |s| StmtMap.find( s ).intern == k }
|
66
66
|
raise ArgumentError, "substatement #{StmtMap.find( k )} is not in #{self.class} #{k}'s cardinality"
|
67
67
|
end
|
68
68
|
}
|
@@ -74,6 +74,13 @@ module Rubyang
|
|
74
74
|
}
|
75
75
|
@substmts = substmts
|
76
76
|
end
|
77
|
+
def to_s parent=true
|
78
|
+
head, vars, tail = "#<#{self.class.to_s}:0x#{(self.object_id << 1).to_s(16).rjust(14,'0')} ", Array.new, ">"
|
79
|
+
if parent
|
80
|
+
vars.push "@substmts=#{@substmts.map{|s| s.to_s(false)}}"
|
81
|
+
end
|
82
|
+
head + vars.join(', ') + tail
|
83
|
+
end
|
77
84
|
def substmt substmt, strict: false
|
78
85
|
raise TypeError unless String === substmt
|
79
86
|
if strict
|
@@ -141,6 +148,14 @@ module Rubyang
|
|
141
148
|
raise ArgumentError, "Invalid Argument: '#{arg}'"
|
142
149
|
end
|
143
150
|
end
|
151
|
+
def to_s parent=true
|
152
|
+
head, vars, tail = "#<#{self.class.to_s}:0x#{(self.object_id << 1).to_s(16).rjust(14,'0')} ", Array.new, ">"
|
153
|
+
if parent
|
154
|
+
vars.push "@arg=#{@arg.to_s}"
|
155
|
+
vars.push "@substmts=#{@substmts.map{|s| s.to_s(false)}}"
|
156
|
+
end
|
157
|
+
head + vars.join(', ') + tail
|
158
|
+
end
|
144
159
|
def arg
|
145
160
|
@arg
|
146
161
|
end
|
data/lib/rubyang/version.rb
CHANGED