stark 0.7.0 → 0.8.0

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.
@@ -1,7 +1,16 @@
1
1
  require 'thrift'
2
+ require 'logger'
2
3
 
3
4
  module Stark
4
- VERSION = '0.7.0'
5
+ VERSION = '0.8.0'
6
+
7
+ def self.logger
8
+ @logger ||= ::Logger.new($stdout)
9
+ end
10
+
11
+ def self.logger=(logger)
12
+ @logger = logger
13
+ end
5
14
 
6
15
  def self.pipe_transport
7
16
  cr, cw = IO.pipe
@@ -18,7 +27,12 @@ module Stark
18
27
  require 'stark/ruby'
19
28
  require 'stringio'
20
29
 
21
- ast = Stark::Parser.ast File.read(file)
30
+ begin
31
+ contents = file.respond_to?(:read) ? file.read : File.read(file)
32
+ ast = Stark::Parser.ast contents
33
+ rescue => e
34
+ raise e, e.message + " while processing #{file} -\n#{e.backtrace.join("\n")}"
35
+ end
22
36
 
23
37
  stream = StringIO.new
24
38
 
@@ -49,5 +49,10 @@ class Stark::Parser
49
49
  obj.process_exception self
50
50
  end
51
51
  end
52
+
53
+ class Comment
54
+ def accept(obj)
55
+ end
56
+ end
52
57
  end
53
58
  end
@@ -1,7 +1,10 @@
1
1
  require 'stark'
2
+ require 'stark/protocol_helpers'
2
3
 
3
4
  module Stark
4
5
  class Client
6
+ include ProtocolHelpers
7
+
5
8
  def initialize(iprot, oprot)
6
9
  @iprot = iprot
7
10
  @oprot = oprot
@@ -15,72 +18,5 @@ module Stark
15
18
  raise x
16
19
  end
17
20
  end
18
-
19
- def handle_throw(cls)
20
- ip = @iprot
21
-
22
- obj = cls::Struct.new
23
-
24
- ip.read_struct_begin
25
-
26
- while true
27
- _, ftype, fid = ip.read_field_begin
28
- break if ftype == ::Thrift::Types::STOP
29
-
30
- obj.set_from_index ftype, fid, ip
31
-
32
- ip.read_field_end
33
- end
34
-
35
- ip.read_struct_end
36
-
37
- ip.read_message_end
38
-
39
- raise cls.new(obj)
40
- end
41
-
42
- def handle_unexpected(rtype)
43
- return if rtype == ::Thrift::Types::STOP
44
- @iprot.skip(rtype)
45
- end
46
-
47
- def handle_bad_list(rtype, size)
48
- size.times { @iprot.skip(rtype) }
49
- end
50
-
51
- def handle_bad_map(key, value, size)
52
- size.times do
53
- @iprot.skip(key)
54
- @iprot.skip(value)
55
- end
56
- end
57
-
58
- def hash_cast(obj)
59
- return obj if obj.kind_of? Hash
60
- return obj.to_h if obj.respond_to? :to_h
61
-
62
- raise TypeError, "Unable to convert #{obj.class} to Hash"
63
- end
64
-
65
- def read_generic(type, id, cls)
66
- ip = @iprot
67
-
68
- obj = cls.new
69
-
70
- ip.read_struct_begin
71
-
72
- while true
73
- _, ftype, fid = ip.read_field_begin
74
- break if ftype == ::Thrift::Types::STOP
75
-
76
- obj.set_from_index ftype, fid, ip
77
-
78
- ip.read_field_end
79
- end
80
-
81
- ip.read_struct_end
82
-
83
- obj
84
- end
85
21
  end
86
22
  end
@@ -1,15 +1,15 @@
1
1
  module Stark
2
2
  class Exception < RuntimeError
3
- def initialize(struct)
4
- super "A remote exception occurred"
5
-
6
- if struct.kind_of? Hash
7
- @struct = self.class::Struct.new(struct)
8
- else
9
- @struct = struct
3
+ def initialize(fields_or_msg = nil)
4
+ case fields_or_msg
5
+ when Hash
6
+ fields_or_msg.each do |k,v|
7
+ send(:"#{k}=", v) if respond_to?(:"#{k}=")
8
+ end
9
+ when nil
10
+ fields_or_msg = "A remote exception occurred"
10
11
  end
