RbYAML 0.1.0 → 0.2.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.
Files changed (81) hide show
  1. data/lib/rbyaml.rb +14 -256
  2. data/lib/rbyaml.rb.~1.2.~ +383 -0
  3. data/lib/rbyaml/composer.rb +9 -11
  4. data/lib/rbyaml/{composer.rb.~1.2.~ → composer.rb.~1.3.~} +28 -25
  5. data/lib/rbyaml/constants.rb +95 -0
  6. data/lib/rbyaml/constructor.rb +180 -89
  7. data/lib/rbyaml/{constructor.rb.~1.2.~ → constructor.rb.~1.9.~} +137 -95
  8. data/lib/rbyaml/dumper.rb +12 -9
  9. data/lib/rbyaml/dumper.rb.~1.3.~ +36 -0
  10. data/lib/rbyaml/emitter.rb +14 -28
  11. data/lib/rbyaml/{emitter.rb.~1.2.~ → emitter.rb.~1.6.~} +22 -33
  12. data/lib/rbyaml/error.rb +4 -57
  13. data/lib/rbyaml/error.rb.~1.2.~ +75 -0
  14. data/lib/rbyaml/events.rb +8 -14
  15. data/lib/rbyaml/{events.rb.~1.2.~ → events.rb.~1.4.~} +29 -6
  16. data/lib/rbyaml/nodes.rb +5 -5
  17. data/lib/rbyaml/{nodes.rb.~1.2.~ → nodes.rb.~1.3.~} +13 -9
  18. data/lib/rbyaml/parser.rb +70 -108
  19. data/lib/rbyaml/parser.rb.~1.4.~ +632 -0
  20. data/lib/rbyaml/representer.rb +19 -157
  21. data/lib/rbyaml/representer.rb.old +317 -0
  22. data/lib/rbyaml/{representer.rb.~1.2.~ → representer.rb.~1.5.~} +60 -26
  23. data/lib/rbyaml/resolver.rb +6 -6
  24. data/lib/rbyaml/{resolver.rb.~1.1.~ → resolver.rb.~1.6.~} +20 -20
  25. data/lib/rbyaml/rubytypes.rb +391 -0
  26. data/lib/rbyaml/scanner.rb +123 -225
  27. data/lib/rbyaml/{scanner.rb.~1.2.~ → scanner.rb.~1.5.~} +466 -378
  28. data/lib/rbyaml/serializer.rb +9 -9
  29. data/lib/rbyaml/{serializer.rb.~1.2.~ → serializer.rb.~1.4.~} +19 -17
  30. data/lib/rbyaml/stream.rb +48 -0
  31. data/lib/rbyaml/tag.rb +72 -0
  32. data/lib/rbyaml/tokens.rb +22 -16
  33. data/lib/rbyaml/{tokens.rb.~1.2.~ → tokens.rb.~1.3.~} +44 -4
  34. data/lib/rbyaml/types.rb +146 -0
  35. data/lib/rbyaml/util.rb.~1.3.~ +38 -0
  36. data/lib/rbyaml/yaml.rb +22 -32
  37. data/lib/rbyaml/{yaml.rb.~1.2.~ → yaml.rb.~1.5.~} +17 -17
  38. data/test/load_one.rb +6 -0
  39. data/test/load_one_yaml.rb +6 -0
  40. data/test/output_events.rb +9 -0
  41. data/test/test_add_ctor.rb +51 -0
  42. data/test/test_add_ctor.rb.~1.1.~ +30 -0
  43. data/test/test_bm.rb +2 -2
  44. data/test/test_bm.rb.~1.1.~ +28 -0
  45. data/test/test_gems.rb +10 -0
  46. data/test/test_one.rb.~1.1.~ +5 -0
  47. data/test/test_one_syck.rb +5 -0
  48. data/test/test_rbyaml.rb +63 -32
  49. data/test/test_rbyaml.rb.~1.6.~ +59 -0
  50. data/test/{test_rbyaml.rb.~1.2.~ → test_rbyaml_old.rb} +13 -4
  51. data/test/test_time_events.rb +24 -0
  52. data/test/test_time_nodes.rb +24 -0
  53. data/test/test_time_tokens.rb +24 -0
  54. data/test/yaml/gems_new.yml +147456 -0
  55. data/test/yaml/test1.rb +8 -0
  56. data/test/yaml/test10.rb +14 -0
  57. data/test/yaml/test11.rb +13 -0
  58. data/test/yaml/test12.rb +9 -0
  59. data/test/yaml/test13.rb +9 -0
  60. data/test/yaml/test14.rb +13 -0
  61. data/test/yaml/test15.rb +12 -0
  62. data/test/yaml/test16.rb +11 -0
  63. data/test/yaml/test16.rb.~1.1.~ +11 -0
  64. data/test/yaml/test17.rb +10 -0
  65. data/test/yaml/test18.rb +13 -0
  66. data/test/yaml/test19.rb +9 -0
  67. data/test/yaml/test19.yml +1 -1
  68. data/test/yaml/test2.rb +8 -0
  69. data/test/yaml/test20.rb +11 -0
  70. data/test/yaml/test20.rb.~1.1.~ +9 -0
  71. data/test/yaml/test20.yml +1 -1
  72. data/test/yaml/test3.rb +13 -0
  73. data/test/yaml/test4.rb +13 -0
  74. data/test/yaml/test5.rb +8 -0
  75. data/test/yaml/test6.rb +10 -0
  76. data/test/yaml/test7.rb +15 -0
  77. data/test/yaml/test8.rb +15 -0
  78. data/test/yaml/test9.rb +13 -0
  79. metadata +61 -16
  80. data/lib/rbyaml/dumper.rb.~1.2.~ +0 -43
  81. data/lib/rbyaml/parser.rb.~1.2.~ +0 -494
