Commits

Kirill Simonov  committed caa8459 Draft

Move old pyyaml code to the pyyaml-legacy directory.

  • Participants

Comments (0)

Files changed (76)

+- Introductions: >
+   Hello.  Welcome to the Python YAML parser.  This is 
+   a work in progress.   The primary author is Steve Howell,
+   with a few contributions by Clark Evans
+
+- installation: >
+   Simply type setup.py install.  If you do not have distutils
+   installed, you can simply copy the yaml sub-directory into 
+   site-packages.
+
+- testing: >
+   If you want to run all of the tests use the following
+
+   >python2.3 scripts/testrunner.py yaml.tests
+
+   if you haven't installed the module yet you might have to
+
+   >export PYTHONPATH = .
+
+   whilst in the directory above yaml
+
+   This package currently requires python2.3.  We lost Python2.1 support
+   recently, so we should be able to get that back.  Depending on interest
+   we may be able to port back to 1.5, but don't hold your breath.  2.2
+   may work, but at the time of this documentation update, it hadn't been
+   tested.
+
+- playing: >
+   The best way to play, is to start with demo.py and 
+   work from there.  Note that this implementation has quite
+   a way to go before it is compliant with the YAML specification.
+   
+   If something is failing in the tests for your platform
+   please let us know.  If something doesn't work, check the
+   tests to see if the test covering the feature you need is
+   active; if not, chances are it's not implemented.
+
+   Your feedback or any other contributions are certainly welcome.
+
+- ypath: >
+   The YPATH implementation is EXPERIMENTAL but included
+   in the yaml package beacuse it is fun and we'd like to get
+   feedback from the user community as to how they'd like it 
+   to work.  It requries Python >=2.2 since it uses iterators.
+
+- query: >
+   There is a query.py and query.yml file in the experimental directory,
+   it is currently broken as ypath was re-written.
+
+---
+contributors:
+  - who: Steve Howell
+    why?: |
+      Original author of the pure Python implementations of the 
+      YAML parser and emitter.  Many thanks to the other folks 
+      listed here, and some not listed here.  
+    email: showell@zipcon.net
+
+  - who: Brian Ingerson
+    why?: |
+      Brian got me hooked on YAML.  We have used his Perl 
+      implementation to do some really cool stuff, even on projects
+      that primarily used XML.  He also got me started on 
+      the Python project.
+
+  - who: Clark Evans
+    why?: |
+      Clark's YAML fame far precedes the Python implementation--he
+      founded the whole project.  But, he also contributed alias 
+      emitting to this project, and he's also generously allowed
+      me to bundle his very cool YPATH implementation.  Finally,
+      he's helped with module packaging issues and miscellaneous
+      features and bug fixes.
+
+  - who: Why The Lucky Stiff
+    why?: |
+      That's right, Why's the name, Ruby's the game.  Why devotes
+      most of his YAML effort to a Ruby implementation that grows
+      increasingly robust, but he's also a great team player on 
+      the YAML project.  For example, he consolidated the YAML
+      testing suites, so that multiple YAML implementations can 
+      share the same YAML test files.  If you look in this YAML
+      distribution, you will see Ruby all over the place.  Think
+      of it as a free introduction to another great scripting 
+      language.
+
+  - who: Ryan King
+    why?: |
+      Sharpener of saws and pair programmer extraordinaire.
+
+  - who: Neil Watkiss
+    why?: |
+      Donated hardware and major expertise to the project.       
+
+  - who: Oren Ben-Kiki
+    why?: |
+      YAML cofounder.  All library implementors owe a huge gratitude 
+      toward Oren for his work on the YAML spec.
+
+  - who: Lion Kimbro
+    why?: |
+      Early adopter, also known for his three-humped YAML.
+       
+  - who: Dave Kuhlman
+    why?: |
+      Dave's contributions include, but are not limited to, the 
+      XmlYaml code bundled with this distribution.  The README
+      with that code talks more about Dave.
+
+  - who: Tim Parkin
+    why?: |
+      Been using yaml for a while and wanted to use it more and see it adopted
+      more so put a little effort into a home and a spring clean
+
+  - who: Seth de l'Isle
+    why?: |
+      Love YAML. Installing syck is not always convenient and pyyaml is
+      looking very unmaintained;  I was initially motivated by security
+      vulnerabilities announced on the python mailing list.  Now I'm going to
+      focus on spec. compatibility and perhaps integrating syck.
+
+tests are located in the tests module under yaml. These can be run using
+
+python2.3 scripts/testrunner.py yaml.tests
+
+or wherever else as long as the yaml module  is in the pythonpath

File assets/pyyaml_banner.png

Added
New image

File docs/CHANGELOG