12
+ super
11
13
  end
12
-
13
- attr_reader :struct
14
14
  end
15
15
  end
@@ -1,5 +1,9 @@
1
+ require 'stark/protocol_helpers'
2
+
1
3
  module Stark
2
4
  class Processor
5
+ include ProtocolHelpers
6
+
3
7
  def initialize(handler)
4
8
  @handler = handler
5
9
  end
@@ -8,6 +12,7 @@ module Stark
8
12
  name, type, seqid = iprot.read_message_begin
9
13
  fail unless type == Thrift::MessageTypes::CALL
10
14
 
15
+ x = nil
11
16
  if respond_to?("process_#{name}")
12
17
  send("process_#{name}", seqid, iprot, oprot)
13
18
  true
@@ -15,63 +20,19 @@ module Stark
15
20
  iprot.skip(::Thrift::Types::STRUCT)
16
21
  iprot.read_message_end
17
22
  x = ::Thrift::ApplicationException.new(Thrift::ApplicationException::UNKNOWN_METHOD, 'Unknown function '+name)
23
+ false
24
+ end
25
+ rescue ::Exception => e
26
+ Stark.logger.error "#{self.class.name}#process_#{name}: #{e.message}\n " + e.backtrace.join("\n ")
27
+ x = Thrift::ApplicationException.new(Thrift::ApplicationException::INTERNAL_ERROR, e.message)
28
+ false
29
+ ensure
30
+ if x
18
31
  oprot.write_message_begin(name, ::Thrift::MessageTypes::EXCEPTION, seqid)
19
32
  x.write(oprot)
20
33
  oprot.write_message_end
21
34
  oprot.trans.flush
22
- false
23
- end
24
- end
25
-
26
- def check_raise_specific(name, seqid, op, c)
27
- begin
28
- yield
29
- rescue c => e
30
- op.write_message_begin name, ::Thrift::MessageTypes::REPLY, seqid
31
- op.write_struct_begin 'result_struct'
32
-
33
- op.write_field_begin 'result', ::Thrift::Types::STRUCT, 1
34
- op.write_struct_begin c.class.name
35
- e.struct.write_fields op
36
- op.write_field_end
37
- op.write_field_stop
38
- op.write_struct_end
39
-
40
- op.write_field_end
41
- op.write_field_stop
42
- op.write_struct_end
43
-
44
- op.write_message_end
45
- op.trans.flush
46
-
47
- nil
48
35
  end
49
36
  end
50
-
51
- def hash_cast(obj)
52
- return obj if obj.kind_of? Hash
53
- return obj.to_h if obj.respond_to? :to_h
54
-
55
- raise TypeError, "Unable to convert #{obj.class} to Hash"
56
- end
57
-
58
- def read_struct(ip, type, id, cls)
59
- obj = cls.new
60
-
61
- ip.read_struct_begin
62
-
63
- while true
64
- _, ftype, fid = ip.read_field_begin
65
- break if ftype == ::Thrift::Types::STOP
66
-
67
- obj.set_from_index ftype, fid, ip
68
-
69
- ip.read_field_end
70
- end
71
-
72
- ip.read_struct_end
73
-
74
- obj
75
- end
76
37
  end
77
38
  end
