junoser 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.travis.yml +6 -4
- data/CHANGELOG.md +169 -75
- data/Gemfile.lock +30 -0
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/Rakefile +11 -3
- data/example/vmx-17.2R1.13.rb +42432 -42429
- data/junoser.gemspec +6 -2
- data/lib/junoser/development.rb +1 -0
- data/lib/junoser/display/config_store.rb +15 -15
- data/lib/junoser/display/enumerable.rb +35 -0
- data/lib/junoser/display.rb +3 -0
- data/lib/junoser/js_ruler.rb +334 -0
- data/lib/junoser/parser.rb +315 -308
- data/lib/junoser/ruler.rb +12 -3
- data/lib/junoser/squash.rb +9 -1
- data/lib/junoser/transformer.rb +8 -0
- data/lib/junoser/version.rb +1 -1
- data/lib/junoser/xsd/element.rb +13 -0
- data/lib/junoser/xsd/restriction.rb +9 -1
- metadata +7 -4
data/lib/junoser/ruler.rb
CHANGED
@@ -12,6 +12,7 @@ module Junoser
|
|
12
12
|
|
13
13
|
def rule
|
14
14
|
str = @rule.read
|
15
|
+
str = remove_comments(str)
|
15
16
|
str = process_reserved_element(str)
|
16
17
|
str = str.split(/\n/).map {|l| format(process_line(l)) }.join("\n")
|
17
18
|
end
|
@@ -19,6 +20,10 @@ module Junoser
|
|
19
20
|
|
20
21
|
private
|
21
22
|
|
23
|
+
def remove_comments(str)
|
24
|
+
str.gsub(%r(\s*/\*.*\*/), '')
|
25
|
+
end
|
26
|
+
|
22
27
|
def process_line(str)
|
23
28
|
return str if str =~ /^(.* do|end)$/
|
24
29
|
|
@@ -26,12 +31,12 @@ module Junoser
|
|
26
31
|
|
27
32
|
str.gsub!(/^(\s*)arg(\.as\(:\S+\))? \($/) { "#{$1}b(arg#$2," } # arg ( -> b(arg,
|
28
33
|
str.gsub!(/^(\s*)(str\(\S+\)) ([^ \t\n\r\f\(|,]+)(\.as\(:\S+\))?(,?)$/) { "#{$1}a(#$2, #$3)#$4#$5" } # str("foo") bar -> a(str("foo"), bar)
|
29
|
-
str.gsub!(/^(\s*)(str\(\S+\))
|
34
|
+
str.gsub!(/^(\s*)(str\(\S+\)) (enum)?\((.*)\)(,?)$/) { "#{$1}a(#$2, #$3#$4)#$5" } # str("foo") (a | b) -> a(str("foo"), a | b)
|
30
35
|
|
31
36
|
str.gsub!(/^(\s*)(str\(\S+\)) \($/) { "#{$1}b(#$2," } # str("foo") ( -> b(str("foo"),
|
32
|
-
str.gsub!(/^(\s*)(\(.*\))(\.as\(:\S\))? \($/) { "#{$1}b(#$2#$3," } # (a | b) ( -> b((a | b),
|
37
|
+
str.gsub!(/^(\s*)(enum)?(\(.*\))(\.as\(:\S\))? \($/) { "#{$1}b(#$2#$3#$4," } # (a | b) ( -> b((a | b),
|
33
38
|
str.gsub!(/^(\s*)(str\(\S+\)) ([^ \t\n\r\f\(|,]+) \($/) { "#{$1}b(a(#$2, #$3)," } # str("foo") bar ( -> b(a(str("foo"), bar),
|
34
|
-
str.gsub!(/^(\s*)(str\(\S+\))
|
39
|
+
str.gsub!(/^(\s*)(str\(\S+\)) (enum)?\((.*)\) \($/) { "#{$1}a(#$2, #$3#$4," } # str("foo") (a | b) ( -> a(str("foo"), a | b,
|
35
40
|
|
36
41
|
str
|
37
42
|
end
|
@@ -232,6 +237,10 @@ module Junoser
|
|
232
237
|
(c(*objects, arg) >> space.maybe).repeat(0)
|
233
238
|
end
|
234
239
|
|
240
|
+
def enum(object)
|
241
|
+
(object.as(:enum))
|
242
|
+
end
|
243
|
+
|
235
244
|
rule(:arg) { match('\\S').repeat(1) }
|
236
245
|
rule(:space) { match('\\s').repeat(1) }
|
237
246
|
rule(:any) { match('.').repeat(1) }
|
data/lib/junoser/squash.rb
CHANGED
@@ -42,6 +42,14 @@ module Junoser
|
|
42
42
|
rule(oneline: sequence(:strs)) do
|
43
43
|
strs.join(' ')
|
44
44
|
end
|
45
|
+
|
46
|
+
rule(enum: simple(:str)) do
|
47
|
+
str
|
48
|
+
end
|
49
|
+
|
50
|
+
rule(enum: sequence(:strs)) do
|
51
|
+
strs.join(' ')
|
52
|
+
end
|
45
53
|
end
|
46
54
|
|
47
55
|
class Squash
|
@@ -87,4 +95,4 @@ module Junoser
|
|
87
95
|
end
|
88
96
|
end
|
89
97
|
end
|
90
|
-
end
|
98
|
+
end
|
data/lib/junoser/transformer.rb
CHANGED
@@ -44,6 +44,14 @@ module Junoser
|
|
44
44
|
strs.join(' ')
|
45
45
|
end
|
46
46
|
|
47
|
+
rule(enum: simple(:str)) do
|
48
|
+
str.to_s.gsub("\n", ' ')
|
49
|
+
end
|
50
|
+
|
51
|
+
rule(enum: sequence(:strs)) do
|
52
|
+
strs.join(' ')
|
53
|
+
end
|
54
|
+
|
47
55
|
|
48
56
|
def self.remove_slash_asterisk(array)
|
49
57
|
open = array.index("arg(/*)\n")
|
data/lib/junoser/version.rb
CHANGED
data/lib/junoser/xsd/element.rb
CHANGED
@@ -86,6 +86,19 @@ module Junoser
|
|
86
86
|
'arg'
|
87
87
|
end
|
88
88
|
end
|
89
|
+
|
90
|
+
def format(header, content = nil, footer = nil)
|
91
|
+
if documentation
|
92
|
+
header += " /* #{documentation} */"
|
93
|
+
end
|
94
|
+
|
95
|
+
super(header, content, footer)
|
96
|
+
end
|
97
|
+
|
98
|
+
def documentation
|
99
|
+
@documentation ||= xml.xpath('./xsd:annotation/xsd:documentation').text
|
100
|
+
@documentation.empty? ? nil : @documentation
|
101
|
+
end
|
89
102
|
end
|
90
103
|
end
|
91
104
|
end
|
@@ -30,9 +30,17 @@ module Junoser
|
|
30
30
|
def to_s
|
31
31
|
return format('arg') if config.empty?
|
32
32
|
|
33
|
-
str =
|
33
|
+
str = enumeration? ? 'enum' : ''
|
34
|
+
str += '(' + config.map {|c| c.to_s.strip }.join(' | ') + ')'
|
34
35
|
format(str)
|
35
36
|
end
|
37
|
+
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def enumeration?
|
42
|
+
children.reject {|c| c.name != 'enumeration'}.empty?
|
43
|
+
end
|
36
44
|
end
|
37
45
|
end
|
38
46
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: junoser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shintaro Kojima
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parslet
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '2.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '2.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -93,6 +93,7 @@ files:
|
|
93
93
|
- ".travis.yml"
|
94
94
|
- CHANGELOG.md
|
95
95
|
- Gemfile
|
96
|
+
- Gemfile.lock
|
96
97
|
- LICENSE.txt
|
97
98
|
- README.md
|
98
99
|
- Rakefile
|
@@ -108,9 +109,11 @@ files:
|
|
108
109
|
- lib/junoser/development.rb
|
109
110
|
- lib/junoser/display.rb
|
110
111
|
- lib/junoser/display/config_store.rb
|
112
|
+
- lib/junoser/display/enumerable.rb
|
111
113
|
- lib/junoser/display/set.rb
|
112
114
|
- lib/junoser/display/structure.rb
|
113
115
|
- lib/junoser/input.rb
|
116
|
+
- lib/junoser/js_ruler.rb
|
114
117
|
- lib/junoser/parser.rb
|
115
118
|
- lib/junoser/ruler.rb
|
116
119
|
- lib/junoser/squash.rb
|