Changeset 122


Ignore:
Timestamp:
03/20/06 18:31:07 (8 years ago)
Author:
xi
Message:

Add a skeleton of the emitter.

Location:
pyyaml/branches/working-on-emitter
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • pyyaml/branches/working-on-emitter/lib/yaml/__init__.py

    r57 r122  
    77from resolver import * 
    88from constructor import * 
     9 
     10from emitter import * 
    911 
    1012from tokens import * 
  • pyyaml/branches/working-on-emitter/lib/yaml/events.py

    r121 r122  
    11 
    22class Event: 
    3     def __init__(self, start_mark, end_mark): 
     3    def __init__(self, start_mark=None, end_mark=None): 
    44        self.start_mark = start_mark 
    55        self.end_mark = end_mark 
    66    def __repr__(self): 
    7         attributes = [key for key in self.__dict__ 
    8                 if not key.endswith('_mark')] 
    9         attributes.sort() 
     7        attributes = [key for key in ['anchor', 'tag', 'value'] 
     8                if hasattr(self, key)] 
    109        arguments = ', '.join(['%s=%r' % (key, getattr(self, key)) 
    1110                for key in attributes]) 
     
    1312 
    1413class NodeEvent(Event): 
    15     def __init__(self, anchor, start_mark, end_mark): 
     14    def __init__(self, anchor, start_mark=None, end_mark=None): 
    1615        self.anchor = anchor 
    1716        self.start_mark = start_mark 
     
    2221 
    2322class ScalarEvent(NodeEvent): 
    24     def __init__(self, anchor, tag, value, start_mark, end_mark): 
     23    def __init__(self, anchor, tag, value, start_mark=None, end_mark=None): 
    2524        self.anchor = anchor 
    2625        self.tag = tag 
     
    3029 
    3130class CollectionEvent(NodeEvent): 
    32     def __init__(self, anchor, tag, start_mark, end_mark): 
     31    def __init__(self, anchor, tag, start_mark=None, end_mark=None): 
    3332        self.anchor = anchor 
    3433        self.tag = tag 
  • pyyaml/branches/working-on-emitter/lib/yaml/tokens.py

    r121 r122  
    11 
    22class Token: 
    3     def __init__(self, start_mark, end_mark): 
     3    def __init__(self, start_mark=None, end_mark=None): 
    44        self.start_mark = start_mark 
    55        self.end_mark = end_mark 
     
    1717class DirectiveToken(Token): 
    1818    id = '<directive>' 
    19     def __init__(self, name, value, start_mark, end_mark): 
     19    def __init__(self, name, value, start_mark=None, end_mark=None): 
    2020        self.name = name 
    2121        self.value = value 
     
    7070class AliasToken(Token): 
    7171    id = '<alias>' 
    72     def __init__(self, value, start_mark, end_mark): 
     72    def __init__(self, value, start_mark=None, end_mark=None): 
    7373        self.value = value 
    7474        self.start_mark = start_mark 
     
    7777class AnchorToken(Token): 
    7878    id = '<anchor>' 
    79     def __init__(self, value, start_mark, end_mark): 
     79    def __init__(self, value, start_mark=None, end_mark=None): 
    8080        self.value = value 
    8181        self.start_mark = start_mark 
     
    8484class TagToken(Token): 
    8585    id = '<tag>' 
    86     def __init__(self, value, start_mark, end_mark): 
     86    def __init__(self, value, start_mark=None, end_mark=None): 
    8787        self.value = value 
    8888        self.start_mark = start_mark 
     
    9191class ScalarToken(Token): 
    9292    id = '<scalar>' 
    93     def __init__(self, value, plain, start_mark, end_mark): 
     93    def __init__(self, value, plain, start_mark=None, end_mark=None): 
    9494        self.value = value 
    9595        self.plain = plain 
  • pyyaml/branches/working-on-emitter/tests/test_yaml.py

    r121 r122  
    1010from test_detector import * 
    1111from test_constructor import * 
     12from test_emitter import * 
    1213from test_syck import * 
    1314 
Note: See TracChangeset for help on using the changeset viewer.