@@ -0,0 +1,161 @@
1
+ module Stark
2
+ module ProtocolHelpers
3
+ COERCION_TO_STRING = Hash.new {|h,k|
4
+ lambda {|ip| ip.skip k; nil }
5
+ }.update({
6
+ ::Thrift::Types::BOOL => lambda {|ip| ip.read_bool.to_s },
7
+ ::Thrift::Types::BYTE => lambda {|ip| ip.read_byte.to_s },
8
+ ::Thrift::Types::I16 => lambda {|ip| ip.read_i16.to_s },
9
+ ::Thrift::Types::I32 => lambda {|ip| ip.read_i32.to_s },
10
+ ::Thrift::Types::I64 => lambda {|ip| ip.read_i64.to_s },
11
+ ::Thrift::Types::DOUBLE => lambda {|ip| ip.read_double.to_s },
12
+ })
13
+
14
+ COERCION_FROM_STRING = Hash.new {|h,k|
15
+ lambda {|val| nil }
16
+ }.update({
17
+ ::Thrift::Types::BOOL => lambda {|val|
18
+ val =~ /^(1|y|t|on)/ ? true : false },
19
+ ::Thrift::Types::BYTE => lambda {|val| val.to_i },
20
+ ::Thrift::Types::I16 => lambda {|val| val.to_i },
21
+ ::Thrift::Types::I32 => lambda {|val| val.to_i },
22
+ ::Thrift::Types::I64 => lambda {|val| val.to_i },
23
+ ::Thrift::Types::DOUBLE => lambda {|val| val.to_f },
24
+ })
25
+
26
+ def expect(ip, expected, actual)
27
+ return nil if actual == ::Thrift::Types::STOP
28
+
29
+ if expected == actual
30
+ yield
31
+ elsif expected == ::Thrift::Types::STRING
32
+ COERCION_TO_STRING[actual][ip]
33
+ elsif actual == ::Thrift::Types::STRING
34
+ COERCION_FROM_STRING[expected][ip.read_string]
35
+ else
36
+ ip.skip actual
37
+ nil
38
+ end
39
+ end
40
+
41
+ def valid_element_type?(expected, actual)
42
+ expected == actual ||
43
+ expected == ::Thrift::Types::STRING ||
44
+ actual == ::Thrift::Types::STRING
45
+ end
46
+
47
+ def expect_list(ip, expected)
48
+ actual, size = ip.read_list_begin
49
+ if valid_element_type?(expected, actual)
50
+ yield actual, size
51
+ else
52
+ size.times { ip.skip actual }
53
+ nil
54
+ end
55
+ ensure
56
+ ip.read_list_end
57
+ end
58
+
59
+ def expect_map(ip, expected_key, expected_value)
60
+ actual_key, actual_value, size = ip.read_map_begin
61
+ if valid_element_type?(expected_key, actual_key) &&
62
+ valid_element_type?(expected_value, actual_value)
63
+ yield actual_key, actual_value, size
64
+ else
65
+ size.times do
66
+ ip.skip actual_key
67
+ ip.skip actual_value
68
+ end
69
+ nil
70
+ end
71
+ ensure
72
+ ip.read_map_end
73
+ end
74
+
75
+ def expect_set(ip, expected)
76
+ actual, size = ip.read_set_begin
77
+ if valid_element_type?(expected, actual)
78
+ yield actual, size
79
+ else
80
+ size.times { ip.skip actual }
81
+ nil
82
+ end
83
+ ensure
84
+ ip.read_set_end
85
+ end
86
+
87
+ def hash_cast(obj)
88
+ return obj if obj.kind_of? Hash
89
+ return obj.to_h if obj.respond_to? :to_h
90
+
91
+ raise TypeError, "Unable to convert #{obj.class} to Hash"
92
+ end
93
+
94
+ THRIFT_TO_RUBY = {
95
+ ::Thrift::Types::BOOL => [TrueClass, FalseClass, NilClass],
96
+ ::Thrift::Types::BYTE => [Fixnum],
97
+ ::Thrift::Types::I16 => [Fixnum],
98
+ ::Thrift::Types::I32 => [Fixnum],
99
+ ::Thrift::Types::I64 => [Fixnum],
100
+ ::Thrift::Types::DOUBLE => [Float],
101
+ ::Thrift::Types::STRING => [String],
102
+ ::Thrift::Types::MAP => [Hash],
103
+ ::Thrift::Types::SET => [Set],
104
+ ::Thrift::Types::LIST => [Array]
105
+ }
106
+
107
+ def value_for_write(val, expected, additional = nil)
108
+ return val if val.nil?
109
+
110
+ ruby_types = nil
111
+ if additional
112
+ case expected
113
+ when ::Thrift::Types::STRUCT
114
+ if Class === additional && # Struct or Exception
115
+ (additional < Stark::Struct || additional < Stark::Exception)
116
+ ruby_types = [additional]
117
+ end
118
+ when ::Thrift::Types::I32
119
+ if Hash === additional # Enum hash
120
+ ruby_types = [Symbol]
121
+ end
122
+ end
123
+ else
124
+ ruby_types = THRIFT_TO_RUBY[expected]
125
+ end
126
+
127
+ raise TypeError, "Unknown Thrift type #{expected}" unless ruby_types
128
+
129
+ return val if ruby_types.any? {|t| t === val }
130
+
131
+ if String === val
132
+ obj = COERCION_FROM_STRING[expected][val]
133
+ raise TypeError, "Cannot coerce #{val.class} to #{ruby_types.join(' ')}" unless obj
134
+ return obj
135
+ end
136
+
137
+ case expected
138
+ when ::Thrift::Types::BOOL
139
+ return val
140
+ when ::Thrift::Types::STRING
141
+ return val.to_s
142
+ when ::Thrift::Types::MAP
143
+ return val.to_hash if val.respond_to?(:to_hash)
144
+ when ::Thrift::Types::SET
145
+ return Set.new(val.to_a) if val.respond_to?(:to_a)
146
+ when ::Thrift::Types::LIST
147
+ return val.to_a if val.respond_to?(:to_a)
148
+ when ::Thrift::Types::BYTE, ::Thrift::Types::I16, ::Thrift::Types::I64
149
+ return val.to_i if val.respond_to?(:to_i)
150
+ when ::Thrift::Types::I32
151
+ if Hash === additional # Enum hash
152
+ return val.to_sym if val.respond_to?(:to_sym)
153
+ end
154
+ return additional[val.to_i] if val.respond_to?(:to_i)
155
+ when ::Thrift::Types::DOUBLE
156
+ return val.to_f if val.respond_to?(:to_f)
157
+ end
158
+ raise TypeError, "Unexpected type #{val.class} (#{val.inspect}); was expecting #{ruby_types.join(' ')}"
159
+ end
160
+ end
161
+ end
@@ -613,7 +613,7 @@ class Stark::Parser
613
613
  return _tmp
