Index: branches/pyyaml3000/lib/yaml/parser.py
===================================================================
--- branches/pyyaml3000/lib/yaml/parser.py	(revision 51)
+++ branches/pyyaml3000/lib/yaml/parser.py	(revision 52)
@@ -21,5 +21,8 @@
 # flow_sequence_entry   ::= flow_node | KEY flow_node? (VALUE flow_node?)?
 # flow_mapping_entry    ::= flow_node | KEY flow_node? (VALUE flow_node?)?
-#
+
+# TODO: support for BOM within a stream.
+# stream ::= (BOM? implicit_document)? (BOM? explicit_document)* STREAM-END
+
 # Note that there is a slight deviation from the specification. We require a
 # non-empty node content if ANCHOR or TAG is specified. This disallow such
@@ -59,26 +62,10 @@
 # flow_mapping_entry: { ALIAS ANCHOR TAG SCALAR FLOW-SEQUENCE-START FLOW-MAPPING-START KEY }
 
-from error import YAMLError
+from error import MarkedYAMLError
 from tokens import *
 from events import *
 
-class ParserError(YAMLError):
-
-    def __init__(self, context=None, context_marker=None,
-            problem=None, problem_marker=None):
-        self.context = context
-        self.context_marker = context_marker
-        self.problem = problem
-        self.problem_marker = problem_marker
-
-    def __str__(self):
-        lines = []
-        for (place, marker) in [(self.context, self.context_marker),
-                                (self.problem, self.problem_marker)]:
-            if place is not None:
-                lines.append(place)
-                if marker is not None:
-                    lines.append(str(marker))
-        return '\n'.join(lines)
+class ParserError(MarkedYAMLError):
+    pass
 
 class Parser:
@@ -169,10 +156,10 @@
                 if self.yaml_version is not None:
                     raise ParserError(None, None,
-                            "found duplicate YAML directive", token.start_marker())
+                            "found duplicate YAML directive", token.start_marker)
                 major, minor = token.value
                 if major != 1:
                     raise ParserError(None, None,
                             "found incompatible YAML document (version 1.* is required)",
-                            token.start_marker())
+                            token.start_marker)
                 self.yaml_version = token.value
             elif token.name == u'TAG':
@@ -181,5 +168,5 @@
                     raise ParserError(None, None,
                             "duplicate tag handle %r" % handle.encode('utf-8'),
-                            token.start_marker())
+                            token.start_marker)
                 self.tag_handles[handle] = prefix
         for key in self.DEFAULT_TAGS:
@@ -394,8 +381,4 @@
             if self.scanner.check(FlowEntryToken):
                 self.scanner.get()
-        if not self.scanner.check(FlowSequenceEndToken):
-            token = self.scanner.peek()
-            raise ParserError("while scanning a flow sequence", start_marker,
-                    "expected ']', but found %r" % token.id, token.start_marker)
         token = self.scanner.get()
         yield CollectionEndEvent(token.start_marker, token.end_marker)