@@ -7,15 +7,15 @@ module RbYAML
7
7
  end
8
8
 
9
9
  class Serializer
10
- ANCHOR_TEMPLATE = "id%03d"
11
-
12
- def initialize(emitter, resolver, explicit_start=nil, explicit_end=nil, version=nil, tags=nil)
10
+ def initialize(emitter, resolver, opts={})
13
11
  @emitter = emitter
14
12
  @resolver = resolver
15
- @use_explicit_start = explicit_start
16
- @use_explicit_end = explicit_end
17
- @use_version = version
18
- @use_tags = tags
13
+ @options = opts
14
+ @use_explicit_start = opts[:ExplicitStart]
15
+ @use_explicit_end = opts[:ExplicitEnd]
16
+ @use_version = opts[:UseVersion] && opts[:Version]
17
+ @use_tags = opts[:UseHeader]
18
+ @anchor_template = opts[:AnchorFormat] || "id%03d"
19
19
  @serialized_nodes = {}
20
20
  @anchors = {}
21
21
  @last_anchor_id = 0
@@ -77,7 +77,7 @@ module RbYAML
77
77
 
78
78
  def generate_anchor(node)
79
79
  @last_anchor_id += 1
80
- ANCHOR_TEMPLATE % @last_anchor_id
80
+ @anchor_template % @last_anchor_id
81
81
  end
82
82
 
83
83
  def serialize_node(node,parent,index)
@@ -91,7 +91,7 @@ module RbYAML
91
91
  detected_tag = @resolver.resolve(ScalarNode, node.value, [true,false])
92
92
  default_tag = @resolver.resolve(ScalarNode, node.value, [false,true])
93
93
  implicit = (node.tag == detected_tag), (node.tag == default_tag)
94
- @emitter.emit(ScalarEvent.new(talias, node.tag, implicit, node.value,nil,nil,node.style))
94
+ @emitter.emit(ScalarEvent.new(talias, node.tag, implicit, node.value,node.style))
95
95
  elsif SequenceNode === node
96
96
  implicit = (node.tag == @resolver.resolve(SequenceNode, node.value, true))
97
97
  @emitter.emit(SequenceStartEvent.new(talias, node.tag, implicit,node.flow_style))
@@ -6,10 +6,12 @@ module RbYAML
6
6
  class SerializerError < YAMLError
7
7
  end
8
8
 
9
- module Serializer
9
+ class Serializer
10
10
  ANCHOR_TEMPLATE = "id%03d"
11
11
 
12
- def initialize_serializer(explicit_start=nil, explicit_end=nil, version=nil, tags=nil)
12
+ def initialize(emitter, resolver, explicit_start=nil, explicit_end=nil, version=nil, tags=nil)
13
+ @emitter = emitter
14
+ @resolver = resolver
13
15
  @use_explicit_start = explicit_start