614
614
  end
615
615
 
616
- # reserved = ("BEGIN" | "END" | "__CLASS__" | "__DIR__" | "__FILE__" | "__FUNCTION__" | "__LINE__" | "__METHOD__" | "__NAMESPACE__" | "abstract" | "alias" | "and" | "args" | "as" | "assert" | "begin" | "break" | "case" | "catch" | "class" | "clone" | "continue" | "declare" | "def" | "default" | "del" | "delete" | "do" | "dynamic" | "elif" | "else" | "elseif" | "elsif" | "end" | "enddeclare" | "endfor" | "endforeach" | "endif" | "endswitch" | "endwhile" | "ensure" | "except" | "exec" | "finally" | "float" | "for" | "foreach" | "function" | "global" | "goto" | "if" | "implements" | "import" | "in" | "inline" | "instanceof" | "interface" | "is" | "lambda" | "module" | "native" | "new" | "next" | "nil" | "not" | "or" | "pass" | "public" | "print" | "private" | "protected" | "public" | "raise" | "redo" | "rescue" | "retry" | "register" | "return" | "self" | "sizeof" | "static" | "super" | "switch" | "synchronized" | "then" | "this" | "throw" | "transient" | "try" | "undef" | "union" | "unless" | "unsigned" | "until" | "use" | "var" | "virtual" | "volatile" | "when" | "while" | "with" | "xor" | "yield")
616
+ # reserved = ("BEGIN" | "END" | "__CLASS__" | "__DIR__" | "__FILE__" | "__FUNCTION__" | "__LINE__" | "__METHOD__" | "__NAMESPACE__" | "abstract" | "alias" | "and" | "args" | "as" | "assert" | "begin" | "break" | "case" | "catch" | "class" | "clone" | "continue" | "declare" | "def" | "default" | "del" | "delete" | "do" | "dynamic" | "elif" | "else" | "elseif" | "elsif" | "end" | "enddeclare" | "endfor" | "endforeach" | "endif" | "endswitch" | "endwhile" | "ensure" | "except" | "exec" | "finally" | "float" | "for" | "foreach" | "function" | "global" | "goto" | "if" | "implements" | "import" | "in" | "inline" | "instanceof" | "interface" | "is" | "lambda" | "module" | "native" | "new" | "next" | "nil" | "not" | "or" | "pass" | "public" | "print" | "private" | "protected" | "public" | "raise" | "redo" | "rescue" | "retry" | "register" | "return" | "self" | "sizeof" | "static" | "super" | "switch" | "synchronized" | "then" | "this" | "throws" | "transient" | "try" | "undef" | "union" | "unless" | "unsigned" | "until" | "use" | "var" | "virtual" | "volatile" | "when" | "while" | "with" | "xor" | "yield")
617
617
  def _reserved
