msgpack-idl 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +4 -0
- data/lib/msgpack/idl/ast.rb +164 -3
- data/lib/msgpack/idl/command/example.rb +64 -4
- data/lib/msgpack/idl/command/idl.rb +75 -42
- data/lib/msgpack/idl/command/vimcolor.rb +254 -0
- data/lib/msgpack/idl/command/vimcolor/mark.vim +67 -0
- data/lib/msgpack/idl/command/vimcolor/msgspec.vim +68 -0
- data/lib/msgpack/idl/error.rb +1 -1
- data/lib/msgpack/idl/evaluator.rb +283 -138
- data/lib/msgpack/idl/ir.rb +31 -6
- data/lib/msgpack/idl/parser/rule.rb +20 -3
- data/lib/msgpack/idl/parser/transform.rb +15 -18
- data/lib/msgpack/idl/version.rb +1 -1
- metadata +7 -4
data/lib/msgpack/idl/ir.rb
CHANGED
@@ -115,6 +115,11 @@ module IR
|
|
115
115
|
def map_type?
|
116
116
|
@generic_type == Primitive.map
|
117
117
|
end
|
118
|
+
|
119
|
+
def ==(o)
|
120
|
+
o.is_a?(ParameterizedType) && @generic_type == o.generic_type &&
|
121
|
+
@type_params == o.type_params
|
122
|
+
end
|
118
123
|
end
|
119
124
|
|
120
125
|
class TypeParameterSymbol
|
@@ -138,6 +143,11 @@ module IR
|
|
138
143
|
def map_type?
|
139
144
|
false
|
140
145
|
end
|
146
|
+
|
147
|
+
def ==(o)
|
148
|
+
o.is_a?(GenericType) && @name == o.name &&
|
149
|
+
@type_params.size == o.type_params.size
|
150
|
+
end
|
141
151
|
end
|
142
152
|
|
143
153
|
class PrimitiveGenericType < GenericType
|
@@ -342,32 +352,47 @@ module IR
|
|
342
352
|
@functions = funcs
|
343
353
|
end
|
344
354
|
attr_reader :version, :functions
|
355
|
+
attr_writer :functions
|
345
356
|
end
|
346
357
|
|
347
358
|
class Function
|
348
|
-
def initialize(name, return_type, args,
|
359
|
+
def initialize(name, return_type, args, exceptions)
|
349
360
|
@name = name
|
350
361
|
@return_type = return_type
|
351
362
|
@args = args
|
352
|
-
@
|
353
|
-
@super_func = super_func
|
363
|
+
@exceptions = exceptions
|
354
364
|
@max_id = @args.map {|a| a.id }.max || 0
|
355
365
|
@max_required_id = @args.select {|a| a.required? }.map {|a| a.id }.max || 0
|
356
366
|
end
|
357
|
-
attr_reader :name, :return_type, :args
|
358
|
-
attr_reader :super_version, :super_func
|
367
|
+
attr_reader :name, :return_type, :args, :exceptions
|
359
368
|
attr_reader :max_id, :max_required_id
|
360
|
-
attr_writer :super_version, :super_func
|
361
369
|
|
362
370
|
def super_class; nil; end
|
363
371
|
alias new_fields args
|
364
372
|
alias all_fields args
|
365
373
|
|
374
|
+
def inherited?
|
375
|
+
false
|
376
|
+
end
|
377
|
+
|
366
378
|
def [](id)
|
367
379
|
@args.find {|a| a.id == id }
|
368
380
|
end
|
369
381
|
end
|
370
382
|
|
383
|
+
class InheritedFunction < Function
|
384
|
+
def initialize(inherit_version, inherit_func)
|
385
|
+
super(inherit_func.name, inherit_func.return_type, inherit_func.args, inherit_func.exceptions)
|
386
|
+
@inherit_version = inherit_version
|
387
|
+
@inherit_func = inherit_func
|
388
|
+
end
|
389
|
+
attr_reader :inherit_version, :inherit_func
|
390
|
+
|
391
|
+
def inherited?
|
392
|
+
true
|
393
|
+
end
|
394
|
+
end
|
395
|
+
|
371
396
|
class Argument < Field
|
372
397
|
end
|
373
398
|
|
@@ -149,7 +149,7 @@ class ParsletParser < Parslet::Parser
|
|
149
149
|
service_name.as(:service_name) >>
|
150
150
|
service_version.maybe.as(:service_version) >>
|
151
151
|
k_lwing >>
|
152
|
-
|
152
|
+
service_def.repeat.as(:service_funcs) >>
|
153
153
|
k_rwing
|
154
154
|
}
|
155
155
|
|
@@ -159,6 +159,19 @@ class ParsletParser < Parslet::Parser
|
|
159
159
|
(str('0') | (match('[1-9]') >> match('[0-9]').repeat)).as(:val_int)
|
160
160
|
}
|
161
161
|
|
162
|
+
rule(:service_def) {
|
163
|
+
inherit | func
|
164
|
+
}
|
165
|
+
|
166
|
+
rule(:inherit) {
|
167
|
+
k_inherit >>
|
168
|
+
(
|
169
|
+
k_asterisk.as(:inherit_all) |
|
170
|
+
func.as(:inherit_func) |
|
171
|
+
func_name.as(:inherit_name)
|
172
|
+
)
|
173
|
+
}
|
174
|
+
|
162
175
|
rule(:func) {
|
163
176
|
return_type.as(:return_type) >>
|
164
177
|
func_name.as(:func_name) >>
|
@@ -169,6 +182,10 @@ class ParsletParser < Parslet::Parser
|
|
169
182
|
eol
|
170
183
|
}
|
171
184
|
|
185
|
+
rule(:func_modifier) {
|
186
|
+
k_obsolete.as(:val_obsolete)
|
187
|
+
}
|
188
|
+
|
172
189
|
sequence :func_args_seq, :k_comma, :field_element
|
173
190
|
|
174
191
|
rule(:func_args) {
|
@@ -395,6 +412,7 @@ class ParsletParser < Parslet::Parser
|
|
395
412
|
keyword('application')
|
396
413
|
keyword('optional')
|
397
414
|
keyword('required')
|
415
|
+
keyword('inherit')
|
398
416
|
keyword('obsolete')
|
399
417
|
keyword('throws')
|
400
418
|
keyword('default')
|
@@ -420,6 +438,7 @@ class ParsletParser < Parslet::Parser
|
|
420
438
|
separator('!', :k_bang)
|
421
439
|
separator('?', :k_question)
|
422
440
|
separator('.', :k_dot)
|
441
|
+
separator('*', :k_asterisk)
|
423
442
|
|
424
443
|
LINE_HEAD_FORMAT = " % 4d: "
|
425
444
|
LINE_HEAD_SIZE = (LINE_HEAD_FORMAT % 0).size
|
@@ -488,8 +507,6 @@ class ParsletParser < Parslet::Parser
|
|
488
507
|
out.puts ln
|
489
508
|
}
|
490
509
|
|
491
|
-
out.puts ""
|
492
|
-
|
493
510
|
out
|
494
511
|
end
|
495
512
|
end
|
@@ -18,6 +18,11 @@
|
|
18
18
|
module MessagePack
|
19
19
|
module IDL
|
20
20
|
|
21
|
+
if defined?(RUBY_VERSION) && RUBY_VERSION >= "1.9.0" && RUBY_VERSION < "1.9.2"
|
22
|
+
class Parslet::Pattern::Context
|
23
|
+
AST = MessagePack::IDL::AST
|
24
|
+
end
|
25
|
+
end
|
21
26
|
|
22
27
|
class ParsletTransform < Parslet::Transform
|
23
28
|
rule(:sequence_x => simple(:x)) {
|
@@ -131,24 +136,16 @@ class ParsletTransform < Parslet::Transform
|
|
131
136
|
AST::Func.new(n, rt, a, ex)
|
132
137
|
}
|
133
138
|
|
134
|
-
rule(:
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
current = AST::ServiceVersion.new(l, [])
|
145
|
-
versions << current
|
146
|
-
end
|
147
|
-
else
|
148
|
-
current.funcs << l
|
149
|
-
end
|
150
|
-
}
|
151
|
-
versions
|
139
|
+
rule(:inherit_all => simple(:_)) {
|
140
|
+
AST::InheritAll.new
|
141
|
+
}
|
142
|
+
|
143
|
+
rule(:inherit_name => simple(:n)) {
|
144
|
+
AST::InheritName.new(n)
|
145
|
+
}
|
146
|
+
|
147
|
+
rule(:inherit_func => simple(:f)) {
|
148
|
+
AST::InheritFunc.new(f.name, f.return_type, f.args, f.exceptions)
|
152
149
|
}
|
153
150
|
|
154
151
|
rule(:service_name => simple(:n),
|
data/lib/msgpack/idl/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: msgpack-idl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- FURUHASHI Sadayuki
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04-
|
18
|
+
date: 2011-04-26 00:00:00 +09:00
|
19
19
|
default_executable: msgpack-idl
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -63,6 +63,9 @@ files:
|
|
63
63
|
- lib/msgpack/idl/ast.rb
|
64
64
|
- lib/msgpack/idl/command/example.rb
|
65
65
|
- lib/msgpack/idl/command/idl.rb
|
66
|
+
- lib/msgpack/idl/command/vimcolor.rb
|
67
|
+
- lib/msgpack/idl/command/vimcolor/mark.vim
|
68
|
+
- lib/msgpack/idl/command/vimcolor/msgspec.vim
|
66
69
|
- lib/msgpack/idl/error.rb
|
67
70
|
- lib/msgpack/idl/evaluator.rb
|
68
71
|
- lib/msgpack/idl/generator.rb
|