14
16
  @use_explicit_end = explicit_end
15
17
  @use_version = version
@@ -22,7 +24,7 @@ module RbYAML
22
24
 
23
25
  def open
24
26
  if @closed.nil?
25
- emit(StreamStartEvent.new)
27
+ @emitter.emit(StreamStartEvent.new)
26
28
  @closed = false
27
29
  elsif @closed
28
30
  raise SerializerError.new("serializer is closed")
@@ -35,7 +37,7 @@ module RbYAML
35
37
  if @closed.nil?
36
38
  raise SerializerError.new("serializer is not opened")
37
39
  elsif !@closed
38
- emit(StreamEndEvent.new)
40
+ @emitter.emit(StreamEndEvent.new)
39
41
  @closed = true
40
42
  end
41
43
  end
@@ -46,10 +48,10 @@ module RbYAML
46
48
  elsif @closed
47
49
  raise SerializerError.new("serializer is closed")
48
50
  end
49
- emit(DocumentStartEvent.new(@use_explicit_start,@use_version,@use_tags))
51
+ @emitter.emit(DocumentStartEvent.new(nil,nil,@use_explicit_start,@use_version,@use_tags))
50
52
  anchor_node(node)
51
53
  serialize_node(node,nil,nil)
52
- emit(DocumentEndEvent.new(@use_explicit_end))
54
+ @emitter.emit(DocumentEndEvent.new(nil,nil,@use_explicit_end))
53
55
  @serialized_nodes = {}
54
56
  @anchors = {}
55
57
  @last_alias_id = 0
@@ -81,32 +83,32 @@ module RbYAML
81
83
  def serialize_node(node,parent,index)
82
84
  talias = @anchors[node]
83
85
  if @serialized_nodes.include?(node)
84
- emit(AliasEvent.new(talias))
86
+ @emitter.emit(AliasEvent.new(talias))
85
87
  else
86
88
  @serialized_nodes[node] = true
87
- descend_resolver(parent, index)
89
+ @resolver.descend_resolver(parent, index)
88
90
  if ScalarNode === node
89
- detected_tag = resolve(ScalarNode, node.value, [true,false])
90
- default_tag = resolve(ScalarNode, node.value, [false,true])
91
+ detected_tag = @resolver.resolve(ScalarNode, node.value, [true,false])
92
+ default_tag = @resolver.resolve(ScalarNode, node.value, [false,true])
91
93
  implicit = (node.tag == detected_tag), (node.tag == default_tag)
92
- emit(ScalarEvent.new(talias, node.tag, implicit, node.value,nil,nil,node.style))
94
+ @emitter.emit(ScalarEvent.new(talias, node.tag, implicit, node.value,nil,nil,node.style))
93
95
  elsif SequenceNode === node
94
- implicit = (node.tag == resolve(SequenceNode, node.value, true))
95
- emit(SequenceStartEvent.new(talias, node.tag, implicit,node.flow_style))
96
+ implicit = (node.tag == @resolver.resolve(SequenceNode, node.value, true))
97
+ @emitter.emit(SequenceStartEvent.new(talias, node.tag, implicit,node.flow_style))
96
98
  index = 0
97
99
  for item in node.value
98
100
  serialize_node(item,node,index)
99
101
  index += 1
100
102
  end
101
- emit(SequenceEndEvent.new)
103
+ @emitter.emit(SequenceEndEvent.new)
102
104
  elsif MappingNode === node
103
- implicit = (node.tag == resolve(MappingNode, node.value, true))
104
- emit(MappingStartEvent.new(talias, node.tag, implicit,node.flow_style))
105
+ implicit = (node.tag == @resolver.resolve(MappingNode, node.value, true))
106
+ @emitter.emit(MappingStartEvent.new(talias, node.tag, implicit,node.flow_style))
105
107
  for key, value in node.value
106
108
  serialize_node(key,node,nil)
107
109
  serialize_node(value,node,key)
108
110
  end
109
- emit(MappingEndEvent.new)
111
+ @emitter.emit(MappingEndEvent.new)
110
112
  end
111
113
  end
112
114
  end