618
618
 
619
619
  _save = self.pos
@@ -876,7 +876,7 @@ class Stark::Parser
876
876
  _tmp = match_string("this")
877
877
  break if _tmp
878
878
  self.pos = _save
879
- _tmp = match_string("throw")
879
+ _tmp = match_string("throws")
880
880
  break if _tmp
881
881
  self.pos = _save
882
882
  _tmp = match_string("transient")
@@ -1424,8 +1424,8 @@ class Stark::Parser
1424
1424
  return _tmp
1425
1425
  end
1426
1426
 
1427
- # CComment = "/*" < (!"*/" .)* > "*/" obsp {comment(text)}
1428
- def _CComment
1427
+ # CMLComment = "/*" < (!"*/" .)* > "*/" obsp {comment(text)}
1428
+ def _CMLComment
1429
1429
 
1430
1430
  _save = self.pos
1431
1431
  while true # sequence
@@ -1482,7 +1482,64 @@ class Stark::Parser
1482
1482
  break
1483
1483
  end # end sequence
1484
1484
 
1485
- set_failed_rule :_CComment unless _tmp
1485
+ set_failed_rule :_CMLComment unless _tmp
1486
+ return _tmp
1487
+ end
1488
+
1489
+ # CSLComment = "//" < (!"\n" .)* > bsp {comment(text)}
1490
+ def _CSLComment
1491
+
1492
+ _save = self.pos
1493
+ while true # sequence
1494
+ _tmp = match_string("//")
1495
+ unless _tmp
1496
+ self.pos = _save
1497
+ break
1498
+ end
1499
+ _text_start = self.pos
1500
+ while true
1501
+
1502
+ _save2 = self.pos
1503
+ while true # sequence
1504
+ _save3 = self.pos
1505
+ _tmp = match_string("\n")
1506
+ _tmp = _tmp ? nil : true
1507
+ self.pos = _save3
1508
+ unless _tmp
1509
+ self.pos = _save2
1510
+ break
1511
+ end
1512
+ _tmp = get_byte
1513
+ unless _tmp
1514
+ self.pos = _save2
1515
+ end
1516
+ break
1517
+ end # end sequence
1518
+
1519
+ break unless _tmp
1520
+ end
1521
+ _tmp = true
1522
+ if _tmp
1523
+ text = get_text(_text_start)
1524
+ end
1525
+ unless _tmp
1526
+ self.pos = _save
1527
+ break
1528
+ end
1529
+ _tmp = apply(:_bsp)
1530
+ unless _tmp
1531
+ self.pos = _save
1532
+ break
1533
+ end
1534
+ @result = begin; comment(text); end
1535
+ _tmp = true
1536
+ unless _tmp
1537
+ self.pos = _save
1538
+ end
1539
+ break
1540
+ end # end sequence
1541
+
1542
+ set_failed_rule :_CSLComment unless _tmp
1486
1543
  return _tmp
1487
1544
  end
1488
1545
 
@@ -1543,12 +1600,15 @@ class Stark::Parser
1543
1600
  return _tmp
1544
1601
  end
1545
1602
 
1546
- # Comment = (CComment | HComment)
1603
+ # Comment = (CMLComment | CSLComment | HComment)
1547
1604
  def _Comment
1548
1605
 
1549
1606
  _save = self.pos
1550
1607
  while true # choice
1551
- _tmp = apply(:_CComment)
1608
+ _tmp = apply(:_CMLComment)
1609
+ break if _tmp
1610
+ self.pos = _save
1611
+ _tmp = apply(:_CSLComment)
1552
1612
  break if _tmp
1553
1613
  self.pos = _save
1554
1614
  _tmp = apply(:_HComment)
@@ -3170,12 +3230,12 @@ class Stark::Parser
3170
3230
  return _tmp
3171
3231
  end
3172
3232
 
