Changeset 328 for pyyaml/trunk/lib3/yaml/parser.py
- Timestamp:
- 12/29/08 12:24:05 (4 years ago)
- Location:
- pyyaml/trunk/lib3
- Files:
-
- 1 edited
- 1 copied
-
. (copied) (copied from pyyaml/trunk/lib)
-
yaml/parser.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pyyaml/trunk/lib3/yaml/parser.py
r302 r328 62 62 __all__ = ['Parser', 'ParserError'] 63 63 64 from error import MarkedYAMLError65 from tokens import *66 from events import *67 from scanner import *64 from .error import MarkedYAMLError 65 from .tokens import * 66 from .events import * 67 from .scanner import * 68 68 69 69 class ParserError(MarkedYAMLError): 70 70 pass 71 71 72 class Parser (object):72 class Parser: 73 73 # Since writing a recursive-descendant parser is a straightforward task, we 74 74 # do not give many comments here. 75 75 76 76 DEFAULT_TAGS = { 77 u'!': u'!',78 u'!!': u'tag:yaml.org,2002:',77 '!': '!', 78 '!!': 'tag:yaml.org,2002:', 79 79 } 80 80 … … 215 215 while self.check_token(DirectiveToken): 216 216 token = self.get_token() 217 if token.name == u'YAML':217 if token.name == 'YAML': 218 218 if self.yaml_version is not None: 219 219 raise ParserError(None, None, … … 225 225 token.start_mark) 226 226 self.yaml_version = token.value 227 elif token.name == u'TAG':227 elif token.name == 'TAG': 228 228 handle, prefix = token.value 229 229 if handle in self.tag_handles: 230 230 raise ParserError(None, None, 231 "duplicate tag handle %r" % handle .encode('utf-8'),231 "duplicate tag handle %r" % handle, 232 232 token.start_mark) 233 233 self.tag_handles[handle] = prefix … … 299 299 if handle not in self.tag_handles: 300 300 raise ParserError("while parsing a node", start_mark, 301 "found undefined tag handle %r" % handle .encode('utf-8'),301 "found undefined tag handle %r" % handle, 302 302 tag_mark) 303 303 tag = self.tag_handles[handle]+suffix 304 304 else: 305 305 tag = suffix 306 #if tag == u'!':306 #if tag == '!': 307 307 # raise ParserError("while parsing a node", start_mark, 308 308 # "found non-specific tag '!'", tag_mark, … … 311 311 start_mark = end_mark = self.peek_token().start_mark 312 312 event = None 313 implicit = (tag is None or tag == u'!')313 implicit = (tag is None or tag == '!') 314 314 if indentless_sequence and self.check_token(BlockEntryToken): 315 315 end_mark = self.peek_token().end_mark … … 321 321 token = self.get_token() 322 322 end_mark = token.end_mark 323 if (token.plain and tag is None) or tag == u'!':323 if (token.plain and tag is None) or tag == '!': 324 324 implicit = (True, False) 325 325 elif tag is None: … … 353 353 # Empty scalars are allowed even if a tag or an anchor is 354 354 # specified. 355 event = ScalarEvent(anchor, tag, (implicit, False), u'',355 event = ScalarEvent(anchor, tag, (implicit, False), '', 356 356 start_mark, end_mark) 357 357 self.state = self.states.pop() … … 581 581 582 582 def process_empty_scalar(self, mark): 583 return ScalarEvent(None, None, (True, False), u'', mark, mark)584 583 return ScalarEvent(None, None, (True, False), '', mark, mark) 584
Note: See TracChangeset
for help on using the changeset viewer.