@@ -0,0 +1,48 @@
1
+ module RbYAML
2
+ #
3
+ # RbYAML::Stream -- for emitting many documents
4
+ #
5
+ class Stream
6
+ include Enumerable
7
+
8
+ attr_accessor :documents, :options
9
+ def initialize(opts = {})
10
+ @options = opts
11
+ @documents = []
12
+ end
13
+
14
+ def [](i)
15
+ @documents[ i ]
16
+ end
17
+
18
+ def add(doc)
19
+ @documents << doc
20
+ end
21
+
22
+ def edit(doc_num,doc)
23
+ @documents[ doc_num ] = doc
24
+ end
25
+
26
+ def each(&block)
27
+ @documents.each(&block)
28
+ end
29
+
30
+ def emit
31
+ # TODO: implement
32
+
33
+ opts = @options.dup
34
+ opts[:UseHeader] = true if @documents.length > 1
35
+ ct = 0
36
+ out = Emitter.new( opts )
37
+ @documents.each { |v|
38
+ if ct > 0
39
+ out << "\n--- "
40
+ end
41
+ v.to_yaml( :Emitter => out )
42
+ ct += 1
43
+ }
44
+ out.end_object
45
+ end
46
+ end
47
+
48
+ end
@@ -0,0 +1,72 @@
1
+ module RbYAML
2
+ # A dictionary of taguris which map to
3
+ # Ruby classes.
4
+ @@tagged_classes = {}
5
+
6
+ #
7
+ # Associates a taguri _tag_ with a Ruby class _cls_. The taguri is used to give types
8
+ # to classes when loading YAML. Taguris are of the form:
9
+ #
10
+ # tag:authorityName,date:specific
11
+ #
12
+ # The +authorityName+ is a domain name or email address. The +date+ is the date the type
13
+ # was issued in YYYY or YYYY-MM or YYYY-MM-DD format. The +specific+ is a name for
14
+ # the type being added.
15
+ #
16
+ # For example, built-in YAML types have 'yaml.org' as the +authorityName+ and '2002' as the
17
+ # +date+. The +specific+ is simply the name of the type:
18
+ #
19
+ # tag:yaml.org,2002:int
20
+ # tag:yaml.org,2002:float
21
+ # tag:yaml.org,2002:timestamp
22
+ #
23
+ # The domain must be owned by you on the +date+ declared. If you don't own any domains on the
24
+ # date you declare the type, you can simply use an e-mail address.
25
+ #
26
+ # tag:why@ruby-lang.org,2004:notes/personal
27
+ #
28
+ def self.tag_class( tag, cls )
29
+ if @@tagged_classes.has_key? tag
30
+ warn "class #{ @@tagged_classes[tag] } held ownership of the #{ tag } tag"
31
+ end
32
+ @@tagged_classes[tag] = cls
33
+ end
34
+
35
+ # Returns the complete dictionary of taguris, paired with classes. The key for
36
+ # the dictionary is the full taguri. The value for each key is the class constant
37
+ # associated to that taguri.
38
+ #
39
+ # YAML.tagged_classes["tag:yaml.org,2002:int"] => Integer
40
+ #
41
+ def self.tagged_classes
42
+ @@tagged_classes
43
+ end
44
+ end
45
+
46
+ class Module # :nodoc: all
47
+ def yaml_as( tag, sc = true )
48
+ class_eval <<-"end;", __FILE__, __LINE__+1
49
+ attr_writer :taguri
50
+ def taguri
51
+ return @taguri if defined?(@taguri) and @taguri
52
+ tag = #{ tag.dump }
53
+ if self.class.yaml_tag_subclasses? and self.class != RbYAML::tagged_classes[tag]
54
+ tag = "\#{ tag }:\#{ self.class.yaml_tag_class_name }"
55
+ end
56
+ tag
57
+ end
58
+ def self.yaml_tag_subclasses?; #{ sc ? 'true' : 'false' }; end
59
+ end;
60
+ RbYAML::tag_class tag, self
61
+ end
62
+ # Transforms the subclass name into a name suitable for display
63
+ # in a subclassed tag.
64
+ def yaml_tag_class_name
65
+ self.name
66
+ end
67
+ # Transforms the subclass name found in the tag into a Ruby
68
+ # constant name.
69
+ def yaml_tag_read_class( name )
70
+ name
71
+ end
72
+ end
@@ -1,7 +1,4 @@
1
-
2
1
  module RbYAML
3
- Token = Struct.new(:start_mark, :end_mark)
4
-
5
2
  class Token
6
3
  def __is_document_start; false; end