3173
- # Throws = - "throws" - "(" FieldList ")"
3233
+ # Throws = osp "throws" osp "(" FieldList ")"
3174
3234
  def _Throws
3175
3235
 
3176
3236
  _save = self.pos
3177
3237
  while true # sequence
3178
- _tmp = apply(:__hyphen_)
3238
+ _tmp = apply(:_osp)
3179
3239
  unless _tmp
3180
3240
  self.pos = _save
3181
3241
  break
@@ -3185,7 +3245,7 @@ class Stark::Parser
3185
3245
  self.pos = _save
3186
3246
  break
3187
3247
  end
3188
- _tmp = apply(:__hyphen_)
3248
+ _tmp = apply(:_osp)
3189
3249
  unless _tmp
3190
3250
  self.pos = _save
3191
3251
  break
@@ -3969,7 +4029,7 @@ class Stark::Parser
3969
4029
  Rules[:_whitespace] = rule_info("whitespace", "/([ \\t\\r\\n]*)/")
3970
4030
  Rules[:_st_identifier] = rule_info("st_identifier", "/([a-zA-Z-][\\.a-zA-Z_0-9-]*)/")
3971
4031
  Rules[:_literal_begin] = rule_info("literal_begin", "/(['\\\"])/")
3972
- Rules[:_reserved] = rule_info("reserved", "(\"BEGIN\" | \"END\" | \"__CLASS__\" | \"__DIR__\" | \"__FILE__\" | \"__FUNCTION__\" | \"__LINE__\" | \"__METHOD__\" | \"__NAMESPACE__\" | \"abstract\" | \"alias\" | \"and\" | \"args\" | \"as\" | \"assert\" | \"begin\" | \"break\" | \"case\" | \"catch\" | \"class\" | \"clone\" | \"continue\" | \"declare\" | \"def\" | \"default\" | \"del\" | \"delete\" | \"do\" | \"dynamic\" | \"elif\" | \"else\" | \"elseif\" | \"elsif\" | \"end\" | \"enddeclare\" | \"endfor\" | \"endforeach\" | \"endif\" | \"endswitch\" | \"endwhile\" | \"ensure\" | \"except\" | \"exec\" | \"finally\" | \"float\" | \"for\" | \"foreach\" | \"function\" | \"global\" | \"goto\" | \"if\" | \"implements\" | \"import\" | \"in\" | \"inline\" | \"instanceof\" | \"interface\" | \"is\" | \"lambda\" | \"module\" | \"native\" | \"new\" | \"next\" | \"nil\" | \"not\" | \"or\" | \"pass\" | \"public\" | \"print\" | \"private\" | \"protected\" | \"public\" | \"raise\" | \"redo\" | \"rescue\" | \"retry\" | \"register\" | \"return\" | \"self\" | \"sizeof\" | \"static\" | \"super\" | \"switch\" | \"synchronized\" | \"then\" | \"this\" | \"throw\" | \"transient\" | \"try\" | \"undef\" | \"union\" | \"unless\" | \"unsigned\" | \"until\" | \"use\" | \"var\" | \"virtual\" | \"volatile\" | \"when\" | \"while\" | \"with\" | \"xor\" | \"yield\")")
4032
+ Rules[:_reserved] = rule_info("reserved", "(\"BEGIN\" | \"END\" | \"__CLASS__\" | \"__DIR__\" | \"__FILE__\" | \"__FUNCTION__\" | \"__LINE__\" | \"__METHOD__\" | \"__NAMESPACE__\" | \"abstract\" | \"alias\" | \"and\" | \"args\" | \"as\" | \"assert\" | \"begin\" | \"break\" | \"case\" | \"catch\" | \"class\" | \"clone\" | \"continue\" | \"declare\" | \"def\" | \"default\" | \"del\" | \"delete\" | \"do\" | \"dynamic\" | \"elif\" | \"else\" | \"elseif\" | \"elsif\" | \"end\" | \"enddeclare\" | \"endfor\" | \"endforeach\" | \"endif\" | \"endswitch\" | \"endwhile\" | \"ensure\" | \"except\" | \"exec\" | \"finally\" | \"float\" | \"for\" | \"foreach\" | \"function\" | \"global\" | \"goto\" | \"if\" | \"implements\" | \"import\" | \"in\" | \"inline\" | \"instanceof\" | \"interface\" | \"is\" | \"lambda\" | \"module\" | \"native\" | \"new\" | \"next\" | \"nil\" | \"not\" | \"or\" | \"pass\" | \"public\" | \"print\" | \"private\" | \"protected\" | \"public\" | \"raise\" | \"redo\" | \"rescue\" | \"retry\" | \"register\" | \"return\" | \"self\" | \"sizeof\" | \"static\" | \"super\" | \"switch\" | \"synchronized\" | \"then\" | \"this\" | \"throws\" | \"transient\" | \"try\" | \"undef\" | \"union\" | \"unless\" | \"unsigned\" | \"until\" | \"use\" | \"var\" | \"virtual\" | \"volatile\" | \"when\" | \"while\" | \"with\" | \"xor\" | \"yield\")")
3973
4033
  Rules[:_tok_int_constant] = rule_info("tok_int_constant", "(< intconstant > { text.to_i } | < hexconstant > { text.to_i } | \"false\" { 0 } | \"true\" { 1 })")
