source: branches/pyyaml3000/lib/yaml/__init__.py @ 53

Revision 53, 1.3 KB checked in by xi, 8 years ago (diff)

Implement Composer and BaseResolver?.

RevLine 
[51]1
[53]2from error import YAMLError
[51]3from reader import Reader
4from scanner import Scanner
5from parser import Parser
[53]6from composer import Composer
7from resolver import Resolver
[51]8
9from tokens import *
10from events import *
11
12def scan(data, Reader=Reader, Scanner=Scanner):
13    reader = Reader(data)
14    scanner = Scanner(reader)
15    return iter(scanner)
16
17def parse(data, Reader=Reader, Scanner=Scanner, Parser=Parser):
18    reader = Reader(data)
19    scanner = Scanner(reader)
20    parser = Parser(scanner)
21    return iter(parser)
22
[53]23def compose(data, Reader=Reader, Scanner=Scanner, Parser=Parser,
24        Composer=Composer):
25    reader = Reader(data)
26    scanner = Scanner(reader)
27    parser = Parser(scanner)
28    composer = Composer(parser)
29    return iter(composer)
30
31def compose_document(*args, **kwds):
32    try:
33        return compose(*args, **kwds).next()
34    except StopIteration:
35        return None
36
37def resolve(data, Reader=Reader, Scanner=Scanner, Parser=Parser,
38        Composer=Composer, Resolver=Resolver):
39    reader = Reader(data)
40    scanner = Scanner(reader)
41    parser = Parser(scanner)
42    composer = Composer(parser)
43    resolver = Resolver(composer)
44    return iter(resolver)
45
46def resolve_document(*args, **kwds):
47    try:
48        return resolve(*args, **kwds).next()
49    except StopIteration:
50        return None
51
Note: See TracBrowser for help on using the repository browser.