7
4
  def __is_document_end; false; end
@@ -34,8 +31,7 @@ module RbYAML
34
31
  "<directive>"
35
32
  end
36
33
  attr_reader :name, :value
37
- def initialize(name, value, start_mark, end_mark)
38
- super(start_mark,end_mark)
34
+ def initialize(name, value)
39
35
  @name = name
40
36
  @value = value
41
37
  end
@@ -61,8 +57,7 @@ module RbYAML
61
57
  "<stream start>"
62
58
  end
63
59
  attr_reader :encoding
64
- def initialize(start_mark=nil, end_mark=nil, encoding=nil)
65
- super(start_mark,end_mark)
60
+ def initialize(encoding=nil)
66
61
  @encoding = encoding
67
62
  end
68
63
  end
@@ -157,8 +152,7 @@ module RbYAML
157
152
  "<alias>"
158
153
  end
159
154
  attr_reader :value
160
- def initialize(value, start_mark, end_mark)
161
- super(start_mark,end_mark)
155
+ def initialize(value)
162
156
  @value = value
163
157
  end
164
158
  end
@@ -169,8 +163,7 @@ module RbYAML
169
163
  "<anchor>"
170
164
  end
171
165
  attr_reader :value
172
- def initialize(value, start_mark, end_mark)
173
- super(start_mark,end_mark)
166
+ def initialize(value)
174
167
  @value = value
175
168
  end
176
169
  end
@@ -181,8 +174,7 @@ module RbYAML
181
174
  "<tag>"
182
175
  end
183
176
  attr_reader :value
184
- def initialize(value, start_mark, end_mark)
185
- super(start_mark,end_mark)
177
+ def initialize(value)
186
178
  @value = value
187
179
  end
188
180
  end
@@ -193,12 +185,26 @@ module RbYAML
193
185
  "<scalar>"
194
186
  end
195
187
  attr_reader :value, :plain, :style
196
- alias :implicit :plain #Until all references to ScalarToken.implicit has been removed
197
- def initialize(value, plain, start_mark, end_mark, style=nil)
198
- super(start_mark, end_mark)
188
+ def initialize(value, plain, style=nil)
199
189
  @value = value
200
190
  @plain = plain
201
191
  @style = style
202
192
  end
203
193
  end
194
+
195
+ DOCUMENT_START = DocumentStartToken.new
196
+ DOCUMENT_END = DocumentEndToken.new
197
+ BLOCK_MAPPING_START = BlockMappingStartToken.new
198
+ BLOCK_SEQUENCE_START = BlockSequenceStartToken.new
199
+ BLOCK_ENTRY = BlockEntryToken.new
200
+ BLOCK_END = BlockEndToken.new
201
+ FLOW_ENTRY = FlowEntryToken.new
202
+ FLOW_MAPPING_END = FlowMappingEndToken.new
203
+ FLOW_MAPPING_START = FlowMappingStartToken.new
204
+ FLOW_SEQUENCE_END = FlowSequenceEndToken.new
205
+ FLOW_SEQUENCE_START = FlowSequenceStartToken.new
206
+ KEY = KeyToken.new
207
+ VALUE = ValueToken.new
208
+ STREAM_END = StreamEndToken.new
209
+ STREAM_START = StreamStartToken.new
204
210
  end
@@ -1,14 +1,35 @@
1
1
 
2
2
  module RbYAML
3
+ Token = Struct.new(:start_mark, :end_mark)
4
+
3
5
  class Token
4
- attr_reader :start_mark, :end_mark
5
- def initialize(start_mark, end_mark)
6
- @start_mark = start_mark
7
- @end_mark = end_mark
6
+ def __is_document_start; false; end
7
+ def __is_document_end; false; end
8
+ def __is_stream_start; false; end
9
+ def __is_stream_end; false; end
10
+ def __is_directive; false; end
11
+ def __is_block_sequence_start; false; end
12
+ def __is_block_mapping_start; false; end
13
+ def __is_block_end; false; end
14
+ def __is_flow_sequence_start; false; end
15
+ def __is_flow_mapping_start; false; end
16
+ def __is_flow_sequence_end; false; end
17
+ def __is_flow_mapping_end; false; end
18
+ def __is_key; false; end
19
+ def __is_value; false; end
20
+ def __is_block_entry; false; end
21
+ def __is_flow_entry; false; end
22
+ def __is_alias; false; end
23
+ def __is_anchor; false; end
24
+ def __is_tag; false; end
25
+ def __is_scalar; false; end
26
+ def hash
27
+ object_id
8
28
  end