3974
4034
  Rules[:_tok_dub_constant] = rule_info("tok_dub_constant", "dubconstant:f { f.to_f }")
3975
4035
  Rules[:_tok_identifier] = rule_info("tok_identifier", "< identifier > {text}")
@@ -3982,9 +4042,10 @@ class Stark::Parser
3982
4042
  Rules[:_obsp] = rule_info("obsp", "/[\\s]*/")
3983
4043
  Rules[:_root] = rule_info("root", "Program !.")
3984
4044
  Rules[:_Program] = rule_info("Program", "Element*:a { a }")
3985
- Rules[:_CComment] = rule_info("CComment", "\"/*\" < (!\"*/\" .)* > \"*/\" obsp {comment(text)}")
4045
+ Rules[:_CMLComment] = rule_info("CMLComment", "\"/*\" < (!\"*/\" .)* > \"*/\" obsp {comment(text)}")
4046
+ Rules[:_CSLComment] = rule_info("CSLComment", "\"//\" < (!\"\\n\" .)* > bsp {comment(text)}")
3986
4047
  Rules[:_HComment] = rule_info("HComment", "\"\#\" < (!\"\\n\" .)* > bsp {comment(text)}")
3987
- Rules[:_Comment] = rule_info("Comment", "(CComment | HComment)")
4048
+ Rules[:_Comment] = rule_info("Comment", "(CMLComment | CSLComment | HComment)")
3988
4049
  Rules[:_CaptureDocText] = rule_info("CaptureDocText", "{}")
3989
4050
  Rules[:_DestroyDocText] = rule_info("DestroyDocText", "{}")
3990
4051
  Rules[:_HeaderList] = rule_info("HeaderList", "(HeaderList Header | Header)")
@@ -4021,7 +4082,7 @@ class Stark::Parser
4021
4082
  Rules[:_FunctionList] = rule_info("FunctionList", "(FunctionList:l Function:f { l + [f] } | Function:f { [f] })")
4022
4083
  Rules[:_Function] = rule_info("Function", "CaptureDocText OneWay?:o FunctionType:rt - tok_identifier:name osp \"(\" FieldList?:args \")\" Throws?:t CommaOrSemicolonOptional {function(name, rt, args, t, o)}")
4023
4084
  Rules[:_OneWay] = rule_info("OneWay", "(\"oneway\" | \"async\") - { :oneway }")
4024
- Rules[:_Throws] = rule_info("Throws", "- \"throws\" - \"(\" FieldList \")\"")
4085
+ Rules[:_Throws] = rule_info("Throws", "osp \"throws\" osp \"(\" FieldList \")\"")
4025
4086
  Rules[:_FieldList] = rule_info("FieldList", "(FieldList:l Field:f { l + [f] } | Field:f { [f] })")
4026
4087
  Rules[:_Field] = rule_info("Field", "CaptureDocText FieldIdentifier?:i osp FieldRequiredness?:req osp FieldType:t osp tok_identifier:n osp FieldValue?:val CommaOrSemicolonOptional {field(i,t,n,val,req)}")
4027
4088
  Rules[:_FieldIdentifier] = rule_info("FieldIdentifier", "tok_int_constant:n \":\" {n}")