+---
+- version: 0.35
+  date: 2004-07-10
+  changes:
+    - yaml.file()
+    - unit tests for all tests
+---
+- version: 0.32
+  date: 2002-12-26
+  changes:
+    - report filenames in loadFile exceptions
+    - added loadOrdered() method
+---
+- version: 0.31
+  date: 2002-11-17
+  changes:
+    - dumper doesn't quote strings just because they have dashes
+    - dumper does quote strings that look like negative numbers
+    - dumper does quote strings w/*, &, and white space on edges
+    - dumper doesn't quote strings starting with "* "
+    - loader can tolerate "* " unquoted
+    - complain about duplicate keys in dictionary
+    - complain about trailing spaces
+    - l() and d() convenience methods
+    - applied Tim Hochberg's FLOAT/SCIENTIFIC patch
+    - sync __version__ to CHANGELOG
+---
+- version: 0.30
+  date: 2002-11-06
+  changes:
+    - bunch of changes for 2.1 support
+    - fully tested on 2.1.3 and 2.2
+    - added YamlLoaderException
+    - pluggable dictionaries (2.2 only)
+    - simplified iterator interface (deprecated getNextDocument)
+    - single quote &foo properly
+    - quote "foo'bar properly
+---
+- version: 0.29
+  date: 2002-11-03
+  changes:
+    - support |+ syntax
+---
+- version: 0.28
+  date: 2002-09-25
+  changes:
+    - use compiled regexes for speed
+    - streamlined stream.py for speed
+    - added profileYaml.py
+---
+- version: 0.27
+  date: 2002-09-24
+  changes:
+    - better error handling
+    - removed spurious spaces from specs.yml
+    - use a true FileStream class vs. reading in entire file up front
+---
+- version: 0.26
+  date: 2002-09-23
+  changes:
+    - support to_yaml() when you inherit from Python's dict class
+    - move implicit and inline logic into own modules
+    - require space after comma for inline collections (Brian Dorsey)
+    - only call user's resolver for !!private types
+    - don't choke on !str, etc. (but doesn't yet respect them)
+    - fixed bugs in loader/dumper related to integer dict keys (Joel Shprentz)
+---
+- version: 0.25
+  date: 2002-08-21
+  changes:
+    - extensive refactorings on dumper
+    - Dumper class made public
+    - new interface for setIndent and setSort
+    - added Dave Kuhlman's XmlYaml stuff
+    - limiting support to Python 2.2 and above
+
+

File docs/LICENSE

+A. HISTORY OF THE SOFTWARE
+==========================
+
+The Python library for YAML was started by Steve Howell in 
+February 2002.  Steve is the primary author of the project,
+but others have contributed.  See the README for more on 
+the project.  The term "PyYaml" refers to the entire 
+distribution of this library, including examples, documentation,
+and test files, as well as the core implementation.
+
+This library is intended for general use, and the license 
+below protects the "open source" nature of the library.  The 
+license does, however, allow for use of the library in 
+commercial applications as well, subject to the terms 
+and conditions listed.  The license below is a minor 
+rewrite of the Python 2.2 license, with no substantive 
+differences.
+
+
+B. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PyYaml
+===============================================================
+
+LICENSE AGREEMENT FOR PyYaml
+----------------------------
+
+1. This LICENSE AGREEMENT is between Stephen S. Howell ("Author"), 
+and the Individual or Organization ("Licensee") accessing and
+otherwise using PyYaml software in source or binary form and its
+associated documentation.
+
+2. Subject to the terms and conditions of this License Agreement, Author
+hereby grants Licensee a nonexclusive, royalty-free, world-wide
+license to reproduce, analyze, test, perform and/or display publicly,
+prepare derivative works, distribute, and otherwise use PyYaml
+alone or in any derivative version, provided, however, that Author's
+License Agreement and Author's notice of copyright, i.e., "Copyright (c)
+2001 Steve Howell and Friends; All Rights Reserved" are never removed
+from PyYaml, and are included in any derivative version prepared by Licensee.
+
+3. In the event Licensee prepares a derivative work that is based on
+or incorporates PyYaml or any part thereof, and wants to make
+the derivative work available to others as provided herein, then
+Licensee hereby agrees to include in any such work a brief summary of
+the changes made to PyYaml.
+
+4. Author is making PyYaml available to Licensee on an "AS IS"
+basis.  Author MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
+IMPLIED.  BY WAY OF EXAMPLE, BUT NOT LIMITATION, Author MAKES NO AND
+DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
+FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PyYaml WILL NOT
+INFRINGE ANY THIRD PARTY RIGHTS.
+
+5. Author SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
+2.2 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
+A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 2.2,
+OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
+
+6. This License Agreement will automatically terminate upon a material
+breach of its terms and conditions.
+
+7. Nothing in this License Agreement shall be deemed to create any
+relationship of agency, partnership, or joint venture between Author and
+Licensee.  This License Agreement does not grant permission to use Author
+trademarks or trade name in a trademark sense to endorse or promote
+products or services of Licensee, or any third party.
+
+8. By copying, installing or otherwise using PyYaml, Licensee
+agrees to be bound by the terms and conditions of this License
+Agreement.
+
+

File docs/LIMITATIONS

+PYTHON VERSION: >
+   PyYaml is now being develioed on version 2.3. If version 2.2 is needed
+   we're happy to look at the nescessities. There won't be unjustified 
+   uses of 2.3 if possible although at some point it's likely. Keep watching
+   for further news
+
+DISCLAIMER: > 
+   PyYaml is not ready to be used as a robust serialization tool,
+   although it is moving in that direction, and you can certainly
+   experiment with it. This sentence may still be true?
+
+   You can use it more safely for one-way applications.  You can
+   make YAML be an input-tool only, such as for configuration files
+   or data-driven programs.  You can also use YAML as an output-only
+   tool, for things like logging and debugging.
+
+   You can report bugs on http://pyyaml.dnsalias.org or through
+   lists.pollenation.dnsalias.org/mailman/listinfo/pyyaml.
+
+SOME KNOWN BUGS/LIMITATIONS:
+  These will be reveiwed (TP JUL 04)
+
+  - folded scalars can't lead with blank line
+  - emitter gives invalid YAML for multi-line scalars starting w/whitespace
+  - trailing white space after quotes not ignored
+  - support for inlined hashes and arrays very primitize--can't nest
+    structures and must use simple scalars
+  - specifiers like !str, !int, etc. are ignored
+

File docs/TESTING

+--- >
+As of July 2002, PyYaml shares its YAML-based testing suite with 
+other YAML implementations, starting with YamlForRuby.  Many
+thanks to Why The Lucky Stuff, the author of YamlForRuby, for
+setting this up.
+
+As of July 2004, Testing will be moving to a tests directory. profileYaml.py is currently runs the TestingSuite

File examples/CHANGELOG

+---
+- version: 0.35
+  date: 2004-07-10
+  changes:
+    - yaml.file()
+    - unit tests for all tests
+---
+- version: 0.32
+  date: 2002-12-26
+  changes:
+    - report filenames in loadFile exceptions
+    - added loadOrdered() method
+---
+- version: 0.31
+  date: 2002-11-17
+  changes:
+    - dumper doesn't quote strings just because they have dashes
+    - dumper does quote strings that look like negative numbers
+    - dumper does quote strings w/*, &, and white space on edges
+    - dumper doesn't quote strings starting with "* "
+    - loader can tolerate "* " unquoted
+    - complain about duplicate keys in dictionary
+    - complain about trailing spaces
+    - l() and d() convenience methods
+    - applied Tim Hochberg's FLOAT/SCIENTIFIC patch
+    - sync __version__ to CHANGELOG
+---
+- version: 0.30
+  date: 2002-11-06
+  changes:
+    - bunch of changes for 2.1 support
+    - fully tested on 2.1.3 and 2.2
+    - added YamlLoaderException
+    - pluggable dictionaries (2.2 only)
+    - simplified iterator interface (deprecated getNextDocument)
+    - single quote &foo properly
+    - quote "foo'bar properly
+---
+- version: 0.29
+  date: 2002-11-03
+  changes:
+    - support |+ syntax
+---
+- version: 0.28
+  date: 2002-09-25
+  changes:
+    - use compiled regexes for speed
+    - streamlined stream.py for speed
+    - added profileYaml.py
+---
+- version: 0.27
+  date: 2002-09-24
+  changes:
+    - better error handling
+    - removed spurious spaces from specs.yml
+    - use a true FileStream class vs. reading in entire file up front
+---
+- version: 0.26
+  date: 2002-09-23
+  changes:
+    - support to_yaml() when you inherit from Python's dict class
+    - move implicit and inline logic into own modules
+    - require space after comma for inline collections (Brian Dorsey)
+    - only call user's resolver for !!private types
+    - don't choke on !str, etc. (but doesn't yet respect them)
+    - fixed bugs in loader/dumper related to integer dict keys (Joel Shprentz)
+---
+- version: 0.25
+  date: 2002-08-21
+  changes:
+    - extensive refactorings on dumper
+    - Dumper class made public
+    - new interface for setIndent and setSort
+    - added Dave Kuhlman's XmlYaml stuff
+    - limiting support to Python 2.2 and above
+
+

File examples/README

+- Introductions: >
+   Hello.  Welcome to the Python YAML parser.  This is 
+   a work in progress.   The primary author is Steve Howell,
+   with a few contributions by Clark Evans.
+
+- installation: >
+   Simply type "make install" as root, this runs python setup.py install.
+   If you do not have distutils installed, you can simply copy the
+   yaml sub-directory into site-packages.
+
+- testing: >
+   You should be able to type "make test" both before and
+   after the installation.  This simply runs python on the
+   test programs.
+
+   This package uses python iterators, but there is a surrogate
+   which returns a list object instead of an iterator for python
+   versions below 2.2
+
+   This package should work with 1.5.2 and up, although many of
+   the tests fail with 1.5.2; if you are an expert with 1.5.2
+   please help us patch this up so that it works on older versions
+   of Python.
+
+- playing: >
+   The best way to play, is to start with demo.py and 
+   work from there.  Note that this implementation has quite
+   a way to go before it is compliant with the YAML specification.
+   
+   If something is failing in the tests for your platform
+   please let us know.  If something doesn't work, check the
+   tests to see if the test covering the feature you need is
+   active; if not, chances are it's not implemented.
+
+   Your feedback or any other contributions are certainly welcome.
+
+- ypath: >
+   The YPATH implementation is EXPERIMENTAL but included
+   in the yaml package beacuse it is fun and we'd like to get
+   feedback from the user community as to how they'd like it 
+   to work.  It requries Python 2.2 since it uses iterators.
+
+- query: >
+   There is a query.py and query.yml file in this directory,
+   it is currently broke as ypath was re-written.
+
+---
+contributors:
+  - who: Steve Howell
+    why?: |
+      Original author of the pure Python implementations of the 
+      YAML parser and emitter.  Many thanks to the other folks 
+      listed here, and some not listed here.  
+    email: showell@zipcon.net
+
+  - who: Brian Ingerson
+    why?: |
+      Brian got me hooked on YAML.  We have used his Perl 
+      implementation to do some really cool stuff, even on projects
+      that primarily used XML.  He also got me started on 
+      the Python project.
+
+  - who: Clark Evans
+    why?: |
+      Clark's YAML fame far precedes the Python implementation--he
+      founded the whole project.  But, he also contributed alias 
+      emitting to this project, and he's also generously allowed
+      me to bundle his very cool YPATH implementation.  Finally,
+      he's helped with module packaging issues and miscellaneous
+      features and bug fixes.
+
+  - who: Why The Lucky Stiff
+    why?: |
+      That's right, Why's the name, Ruby's the game.  Why devotes
+      most of his YAML effort to a Ruby implementation that grows
+      increasingly robust, but he's also a great team player on 
+      the YAML project.  For example, he consolidated the YAML
+      testing suites, so that multiple YAML implementations can 
+      share the same YAML test files.  If you look in this YAML
+      distribution, you will see Ruby all over the place.  Think
+      of it as a free introduction to another great scripting 
+      language.
+
+  - who: Ryan King
+    why?: |
+      Sharpener of saws and pair programmer extraordinaire.
+
+  - who: Neil Watkiss
+    why?: |
+      Donated hardware and major expertise to the project.       
+
+  - who: Oren Ben-Kiki
+    why?: |
+      YAML cofounder.  All library implementors owe a huge gratitude 
+      toward Oren for his work on the YAML spec.
+
+  - who: Lion Kimbro
+    why?: |
+      Early adopter, also known for his three-humped YAML.
+       
+  - who: Dave Kuhlman
+    why?: |
+      Dave's contributions include, but are not limited to, the 
+      XmlYaml code bundled with this distribution.  The README
+      with that code talks more about Dave.

File examples/demo.py

+import yaml, string
+
+####### RUNNING YAML AGAINST THE README AND CHANGELOG
+
+readme = yaml.loadFile("README")
+print "README"
+for item in readme.next():
+    print item
+print "\n\nCONTRIBUTORS"
+for person in readme.next()['contributors']:
+    print "===%s===" % person['who']
+    print person['why?']
+    print
+print "\n\n"
+print "CHANGELOG:\n"
+print list(yaml.loadFile("CHANGELOG"))
+print "\n\n"
+
+######## USING YAML INSIDE YOUR PROGRAM
+
+testData = \
+"""
+program: PyYaml
+author: Steve Howell
+---
+shopping list:
+ - apple
+ - banana
+todo:
+ - eat more fruit:
+     - especially bananas!
+     - good for you
+ - write a better demo
+"""
+
+print "YAML INSIDE YOUR PROGRAM"
+for x in yaml.load(testData):
+   print repr(x)
+print "\n\n"
+
+
+######### YPATH STUFF
+
+try:
+    print "YPATH EXPERIMENTATION"
+    data = yaml.load(testData)
+    print yaml.ypath("/author",data.next()).next()
+    print yaml.dump(yaml.ypath("/todo/0",data.next()).next())
+except NotImplementedError:
+    print "Experimental YPATH requires Python 2.2"
+
+######### YAML DUMPER 
+
+class Person:
+    def __init__(self, fname, lname, salary, children):
+        self.fname = fname
+        self.lname = lname
+        self.salary = salary
+        self.children = children
+        # private variables
+        self._fullname = fname + ' ' + lname
+        if salary:
+            self._sal_per_month = salary / 12.0
+        self._num_children = len(children)
+    def to_yaml(self):
+        return ({
+            'first name': self.fname,
+            'last name':  self.lname,
+            'salary':     self.salary
+        }, '!!Person')
+
+mrBarson = Person('Foo', 'Barson', 20, ['ex', 'theomatic'])
+mrDoe = Person('John', 'Doe', None, [])
+print yaml.dump([mrBarson, mrDoe])
+
+print "\n\nANOTHER WAY TO STDOUT:\n"
+import sys
+yaml.dumpToFile(sys.stdout, [mrBarson, mrDoe])
+
+print "\n\nDUMP MULTIPLE DOCS TO A FILE:\n"
+file = open('DEMO_OUTPUT.TXT', 'w')
+yaml.dumpToFile(file, 
+    {'source': "Demo output from demo.py"},
+    [
+        'apple',
+        'banana',
+    ],
+    'Third document'      
+)
+file.close()
+
+

File experimental/IncludeHack/demo.py

+import yaml
+
+def writeFile(fn, data):
+    f = open(fn, 'w')
+    f.write(data)
+
+writeFile('toplevel.yml', """
+    - doc1: !!include doc1.yml
+    - doc2: !!include doc2.yml
+    """)
+
+writeFile('doc1.yml', "foo: bar")
+writeFile('doc2.yml', "more: stuff")
+
+class Includer:
+    def resolveType(self, value, url):
+        return yaml.loadFile(value).next()
+
+print yaml.loadFile('toplevel.yml', Includer()).next()

File experimental/IncludeHack/doc1.yml

+foo: bar

File experimental/IncludeHack/doc2.yml

+more: stuff

File experimental/IncludeHack/toplevel.yml

+
+    - doc1: !!include doc1.yml
+    - doc2: !!include doc2.yml
+    

File experimental/XmlYaml/README_yaml2xml

+                   Convert XML to and from YAML
+                   ============================
+
+
+===========
+Description
+===========
+
+This mini-package contains two implementations of conversion
+routines that convert XML to YAML and YAML to XML.  These two
+implementations use different canonical representations for XML in
+YAML as follows:
+
+convertyaml_map.py uses the following representation:
+
+    The canonical YAML representation of an XML element is a
+    dictionary (mapping) containing the following key/value pairs:
+        (1) "name" (required) -- a string.
+        (2) "attributes" (optional) -- a dictionary (mapping) of name/value
+            pairs.
+        (3) "text" (optional) -- a string.
+        (4) "children" (optional) -- a sequence of dictionaries (mappings).
+
+convertyaml_seq.py uses the following representation:
+
+    The canonical YAML representation of an XML element is a 4-tuple
+    (a sequence) containing the following:
+        (1) element name
+        (2) attributes -- a mapping
+        (3) text -- a string
+        (4) children -- a sequence of elements
+
+Basically, convertyaml_map.py uses keywords (in a dictionary) to
+represent structures and convertyaml_seq.py uses position (within a
+list).
+
+=====
+Usage
+=====
+
+There is some usage information at the top of each implementation
+file.
+
+
+=======
+Testing
+=======
+
+Here are some simple tests:
+
+    python convertyaml_map.py -x2y people.xml
+    python convertyaml_map.py -x2y people.xml > people.yml
+    python convertyaml_map.py -y2x people.yml
+
+    python convertyaml_seq.py -x2y people.xml
+    python convertyaml_seq.py -x2y people.xml > people.yml
+    python convertyaml_seq.py -y2x people.yml
+
+
+======================
+Additional Information
+======================
+
+The YAML home site is at:
+
+    http://www.yaml.org/
+
+
+
+
+
+Dave Kuhlman
+dkuhlman@rexx.com
+http://www.rexx.com/~dkuhlman
+
+

File experimental/XmlYaml/convertyaml_map.py

+#!/usr/bin/env python
+"""
+Sample code to convert YAML to XML and XML to YAML using a canonical
+form.
+
+The canonical YAML representation of an XML element is a
+dictionary (mapping) containing the following key/value pairs:
+    (1) "name" (required) -- a string.
+    (2) "attributes" (optional) -- a dictionary (mapping) of name/value
+        pairs.
+    (3) "text" (optional) -- a string.
+    (4) "children" (optional) -- a sequence of dictionaries (mappings).
+
+For usage information, type:
+    python convertyaml_map.py
+
+Usage: python convertyaml_map.py <option> <in_file>
+
+Options:
+    -y2x    Convert YAML file to XML document.
+    -x2y    Convert XML document to YAML.
+
+
+Requirements:
+    PyXML
+    PyYaml
+
+"""
+
+import sys, string, re, types
+import yaml
+
+from xml.dom import minidom
+from xml.dom import Node
+
+
+#
+# Convert a YAML file to XML and write it to stdout.
+#
+def convertYaml2Xml(inFileName):
+    inobj = yaml.loadFile(inFileName)
+    out = []
+    level = 0
+    convertYaml2XmlAux(inobj, level, out)
+    outStr = "".join(out)
+    sys.stdout.write(outStr)
+
+
+def convertYaml2XmlAux(inobj, level, out):
+    for obj in inobj:
+        if type(obj) == types.DictType and \
+            obj.has_key('name'):
+            name = obj['name']
+            attributes = None
+            if obj.has_key('attributes'):
+                attributes = obj['attributes']
+            text = None
+            if obj.has_key('text'):
+                text = obj['text']
+            children = None
+            if obj.has_key('children'):
+                children = obj['children']
+            addLevel(level, out)
+            out.append('<%s' % name)
+            if attributes:
+                for key in attributes:
+                    out.append(' %s="%s"' % (key, attributes[key]))
+            if not (children or text):
+                out.append('/>\n')
+            else:
+                if children:
+                    out.append('>\n')
+                else:
+                    out.append('>')
+                if text:
+                    out.append(text)
+                if children:
+                    convertYaml2XmlAux(children, level + 1, out)
+                    addLevel(level, out)
+                out.append('</%s>\n' % name)
+
+
+#
+# Convert an XML document (file) to YAML and write it to stdout.
+#
+def convertXml2Yaml(inFileName):
+    doc = minidom.parse(inFileName)
+    root = doc.childNodes[0]
+    # Convert the DOM tree into "YAML-able" data structures.
+    out = convertXml2YamlAux(root)
+    # Ask YAML to dump the data structures to a string.
+    outStr = yaml.dump(out)
+    # Write the string to stdout.
+    sys.stdout.write(outStr)
+
+
+def convertXml2YamlAux(obj):
+    objDict = {}
+    # Add the element name.
+    objDict['name'] = obj.nodeName
+    # Convert the attributes.
+    attrs = obj.attributes
+    if attrs.length > 0:
+        attrDict = {}
+        for idx in range(attrs.length):
+            attr = attrs.item(idx)
+            attrDict[attr.name] = attr.value
+        objDict['attributes'] = attrDict
+    # Convert the text.
+    text = []
+    for child in obj.childNodes:
+        if child.nodeType == Node.TEXT_NODE and \
+            not isAllWhiteSpace(child.nodeValue):
+            text.append(child.nodeValue)
+    if text:
+        textStr = "".join(text)
+        objDict['text'] = textStr
+    # Convert the children.
+    children = []
+    for child in obj.childNodes:
+        if child.nodeType == Node.ELEMENT_NODE:
+            obj = convertXml2YamlAux(child)
+            children.append(obj)
+    if children:
+        objDict['children'] = children
+    return objDict
+
+
+#
+# Utility functions.
+#
+def addLevel(level, out):
+    for idx in range(level):
+        out.append('    ')
+
+
+NonWhiteSpacePattern = re.compile('\S')
+
+def isAllWhiteSpace(text):
+    if NonWhiteSpacePattern.search(text):
+        return 0
+    return 1
+
+
+USAGE_TEXT = """
+Convert a file from YAML to XML or XML to YAML and write it to stdout.
+
+Usage: python convertyaml_map.py <option> <in_file>
+
+Options:
+    -y2x    Convert YAML file to XML document.
+    -x2y    Convert XML document to YAML.
+"""
+
+def usage():
+    print USAGE_TEXT
+    sys.exit(-1)
+
+
+def main():
+    args = sys.argv[1:]
+    if len(args) != 2:
+        usage()
+    option = args[0]
+    inFileName = args[1]
+    if option == '-y2x':
+        convertYaml2Xml(inFileName)
+    elif option == '-x2y':
+        convertXml2Yaml(inFileName)
+    else:
+        usage()
+
+
+if __name__ == '__main__':
+    main()
+    #import pdb
+    #pdb.run('main()')
+

File experimental/XmlYaml/convertyaml_seq.py

+#!/usr/bin/env python
+"""
+Sample code to convert YAML to XML and XML to YAML using a canonical
+form.
+
+The canonical YAML representation of an XML element is a 4-tuple
+(a sequence) containing the following:
+    (1) element name
+    (2) attributes -- a mapping
+    (3) text -- a string
+    (4) children -- a sequence of elements
+
+For usage information, type:
+    python convertyaml_seq.py
+
+Usage: python convertyaml_seq.py <option> <in_file>
+
+Options:
+    -y2x    Convert YAML file to XML document.
+    -x2y    Convert XML document to YAML.
+
+
+Requirements:
+    PyXML
+    PyYaml
+
+"""
+
+import sys, string, re, types
+import yaml
+
+from xml.dom import minidom
+from xml.dom import Node
+
+
+#
+# Convert a YAML file to XML and write it to stdout.
+#
+def convertYaml2Xml(inFileName):
+    inobj = yaml.loadFile(inFileName)
+    out = []
+    level = 0
+    convertYaml2XmlAux(inobj, level, out)
+    outStr = "".join(out)
+    sys.stdout.write(outStr)
+
+
+def convertYaml2XmlAux(inobj, level, out):
+    for obj in inobj:
+        if (type(obj) == types.ListType or type(obj) == types.TupleType) and \
+            len(obj) == 4:
+            name = obj[0]
+            attributes = obj[1]
+            text = obj[2]
+            children = obj[3]
+            addLevel(level, out)
+            out.append('<%s' % name)
+            if attributes:
+                for key in attributes:
+                    out.append(' %s="%s"' % (key, attributes[key]))
+            if not (children or text):
+                out.append('/>\n')
+            else:
+                if children:
+                    out.append('>\n')
+                else:
+                    out.append('>')
+                if text:
+                    out.append(text)
+                if children:
+                    convertYaml2XmlAux(children, level + 1, out)
+                    addLevel(level, out)
+                out.append('</%s>\n' % name)
+
+
+#
+# Convert an XML document (file) to YAML and write it to stdout.
+#
+def convertXml2Yaml(inFileName):
+    doc = minidom.parse(inFileName)
+    root = doc.childNodes[0]
+    # Convert the DOM tree into "YAML-able" data structures.
+    out = convertXml2YamlAux(root)
+    # Ask YAML to dump the data structures to a string.
+    outStr = yaml.dump(out)
+    # Write the string to stdout.
+    sys.stdout.write(outStr)
+
+
+def convertXml2YamlAux(obj):
+    objDict = []
+    # Add the element name.
+    objDict.append(obj.nodeName)
+    # Convert the attributes.
+    attrs = obj.attributes
+    if attrs.length > 0:
+        attrDict = {}
+        for idx in range(attrs.length):
+            attr = attrs.item(idx)
+            attrDict[attr.name] = attr.value
+        objDict.append(attrDict)
+    else:
+        objDict.append(None)
+    # Convert the text.
+    text = []
+    for child in obj.childNodes:
+        if child.nodeType == Node.TEXT_NODE and \
+            not isAllWhiteSpace(child.nodeValue):
+            text.append(child.nodeValue)
+    if text:
+        textStr = "".join(text)
+        objDict.append(textStr)
+    else:
+        objDict.append(None)
+    # Convert the children.
+    children = []
+    for child in obj.childNodes:
+        if child.nodeType == Node.ELEMENT_NODE:
+            obj = convertXml2YamlAux(child)
+            children.append(obj)
+    if children:
+        objDict.append(children)
+    else:
+        objDict.append(None)
+    return objDict
+
+
+#
+# Utility functions.
+#
+def addLevel(level, out):
+    for idx in range(level):
+        out.append('    ')
+
+
+NonWhiteSpacePattern = re.compile('\S')
+
+def isAllWhiteSpace(text):
+    if NonWhiteSpacePattern.search(text):
+        return 0
+    return 1
+
+
+USAGE_TEXT = """
+Convert a file from YAML to XML or XML to YAML and write it to stdout.
+
+Usage: python convertyaml_seq.py <option> <in_file>
+
+Options:
+    -y2x    Convert YAML file to XML document.
+    -x2y    Convert XML document to YAML.
+"""
+
+def usage():
+    print USAGE_TEXT
+    sys.exit(-1)
+
+
+def main():
+    args = sys.argv[1:]
+    if len(args) != 2:
+        usage()
+    option = args[0]
+    inFileName = args[1]
+    if option == '-y2x':
+        convertYaml2Xml(inFileName)
+    elif option == '-x2y':
+        convertXml2Yaml(inFileName)
+    else:
+        usage()
+
+
+if __name__ == '__main__':
+    main()
+    #import pdb
+    #pdb.run('main()')
+

File experimental/XmlYaml/people.xml

+<?xml version="1.0"?>
+<people> 
+    <person id="1" value="abcd" ratio="3.2">
+        <name>Alberta</name>
+        <interest>gardening</interest>
+        <interest>reading</interest>
+        <category>5</category>
+    </person> 
+
+    <person id="2">
+        <name>Bernardo</name>
+        <interest>programming</interest>
+        <category></category>
+        <agent>
+            <firstname>Darren</firstname>
+            <lastname>Diddly</lastname>
+        </agent>
+
+    </person>
+
+    <person id="3">
+        <name>Charlie</name>
+        <interest>people</interest>
+        <interest>cats</interest>
+        <interest>dogs</interest>
+        <category>8</category>
+        <promoter>
+            <firstname>David</firstname>
+            <lastname>Donaldson</lastname>
+            <client>
+                <fullname>Arnold Applebee</fullname>
+                <refid>10001</refid>
+            </client>
+        </promoter>
+        <promoter>
+            <firstname>Edward</firstname>
+            <lastname>Eddleberry</lastname>
+            <client>
+                <fullname>Arnold Applebee</fullname>
+                <refid>10001</refid>
+            </client>
+        </promoter>
+    </person>
+
+</people>
+

File experimental/YAML.vim

+" To make this file do stuff, add something like the following (without the
+" leading ") to your ~/.vimrc:
+" au BufNewFile,BufRead *.yaml,*.yml so ~/src/PyYaml/YAML.vim
+
+" Vim syntax/macro file
+" Language:	YAML
+" Author:	Igor Vergeichik <iverg@mail.ru>
+" Sponsor: Tom Sawyer <transami@transami.net>
+" Stayven: Ryan King <jking@panoptic.com>
+" Copyright (c) 2002 Tom Saywer
+
+" Add an item to a gangly list:
+map , o<bs><bs><bs><bs>-<esc>o
+" Convert to Canonical form:
+map \c :%!python -c 'from yaml.redump import redump; import sys; print redump(sys.stdin.read()).rstrip()'
+
+if version < 600
+  syntax clear
+elseif exists("b:current_syntax")
+  finish
+endif
+syntax clear
+
+syn match yamlStream	"\s*---$"
+syn region yamlComment	start="\s*\#" end="$"
+syn match yamlDelimiter	"[:,]"
+syn match yamlBlock "[\[\]\{\}]"
+
+syn region yamlString	start="'" end="'" skip="\\'"
+syn region yamlString	start='"' end='"' skip='\\"' contains=yamlEscape
+
+syn match  yamlKey		"\w\+\ze\s*:"
+syn match  yamlType		"![^\s]\+\s\@="
+
+hi link yamlKey		Identifier
+hi link yamlComment	Comment
+hi link yamlStream	Statement
+hi link yamlBlock	Operator
+hi link yamlDelimiter	Delimiter
+hi link yamlString	String
+

File experimental/bnfyaml/data.yaml

+--- !clarkevans.com/^invoice
+invoice: 34843
+date   : 2001-01-23
+bill-to: &id001
+    given  : Chris
+    family : Dumars
+    address:
+        lines: |
+            458 Walkman Dr.
+            Suite #292
+        city    : Royal Oak
+        state   : MI
+        postal  : 48046
+ship-to: *id001
+product:
+    - sku         : BL394D
+      quantity    : 4
+      description : Basketball
+      price       : 450.00
+    - sku         : BL4438H
+      quantity    : 1
+      description : Super Hoop
+      price       : 2392.00
+tax  : 251.42
+total: 4443.52
+comments: >
+    Late afternoon is best.
+    Backup contact is Nancy
+    Billsmer @ 338-4338.

File experimental/bnfyaml/datatest.yaml

+sdfsd

File experimental/bnfyaml/parseyamlbnf.py

+"""Re-written version of simpleexample for 2.0"""
+from simpleparse.common import numbers, strings, comments
+from simpleparse.parser import Parser
+import pprint
+
+declaration = open('yamltest.bnf','r').read()
+testData = open('datatest.yaml','r').read()
+parser = Parser( declaration, "c_printable" )
+if __name__ =="__main__":
+	pprint.pprint( parser.parse( testData))

File experimental/bnfyaml/yaml.bnf

+;; 4.1. Characters
+
+;; 4.1.1. Character Set
+
+; [1] characters as defined by the Unicode standard, excluding most control characters and the surrogate blocks 
+c-printable ::= \x9 | 
+                \xA | 
+                \xD | 
+              [ \x20-\x7E] | 
+                \x85 | 
+              [ \xA0-\xD7FF] | 
+              [ \xE000-\xFFFD] | 
+              [ \x10000-\x10FFFF]
+
+;; 4.1.2. Encoding
+
+; [2] unicode BOM
+c-byte-order-mark ::= \xFEFF                                             
+
+
+;; 4.1.3. Indicators
+
+; [3] starts a flow sequence collection 
+c-sequence-start ::= "["                                                
+; [4] ends a flow sequence collection 
+c-sequence-end ::= "]"                                                  
+; [5] starts a flow mapping collection 
+c-mapping-start ::= "{"                                                 
+; [6] ends a flow mapping collection 
+c-mapping-end ::= "}"                                                   
+; [7] indicates a sequence entry 
+c-sequence-entry ::= "-"                                                
+; [8] separates a key from its value 
+c-mapping-entry ::= ":"                                                 
+; [9] separates flow collection entries 
+c-collect-entry ::= ","                                                 
+; [10] a complex key 
+c-complex-key ::= "?"                                                   
+; [11] indicates a tag property 
+c-tag ::= "!"                                                           
+; [12] an anchor property 
+c-anchor ::= "&"                                                        
+; [13] an alias node 
+c-alias ::= "*"                                                         
+; [14] a literal scalar 
+c-literal ::= "|"                                                       
+; [15] a folded scalar 
+c-folded ::= ">"                                                        
+; [16] a single quoted scalar 
+c-single-quote ::= "'"                                                  
+; [17] a double quoted scalar 
+c-double-quote ::= """                                                  
+; [18] a throwaway comment 
+c-throwaway ::= "#"                                                     
+; [19] a directive 
+c-directive ::= "%"                                                     
+; [20] reserved for future use 
+c-reserved ::= "@" | 
+               "`"                                                      
+; [21] indicator characters 
+c-indicators ::= "[" | 
+                 "]" | 
+                 "{" | 
+                 "}" | 
+                 "-" | 
+                 ":" | 
+                 "?" | 
+                 "," | 
+                 "!" | 
+                 "*" | 
+                 "&" | 
+                 "|" | 
+                 ">" | 
+                 "'" | 
+                 """ | 
+                 "#" | 
+                 "%" | 
+                 "@" | 
+                 "`"  
+                 
+;; 4.1.4 Line Breaks
+                                                                                   
+; [22] aSCII line feed (LF) 
+b-line-feed ::= \xA                                                     
+; [23] aSCII carriage return (CR) 
+b-carriage-return ::= \xD                                               
+; [24] unicode next line (NEL) 
+b-next-line ::= \x85                                                    
+; [25] unicode line separator (LS) 
+b-line-separator ::= \x2028                                             
+; [26] unicode paragraph separator (PS) 
+b-paragraph-separator ::= \x2029                                        
+; [27] line break characters 
+b-char ::=           b-line-feed | 
+               b-carriage-return | 
+                     b-next-line | 
+                b-line-separator | 
+           b-paragraph-separator
+; [28] line break with non-specific semantics 
+b-generic ::= ( b-carriage-return b-line-feed ) | 
+                              b-carriage-return | 
+                                    b-line-feed | 
+                                    b-next-line                                             
+; [29] line break with specific semantics 
+b-specific ::= b-line-separator | 
+               b-paragraph-separator                                    
+; [30] any non-content line break 
+b-any ::= b-generic | 
+          b-specific 
+
+;; 4.1.5. Miscellaneous
+          
+; [31] characters valid in a line 
+nb-char ::= c-printable - b-char                                        
+; [32] white space valid in a line 
+s-char ::= \x9 | 
+           \x20                                                         
+; [33] non-space characters valid in a line 
+ns-char ::= nb-char - s-char                                            
+; [34] aSCII letters, A-Z or a-z 
+ns-ascii-letter ::= [\x41-\x5A] | 
+                    [\x61-\x7A] 
+; [35] 0-9
+ns-decimal-digit ::= [\x30-\x39]  
+; [36] 0-9, A-F or a-f 
+ns-hex-digit ::= ns-decimal-digit | 
+                 [\x41-\x46] | 
+                 [\x61-\x66] 
+; [37] characters valid in a word 
+ns-word-char ::= ns-decimal-digit | 
+                  ns-ascii-letter | 
+                  "-" 
+                 
+;; 4.2. Space Processing
+
+;; 4.2.1. Indentation
+                 
+; [38] specific level of indentation 
+i-spaces(n) ::= \x20 x n 
+
+;; 4.2.2. Throwaway comments
+
+; [39] comment trailing a line 
+c-nb-throwaway-comment ::= "#" nb-char* 
+; [40] types of comment lines
+l-comment(n) ::= l-empty-comment(n) | 
+                 l-text-comment(n)  
+; [41] empty throwaway comment line 
+l-empty-comment(n) ::= i-spaces(<n) b-any 
+; [42] explicit throwaway comment line 
+l-text-comment(n) ::= i-spaces(<n) c-nb-throwaway-comment b-any 
+; [43] trailing non-content spaces, comment and line break 
+s-b-trailing-comment ::= ( s-char+ c-nb-throwaway-comment? )? b-any 
+
+;; 4.3. YAML Stream
+
+; [44] document stream 
+c-l-yaml-stream ::= ( c-l-before-document l-l-implicit-document l-l-after-document? )? ( c-l-before-document l-l-explicit-document l-l-after-document? )* 
+; [45] comments before actual document starts 
+c-l-before-document ::= c-byte-order-mark? #l-comment(any)* 
+; [46] first document with an implicit header line 
+l-l-implicit-document ::= l-l-collect-blk-value(any) | 
+                          l-l-collect-top-flow-node(any) 
+; [47] stream document with an explicit header 
+l-l-explicit-document ::= ns-ns-document-header ( s-l-scalar-top-node(any) | 
+                          s-l-collect-top-node(any) ) 
+                          
+;; 4.3.1. Document
+                          
+; [48] document header 
+ns-ns-document-header ::= ns-ns-document-start ( s-char+ c-ns-directive )* 
+; [49] document start indicator 
+ns-ns-document-start ::= "-" "-" "-" 
+; [50] document trailer 
+l-l-after-document ::= ns-ns-document-end b-any l-comment(any)* 
+; [51] document end indicator 
+ns-ns-document-end ::= "." "." "." 
+; [52] forbidden non-indented content line 
+l-forbidden-non-indented ::= ( ns-ns-document-start s-char nb-char* ) | 
+                               ns-ns-document-end 
+
+;; 4.3.2. Directive
+
+; [53] document directive 
+c-ns-directive ::= "%" ns-ns-directive-name ":" ns-ns-directive-value 
+; [54] document directive name 
+ns-ns-directive-name ::= ( ns-char - ":" )+ 
+; [55] document directive value 
+ns-ns-directive-value ::= ns-char+ 
+
+;; 4.3.3. Presentation Node
+
+; [56] node outside flow collection 
+s-l-top-node(n) ::=      s-l-alias-top-node | 
+                    s-l-collect-top-node(n) | 
+                     s-l-scalar-top-node(n) 
+; [57] value node inside flow collection 
+ns-ns-flow-value-node(n) ::=      ns-ns-alias-flow-node | 
+                               c-c-collect-flow-node(n) | 
+                        ns-ns-scalar-flow-value-node(n) 
+; [58] key node inside flow collection
+ns-ns-flow-key-node(n) ::=     ns-ns-alias-flow-node | 
+                            c-c-collect-flow-node(n) | 
+                        ns-ns-scalar-flow-key-node(n)  
+
+;; 4.3.4. Node Property
+
+; [59] properties list 
+c-ns-properties ::= ( c-ns-tag-property ( s-char+ c-ns-anchor-property )? ) | 
+                    ( c-ns-anchor-property ( s-char+ c-ns-tag-property )? ) 
+                    
+;; 4.3.5. Tag                    
+                    
+;; 4.3.5.3. Prefixing
+                    
+; [60] seperate prefix from type 
+c-prefix ::= "^" 
+; [62] characters valid in a tag 
+ns-tag-char ::=         ns-esc-sequence | 
+               ( "%" ns-hex-digit x 2 ) | 
+          ( ns-char - "\" - "^" - "%" ) 
+; [63] non-magical URI character
+ns-mundane-tag-char ::= ns-tag-char - ":" - "/"  
+; [64] collection tag
+c-ns-tag-property ::= "!" ( ; empty (implicit) | 
+                              c-ns-private-tag | 
+                              ns-ns-global-tag | 
+        ( Prefix-of-above? "^" Suffix-of-above ) )  
+; [65] private tags 
+c-ns-private-tag ::= "!" ns-tag-char+ 
+; [66] global tags 
+ns-ns-global-tag ::=       ns-ns-core-tag | 
+                     ns-ns-vocabulary-tag | 
+                     ns-ns-domain-tag 
+; [67] shorthand for tag:yaml.org,2002:type names 
+ns-ns-core-tag ::= ( ns-mundane-tag-char - "!" ) ns-mundane-tag-char* 
+; [68] shorthand for tag:vocabulary.yaml.org,2002:type names
+ns-ns-vocabulary-tag ::= ns-word-char+ "/" ns-tag-char*  
+; [69] shorthand for tag:domain,date:type names 
+ns-ns-domain-tag ::= ns-word-char+ ( "." ns-word-char+ ) "," ns-ns-domain-year ( "-" ns-ns-domain-day-month ( "-" ns-ns-domain-day-month )? )? "/" ns-tag-char* 
+; [70] tag domain ownership year
+ns-ns-domain-year ::= ns-decimal-digit x 4  
+
+;; 4.3.6. Anchor
+
+; [71] tag domain ownership day or month (01 by default)
+ns-ns-domain-day-month ::= ns-decimal-digit x 2  
+; [72] associates an anchor with a given node
+c-ns-anchor-property ::= "&" ns-ns-anchor-name
+
+;; 4.4. Alias  
+
+; [73] unique anchor name
+ns-ns-anchor-name ::= ns-char+  
+; [74] alias node outside flow collection 
+s-l-alias-top-node ::= s-char ns-ns-alias-flow-node s-b-trailing-comment l-comment(any)* 
+
+;; 4.5. Collection
+
+; [75] alias node inside flow collection
+ns-ns-alias-flow-node ::= "*" ns-ns-anchor-name  
+; [76] collection node outside flow collection 
+s-l-collect-top-node(n) ::= s-l-collect-blk-node(n) | 
+                          ( s-s-required(n) c-c-collect-flow-node(n) s-b-trailing-comment l-comment(any)* ) 
+; [77] top-level (document) flow collection node 
+l-l-collect-top-flow-node(n) ::= i-spaces(n) c-c-collect-flow-node(n) s-b-trailing-comment l-comment(any)* 
+; [78] collection node in flow style 
+c-c-collect-flow-node(n) ::= ( c-ns-properties s-char+ )? c-c-collect-flow-value(n) 
+; [79] collection node in block style 
+s-l-collect-blk-node(n) ::= ( s-char+ c-ns-properties )? s-b-trailing-comment l-comment(any)* l-l-collect-blk-value(n) 
+; [80] collection value in block style 
+l-l-collect-blk-value(n) ::= l-l-blk-seq-value(n) | 
+                             l-l-blk-map-value(n) 
+; [81] collection value in flow style 
+c-c-collect-flow-value(n) ::= c-c-flow-seq-value(n) | 
+                              c-c-flow-map-value(n) 
+; [82] optional white space separating tokens 
+s-s-optional(n) ::= s-char* | 
+                  ( s-b-trailing-comment i-spaces(n) s-char+ ) 
+                  
+;; 4.5.1. Sequence
+                  
+; [83] required white space separating tokens
+s-s-required(n) ::= s-char+ | 
+                  ( s-b-trailing-comment i-spaces(n) s-char+ )  
+; [84] sequence value in block style; -1 unless the block sequence is the value of an entry of a parent block sequence 
+l-l-blk-seq-value(n) ::= ( i-spaces(n-1) c-l-blk-seq-entry(n-1) )+ 
+; [85] block sequence node entry 
+c-l-blk-seq-entry(n) ::= "-" s-l-inline-node(n) 
+; [86] top node or a shorthand inline collection
+s-l-inline-node(n) ::=  s-l-top-node(>n) | 
+                       i-l-inline-seq(n) | 
+                       i-l-inline-map(n)  
+; [87] inline sequence node with no properties (where m > 0)
+i-l-inline-seq(n) ::= i-spaces(m) c-l-blk-seq-entry(n+m+1) l-l-blk-seq-value(n+m+1)?  
+; [88] sequence value in flow style
+c-c-flow-seq-value(n) ::= "[" s-s-optional(n) ( ns-ns-flow-seq-entry(n) s-s-optional(n) ( "," s-s-required(n) ns-ns-flow-seq-entry(n) s-s-optional(n) )* )? "]"  
+ns-ns-flow-seq-entry(n) ::= ns-ns-flow-value-node(n) | 
+                            ns-ns-flow-pair-map(n) ; flow style sequence entry 
+                            
+;; 4.5.2. Mapping
+                            
+; [89] mapping value in block style 
+l-l-blk-map-value(n) ::= ( i-spaces(n) ns-l-blk-map-entry(n) )+ 
+; [90] inline mapping node with no properties (where m > 0) 
+i-l-inline-map(n) ::= i-spaces(m) ns-ns-scalar-key-value(n+m+1) s-char* ":" s-l-top-node(>n+m+1) l-l-blk-map-value(n+m+1)? 
+; [91] block key:value pair 
+ns-l-blk-map-entry(n) ::= ns-l-simple-map-entry(n) ns-l-complex-map-entry(n) 
+; [92] simple key:value pair 
+ns-l-simple-map-entry(n) ::= ns-ns-flow-key-node(n) s-char* ":" s-l-top-node(>n) 
+; [93] complex key:value pair 
+ns-l-complex-map-entry(n) ::= "?" s-l-inline-node(n) ( i-spaces(n) ":" s-l-inline-node(n) )? 
+; [94] mapping value in flow style 
+c-c-flow-map-value(n) ::= "{" s-s-optional(n) ( ns-ns-flow-map-entry(n) s-s-optional(n) ( "," s-s-required(n) ns-ns-flow-map-entry(n) s-s-optional(n) )* )? "}" 
+; [95] flow key:value pair 
+ns-ns-flow-map-entry(n) ::= ns-ns-flow-key-node(n) ( s-char* ":" s-s-required(n) ns-ns-flow-value-node(n) )? 
+; [96] single key:value pair map in flow sequence 
+ns-ns-flow-pair-map(n) ::= ns-ns-flow-key-node(n) s-char* ":" s-s-required(n) ns-ns-flow-value-node(n) 
+
+;; 4.6. Scalar
+
+; [97] scalar node outside flow collection 
+s-l-scalar-top-node(n) ::= s-l-scalar-top-blk-node(n) | 
+                           s-l-scalar-top-flow-node(n) 
+; [98] scalar node outside flow collection, in block style 
+s-l-scalar-top-blk-node(n) ::= ( s-char+ c-ns-properties )? s-char+ c-l-scalar-blk-value(n) 
+; [99] scalar node outside flow collection, in flow style 
+s-l-scalar-top-flow-node(n) ::= s-s-required(n) ( c-ns-properties s-char+ )? ns-ns-scalar-top-value(n) s-b-trailing-comment l-comment(any)* 
+; [100] scalar node inside flow collection, used as value 
+ns-ns-scalar-flow-value-node(n) ::= ( c-ns-properties s-char+ )? ns-ns-scalar-flow-value(n) 
+; [101] scalar node inside flow collection, used as key 
+ns-ns-scalar-flow-key-node(n) ::= ( c-ns-properties s-char+ )? ns-ns-scalar-key-value(n) 
+; [102] scalar value in block style 
+c-l-scalar-blk-value(n) ::= c-l-literal(n) | 
+                            c-l-folded(n) 
+; [103] scalar value in flow style, used as value, inside flow collection 
+ns-ns-scalar-flow-value(n) ::= c-c-single-quoted(n) | 
+                               c-c-double-quoted(n) | 
+                               ns-ns-plain-flow(n) 
+; [104] scalar value in flow style, used as value, outside flow collection 
+ns-ns-scalar-top-value(n) ::= c-c-single-quoted(n) | 
+                              c-c-double-quoted(n) | 
+                              ns-ns-plain-top(n) 
+; [105] scalar value in flow style, used as key 
+ns-ns-scalar-key-value(n) ::= c-c-single-quoted(n) | 
+                              c-c-double-quoted(n) | 
+                              ns-ns-plain-key 
+                              
+;; 4.6.1.   End Of line Normalization
+                              
+; [106] line break converted to a line feed 
+b-as-line-feed ::= b-generic 
+; [107] a normalized end of line marker 
+b-normalized ::= b-as-line-feed | 
+                 b-specific 
+                 
+;; 4.6.2. Block Modifiers
+                 
+; [108] block scalar modifiers 
+ns-ns-blk-modifiers ::= ( ns-explicit-indent c-chomp-control? ) | 
+                        ( c-chomp-control ns-explicit-indent? ) 
+                        
+;; 4.6.3.   Explicit Indentation
+                        
+; [109] explicit additional indentation level 
+ns-explicit-indent ::= ns-decimal-digit 
+
+;; 4.6.4. Chomping
+
+; [110] override the default "clip" chomping
+c-chomp-control ::= c-strip-chomp | 
+                    c-keep-chomp  
+; [111] strip final line break from value 
+c-strip-chomp ::= "-" 
+; [112] keep trailing line breaks in value 
+c-keep-chomp ::= "+" 
+; [113] trailing line feeds or comment lines, depending on chomp control) 
+l-l-empty-trailing(n) ::= l-empty-comment(n)+ | 
+                          l-blk-empty-line-feed(n)+ 
+; [114] empty block line 
+l-blk-empty-line-feed(n) ::= i-spaces(<n) b-as-line-feed
+
+;; 4.6.5. Literal
+ 
+; [115] literal scalar 
+c-l-literal(n) ::= "|" ns-ns-blk-modifiers? s-b-trailing-comment l-l-literal-value(n)? l-l-empty-trailing(n)? ( l-text-comment(<n) l-comment(any)* )? 
+; [116] value of literal scalar 
+l-l-literal-value(n) ::= l-l-literal-chunk(n)+ 
+; [117] chunk of literal scalar lines 
+l-l-literal-chunk(n) ::= l-blk-empty-line-feed(n)* ( l-literal-text(n) | 
+                         l-blk-empty-specific(n) ) 
+; [118] empty block line with preserved specific line break 
+l-blk-empty-specific(n) ::= i-spaces(<n) b-specific 
+; [119] literal line character data 
+l-literal-text(n) ::= ( i-spaces(n) nb-char+ b-normalized ) - ( l-forbidden-non-indented b-any ) 
+
+;; 4.6.6. Folding
+
+;; 4.6.6.1.   Folding in a block context
+
+; [120] line feed converted to a space 
+b-as-space ::= b-generic 
+; [121] ignored line feed 
+b-ignored ::= b-generic 
+; [122] sequence of line feeds in block scalar 
+b-l-blk-trimmed(n) ::= b-ignored l-blk-empty-line-feed(n)+ 
+
+;; 4.6.6.2.   Folding flow scalars
+
+; [123] ignored spaces at start of flow scalar line 
+i-s-ignored-leading(n) ::= i-spaces(n) s-char+ 
+; [124] ignored spaces at end of flow scalar line 
+s-s-ignored-trailing ::= s-char+ 
+; [125] empty flow line with preserved specific line break 
+l-flow-empty-specific(n) ::= ( i-spaces(<n) | 
+                               i-s-ignored-leading(n) ) b-specific 
+; [126] empty flow line with line break normalized to line feed 
+l-flow-empty-line-feed(n) ::= ( i-spaces(<n) | 
+                                i-s-ignored-leading(n) ) b-as-line-feed 
+; [127] sequence of line feeds in flow scalar 
+b-l-flow-trimmed(n) ::= b-ignored l-flow-empty-line-feed(n)+ 
+; [128] end of a line in a multi-line flow scalar 
+s-l-end-flow-line(n) ::= s-s-ignored-trailing ( b-as-space | 
+                                       b-l-flow-trimmed(n) | 
+                                               b-specific ) 
+
+;; 4.6.7. Folded
+
+; [129] folded scalar 
+c-l-folded(n) ::= ">" ns-ns-blk-modifiers s-b-trailing-comment l-l-folded-value(n)? l-l-empty-trailing(n)? ( l-text-comment(<n) l-comment(any)* )? 
+; [130] value of folded scalar 
+l-l-folded-value(n) ::= l-blk-empty-line-feed(n)* ( l-l-folded-chunk(n) | 
+                        l-l-non-folded-chunk(n) ) 
+; [131] value starting with a chunk of folded text 
+l-l-folded-chunk(n) ::= ( i-nb-folded-paragraph(n) b-l-blk-trimmed(n) )* i-nb-folded-paragraph(n) b-l-after-folded-chunk(n) 
+; [132] single content paragraph folded into multiple physical lines 
+i-nb-folded-paragraph(n) ::= ( i-nb-folded-text(n) b-as-space )* i-nb-folded-text(n) 
+; [133] folded text line characters 
+i-nb-folded-text(n) ::= ( i-spaces(n) ns-char nb-char* ) - l-forbidden-non-indented 
+; [134] text following a folded text chunk 
+b-l-after-folded-chunk(n) ::= b-normalized ( l-blk-empty-line-feed(n)* l-l-non-folded-chunk(n) )? 
+; [135] value starting with non-folded text chunk 
+l-l-non-folded-chunk(n) ::= ( l-empty-non-folded(n) | 
+                              l-indented-non-folded(n) ) l-l-folded-value(n)? 
+; [136] not folded due to specific line break 
+l-empty-non-folded(n) ::= i-spaces(<n) b-specific 
+; [137] not folded due to starting white space 
+l-indented-non-folded(n) ::= i-spaces(n) s-char nb-char* b-normalized 
+
+;; 4.6.8. Single Quoted
+
+; [138 single quoted scalar 
+c-c-single-quoted(n) ::= "'" nb-nb-single-quoted-value(n)? "'" 
+; [139] value of a single quoted scalar 
+nb-nb-single-quoted-value(n) ::= nb-nb-one-single-line | 
+                               ( nb-l-first-single-line(n) l-l-inner-single-line(n)* i-nb-last-single-line(n) ) 
+; [140] one line value of single quoted scalar 
+nb-nb-one-single-line ::= nb-single-char+ 
+; [141] first line of multi-line single quoted scalar 
+nb-l-first-single-line(n) ::= ( nb-single-char* ns-single-char )? s-l-end-flow-line(n) 
+; [142] inner line of multi-line single quoted scalar 
+l-l-inner-single-line(n) ::= l-flow-empty-specific(n) | 
+                           ( i-s-ignored-leading(n) ns-single-char nb-l-first-single-line(n) ) 
+; [143] last line of multi-line single quoted scalar 
+i-nb-last-single-line(n) ::= i-s-ignored-leading(n) ( ns-single-char nb-single-char* )? 
+; [144] indicates a single quote 
+ns-escaped-single-quote ::= "'" "'" 
+; [145] non-break char valid in a single quoted scalar 
+nb-single-char ::= ns-escaped-single-quote | 
+                 ( nb-char - "'" ) 
+; [146] non-space char valid in a single quoted scalar 
+ns-single-char ::= nb-single-char - s-char 
+
+;; 4.6.9. Escaping
+
+; [147] escape character 
+c-escape ::= "\" 
+; [148] escaped backslash 
+ns-esc-escape ::= "\" "\" 
+; [149] escaped double quote character 
+ns-esc-double-quote ::= "\" """ 
+; [150] aSCII alert (BEL) 
+ns-esc-bel ::= "\" "a" 
+; [151] aSCII backspace (BS) 
+ns-esc-backspace ::= "\" "b" 
+; [152] aSCII escape (ESC) 
+ns-esc-esc ::= "\" "e" 
+; [153] aSCII formfeed (FF) 
+ns-esc-form-feed ::= "\" "f" 
+; [154] aSCII linefeed (LF) 
+ns-esc-line-feed ::= "\" "n" 
+; [155] aSCII carriage return (CR) 
+ns-esc-return ::= "\" "r" 
+; [156] aSCII horizontal tab (TAB) 
+ns-esc-tab ::= "\" "t" 
+; [157] aSCII vertical tab (VTAB) 
+ns-esc-vertical-tab ::= "\" "v" 
+; [158] aSCII hat (CIRCUMFLEX ACCENT) 
+ns-esc-hat ::= "\" "^" 
+; [159] aSCII zero (NUL) 
+ns-esc-null ::= "\" "0" 
+; [160] aSCII space (SP) 
+ns-esc-space ::= "\" #20 
+; [161] unicode non-breaking space (NBSP) 
+ns-esc-non-breaking-space ::= "\" "_" 
+; [162] unicode next line (NEL) 
+ns-esc-next-line ::= "\" "N" 
+; [163] unicode line separator (LS) 
+ns-esc-line-separator ::= "\" "L" 
+; [164] unicode paragraph separator (PS) 
+ns-esc-paragraph-separator ::= "\" "P" 
+; [165] 8-bit character 
+ns-esc-8-bit ::= "\" "x" ( ns-hex-digit x 2 ) 
+; [166] 16-bit character 
+ns-esc-16-bit ::= "\" "u" ( ns-hex-digit x 4 ) 
+; [167] 32-bit character 
+ns-esc-32-bit ::= "\" "U" ( ns-hex-digit x 8 ) 
+; [168] escape codes in escaped scalars 
+ns-esc-sequence ::=              ns-esc-escape | 
+                           ns-esc-double-quote | 
+                                    ns-esc-bel | 
+                              ns-esc-backspace | 
+                                    ns-esc-esc | 
+                              ns-esc-form-feed | 
+                              ns-esc-line-feed | 
+                                 ns-esc-return | 
+                                    ns-esc-tab | 
+                           ns-esc-vertical-tab | 
+                                    ns-esc-hat | 
+                                   ns-esc-null | 
+                                  ns-esc-space | 
+                     ns-esc-non-breaking-space | 
+                              ns-esc-next-line | 
+                         ns-esc-line-separator | 
+                    ns-esc-paragraph-separator | 
+                                  ns-esc-8-bit | 
+                                 ns-esc-16-bit | 
+                                 ns-esc-32-bit 
+; [169] escaped (ignored) line break 
+b-escaped ::= "\" b-any 
+
+;; 4.6.10. Double Quoted
+
+; [170] double quoted scalar 
+c-c-double-quoted(n) ::= """ nb-nb-double-quoted-value(n)? """ 
+; [171] value of a double quoted scalar 
+nb-nb-double-quoted-value(n) ::= nb-nb-one-double-line | 
+                                ( nb-l-first-double-line(n) l-l-inner-double-line(n)* i-nb-last-double-line(n) ) 
+; [172] one line value of double quoted scalar 
+nb-nb-one-double-line ::= nb-double-char+ 
+; [173] first line of multi-line double quoted scalar 
+nb-l-first-double-line(n) ::= ( nb-double-char* ns-double-char )? s-l-end-double-line(n) 
+; [174] inner line of multi-line double quoted scalar 
+l-l-inner-double-line(n) ::= l-flow-empty-specific(n) | 
+                           ( i-s-ignored-leading(n) ns-double-char nb-l-first-double-line(n) ) 
+; [175] last line of multi-line double quoted scalar 
+i-nb-last-double-line(n) ::= i-s-ignored-leading(n) ( ns-double-char nb-double-char* )? 
+; [176] end of a line in a multi-line double quoted scalar 
+s-l-end-double-line(n) ::= s-l-end-flow-line(n) | 
+                         ( s-char* b-escaped ) 
+; [177] non-break char valid in a double quoted scalar 
+nb-double-char ::= ns-esc-sequence | 
+                 ( nb-char - "\" ) 
+; [178] non-space char valid in a double quoted scalar 
+ns-double-char ::= nb-double-char - s-char 
+
+;; 4.6.11. Plain
+
+; [179] avoiding top indicator chars 
+ns-ns-plain-top(n) ::= ns-ns-plain-value(n) 
+; [180] avoiding flow indicator chars 
+ns-ns-plain-flow(n) ::= ns-ns-plain-value(n) 
+; [181] plain scalar used as a key; avoiding flow indicator chars 
+ns-ns-plain-key ::= ns-ns-one-plain-line 
+; [182] plain scalar used as a value 
+ns-ns-plain-value(n) ::= ns-ns-one-plain-line | 
+                       ( ns-l-first-plain-line(n) l-l-inner-plain-line(n)* i-ns-last-plain-line(n) ) 
+; [183] plain one-line value 
+ns-ns-one-plain-line ::= ns-first-plain-char nb-ns-plain-text? 
+; [184} first line of multi-line plain scalar 
+ns-l-first-plain-line(n) ::= ns-ns-one-plain-line s-l-end-flow-line(n) 
+; [185] inner line of multi-line plain scalar 
+l-l-inner-plain-line(n) ::= l-flow-empty-specific(n) | 
+        ( i-s-ignored-leading(n) ns-plain-char nb-ns-plain-text? s-l-end-flow-line(n) ) 
+; [186]last line of multi-line plain scalar
+i-ns-last-plain-line(n) ::= i-s-ignored-leading(n) ( ns-plain-char nb-ns-plain-text? )? 
+; [187] chunk of plain text 
+nb-ns-plain-text ::= nb-plain-char* ns-plain-char 
+; [188] first character in a plain scalar 
+ns-first-plain-char ::= ( ns-plain-char - c-indicators ) | 
+                      ( ( "-" | 
+                          "?" | 
+                          ":" | 
+                          "," ) ns-plain-char ) 
+; [189] char allowed in plain scalar used as top level value 
+nb-plain-top-char ::= ( nb-char - ":" - "#" ) | 
+                      ( ns-plain-char "#" ) | 
+                      ( ":" ns-plain-char ) 
+; [190] char allowed in plain scalar used as value in a flow collection 
+nb-plain-flow-char ::= ( nb-plain-top-char - "[" - "]" - "{" - "}" - "," ) | 
+                       ( "," ns-plain-char ) 
+; [191] char allowed in plain scalar used as key 
+nb-plain-key-char ::= nb-plain-flow-char 
+; [192] depending whether reached from top, flow or key plain scalar production 
+nb-plain-char ::= nb-plain-top-char | 
+                  nb-plain-flow-char | 
+                  nb-plain-key-char 
+; [193] non-space char valid in a plain scalar 
+ns-plain-char ::= nb-plain-char - s-char 

File experimental/bnfyaml/yamlspec.html

+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+    <title>
+      YAML Ain't Markup Language (YAML) 1.0
+    </title>
+    <link rel="stylesheet" href="single_html.css" type="text/css" />
+    <meta name="generator" content="DocBook XSL Stylesheets V1.62.3" />
+    <style type="text/css">
+body { background-image: url('http://docbook.sourceforge.net/release/images/draft.png');
+       background-repeat: no-repeat;
+       background-position: top left;
+       /* The following properties make the watermark &quot;fixed&quot; on the page. */
+       /* I think that's just a bit too distracting for the reader... */
+       /* background-attachment: fixed; */
+       /* background-position: center center; */
+     }</style>
+  </head>
+  <body>
+    <div class="book" lang="en" xml:lang="en">
+      <div class="titlepage">
+        <div>
+          <div>
+            <h1 class="title"><a id="id2439396"></a>
+      YAML Ain't Markup Language (<span class="trademark">YAML</span>&#8482;) 1.0
+    </h1>
+          </div>
+          <div>
+            <h2 class="subtitle">
+      Working Draft 2004-JAN-29
+    </h2>
+          </div>
+          <div>
+            <div class="authorgroup">
+              <div class="author">
+                <h3 class="author"><span class="firstname">Oren</span> <span class="surname">Ben-Kiki</span></h3>
+                <tt class="email">&lt;<a href="mailto:oren@ben-kiki.org">oren@ben-kiki.org</a>&gt;</tt>
+              </div>
+              <div class="author">
+                <h3 class="author"><span class="firstname">Clark</span> <span class="surname">Evans</span></h3>
+                <tt class="email">&lt;<a href="mailto:cce@clarkevans.com">cce@clarkevans.com</a>&gt;</tt>
+              </div>
+              <div class="author">
+                <h3 class="author"><span class="firstname">Brian</span> <span class="surname">Ingerson</span></h3>
+                <tt class="email">&lt;<a href="mailto:ingy@ttul.org">ingy@ttul.org</a>&gt;</tt>
+              </div>
+            </div>
+          </div>
+          <div>
+            <p class="releaseinfo">
+      <span class="emphasis"><em>This version:</em></span>
+      <a href="http://www.yaml.org/spec/29jan2004.html" target="_top">http://www.yaml.org/spec/29jan2004.html</a><br />
+      <span class="emphasis"><em>Latest version:</em></span>
+      <a href="http://www.yaml.org/spec" target="_top">http://www.yaml.org/spec</a>
+    </p>
+          </div>
+          <div>
+            <p class="copyright">Copyright � 2001-2004 Oren Ben-Kiki, Clark Evans, Brian Ingerson</p>
+          </div>
+          <div>
+            <div class="legalnotice">
+      This document may be freely copied provided it is not modified.
+    </div>
+          </div>
+          <div>
+            <div class="abstract">
+              <p class="title">
+                <b>Status of this Document</b>
+              </p>
+              <p>
+        This is an intermediate working draft and is being actively 
+        revised.  Hopefully the next draft will be a release canidate.
+      </p>
+              <p>
+        We wish to thank implementers who have tirelessly tracked earlier
+        versions of this specification, and our fabulous user community
+        whose feedback has both validated and clarified our direction.
+      </p>
+            </div>
+          </div>
+          <div>
+            <div class="abstract">
+              <p class="title">
+                <b>Abstract</b>
+              </p>
+              <p>
+        <span class="trademark">YAML</span>&#8482; (rhymes with &#8220;<span class="quote">camel</span>&#8221;) is a
+        human friendly, cross language, unicode based data serialization
+        language designed around the common native structures of agile
+        programming languages. It is broadly useful for programming needs
+        ranging from configuration files to Internet messaging to object
+        persistence to data auditing. Together with the <a href="http://www.unicode.org/" target="_top">Unicode</a> standard for
+        characters, this specification provides all the information
+        necessary to understand YAML Version 1.0 and to construct programs
+        that process YAML information.
+      </p>
+            </div>
+          </div>
+        </div>
+        <div></div>
+        <hr />
+      </div>
+      <div class="toc">
+        <p>
+          <b>Table of Contents</b>
+        </p>
+        <dl>
+          <dt>
+            <span class="chapter">
+              <a href="#id2488852">1. Introduction</a>
+            </span>
+          </dt>
+          <dd>
+            <dl>
+              <dt>
+                <span class="sect1">
+                  <a href="#id2488873">1.1. Goals</a>
+                </span>
+              </dt>
+              <dt>
+                <span class="sect1">
+                  <a href="#id2488920">1.2. Prior Art</a>
+                </span>
+              </dt>
+              <dt>
+                <span class="sect1">
+                  <a href="#id2489434">1.3. Relation to XML</a>
+                </span>
+              </dt>
+              <dt>
+                <span class="sect1">
+                  <a href="#id2489458">1.4. Terminology</a>
+                </span>