9
29
  end
10
30
 
11
31
  class DirectiveToken < Token
32
+ def __is_directive; true; end
12
33
  def tid
13
34
  "<directive>"
14
35
  end
@@ -21,18 +42,21 @@ module RbYAML
21
42
  end
22
43
 
23
44
  class DocumentStartToken < Token
45
+ def __is_document_start; true; end
24
46
  def tid
25
47
  "<document start>"
26
48
  end
27
49
  end
28
50
 
29
51
  class DocumentEndToken < Token
52
+ def __is_document_end; true; end
30
53
  def tid
31
54
  "<document end>"
32
55
  end
33
56
  end
34
57
 
35
58
  class StreamStartToken < Token
59
+ def __is_stream_start; true; end
36
60
  def tid
37
61
  "<stream start>"
38
62
  end
@@ -44,78 +68,91 @@ module RbYAML
44
68
  end
45
69
 
46
70
  class StreamEndToken < Token
71
+ def __is_stream_end; true; end
47
72
  def tid
48
73
  "<stream end>"
49
74
  end
50
75
  end
51
76
 
52
77
  class BlockSequenceStartToken < Token
78
+ def __is_block_sequence_start; true; end
53
79
  def tid
54
80
  "<block sequence start>"
55
81
  end
56
82
  end
57
83
 
58
84
  class BlockMappingStartToken < Token
85
+ def __is_block_mapping_start; true; end
59
86
  def tid
60
87
  "<block mapping start>"
61
88
  end
62
89
  end
63
90
 
64
91
  class BlockEndToken < Token
92
+ def __is_block_end; true; end
65
93
  def tid
66
94
  "<block end>"
67
95
  end
68
96
  end
69
97
 
70
98
  class FlowSequenceStartToken < Token
99
+ def __is_flow_sequence_start; true; end
71
100
  def tid
72
101
  "["
73
102
  end
74
103
  end
75
104
 
76
105
  class FlowMappingStartToken < Token
106
+ def __is_flow_mapping_start; true; end
77
107
  def tid
78
108
  "{"
79
109
  end
80
110
  end
81
111
 
82
112
  class FlowSequenceEndToken < Token
113
+ def __is_flow_sequence_end; true; end
83
114
  def tid
84
115
  "]"
85
116
  end
86
117
  end
87
118
 
88
119
  class FlowMappingEndToken < Token
120
+ def __is_flow_mapping_end; true; end
89
121
  def tid
90
122
  "}"
91
123
  end
92
124
  end
93
125
 
94
126
  class KeyToken < Token
127
+ def __is_key; true; end
95
128
  def tid
96
129
  "?"
97
130
  end
98
131
  end
99
132
 
100
133
  class ValueToken < Token
134
+ def __is_value; true; end
101
135
  def tid
102
136
  ":"
103
137
  end
104
138
  end
105
139
 
106
140
  class BlockEntryToken < Token
141
+ def __is_block_entry; true; end
107
142
  def tid
108
143
  "-"
109
144
  end
110
145
  end
111
146
 
112
147
  class FlowEntryToken < Token
148
+ def __is_flow_entry; true; end
113
149
  def tid
114
150
  ","
115
151
  end
116
152
  end
117
153
 
118
154
  class AliasToken < Token
155
+ def __is_alias; true; end
119
156
  def tid
120
157
  "<alias>"
121
158
  end
@@ -127,6 +164,7 @@ module RbYAML
127
164
  end
128
165
 
129
166
  class AnchorToken < Token
167
+ def __is_anchor; true; end
130
168
  def tid
131
169
  "<anchor>"
132
170
  end
@@ -138,6 +176,7 @@ module RbYAML
138
176
  end
139
177
 
140
178
  class TagToken < Token
179
+ def __is_tag; true; end
141
180
  def tid
142
181
  "<tag>"
143
182
  end
@@ -149,6 +188,7 @@ module RbYAML
149
188
  end
150
189
 
151
190
  class ScalarToken < Token
191
+ def __is_scalar; true; end
152
192
  def tid
153
193
  "<scalar>"
154
194
  end