Hi Gavin,

I'll check the mailing list to see if Bruce posted anything subsequently. If 
not I might shoot him an email and see of he's interesting in sharing code.

Pádraic
 
Pádraic Brady
http://blog.astrumfutura.com
http://www.patternsforphp.com


----- Original Message ----
From: Gavin Vess <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Cc: Zend Framework General <[email protected]>; [EMAIL PROTECTED]
Sent: Tuesday, March 20, 2007 6:14:57 PM
Subject: Re: [fw-general] Where's the YAML parser?

Perhaps Bruno has something? This topic was discussed last Summer (see 
topic thread appended below).

http://www.yaml.org/refcard.html - YAML reference card

http://en.wikipedia.org/wiki/YAML - YAML intro

http://whytheluckystiff.net/syck/ - PHP extension homepage

http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-php5/syck-php-bindings/ 
- Gentoo's ebuild for this PHP extension

Cheers,
Gavin

[EMAIL PROTECTED] wrote:
> I was making suggestions to a fellow ZF user the other day and I 
> noticed Zend_Config has no YAML format parser. Are there any plans to 
> introduce a YAML config format, or does this require a base YAML 
> parser, such as a Zend_Yaml since PHP is currently without an 
> extension for the format?
>
> There are a few places I find the format useful. The one we were 
> discussing was a more readable configuration file for dynamically 
> constructing filter chains and rulesets. Esp. since XML is a bit 
> bloated (yes, it's human editable but such configurations only have a 
> little nesting and XML can come off as overkill when presenting it to 
> a maintainer).
>
> I googled around a bit and the only reference was back months ago 
> where someone posted a modification of the spyc library to the mailing 
> list. <http://www.patternsforphp.com>
-------- Original Message --------
Subject: [fw-general] Zend-Yaml challenge taken.
Date: Tue, 27 Jun 2006 02:05:26 +0200
From: Bruno Couleau <[EMAIL PROTECTED]>
Organization: The Phocea Experiment
To: 'Zend Framework General' <[email protected]>

Hi,

At the beginning of the month, I was looking to the 
Zend_Config:XML_Format thread and the idea pops that YAML could be 
useful for some of us… so I quickly wrote an class to able Zend_Config 
to process YAML file using the code from Chris Wanstrath (SPYC), that’s 
the YAML parser used in Symfony.


As I didn’t pay to much attention to the CLA I’ve just upload the file 
as a “quick & dirty” hack… and finally Andi Gutmans friendly challenges 
me writing: ‘Now it's up to you to prove that PHP is much easier than 
.NET :)’.


So after some thinking, I’ve started to write some code but it seems to 
me that it will be better to have a parser implementation distinct from 
Zend_Config able to parse an YAML document very much like SAX does for 
XML … producing events that can be used to call some callback functions. 
It could be useful if the class can also provide an YAML Object to 
internally represents the parsed file and some additional method to 
convert it to an array than can be used with Zend_Config.


So basically I came with this minimal requirements:

- support the YAML 1.1 specification as define on the official web site 
(http://yaml.org/spec/current.html)

- the main class would be responsible for :

o loading & parsing an YAML document form different sources

o calling used defined callback function to handle parsing events (e.g. 
: LIST_OPEN, LIST_CLOSE, MAP_OPEN, MAP_CLOSE, LIST_NO_OPEN, MAP_NO_OPEN, 
DOCUMENT_START, DOCUMENT_END, MAP_SEPARATOR, LIST_ENTRY...) trough an 
event_handler class.

o provide access to the parsed document using alternatives like

§ returning an YAML Document Object

§ returning an PHP array

- the parser would be as much as possible an OOP implementation with 
support for

o a virtual class reader than can be derived to process different 
character stream (e.g.: file processing or http transactions)

o both UTF-8, US-ASCCI & ISO-8859-1 characters sets


So far I’m still working on all this stuff but it came nicely even if 
writing it’s not as easy as we can thing mostly because I had to write 
much of the production rules form the YAML language by hand and I 
haven’t wrote a full parser from scratch for a very long time (By the 
way, if any one knows about YACC or LEX equivalent tools to produce PHP, 
just let me know). For now the UML class diagram look just like this:


Except, for all the Yaml_Parser private functions that are omitted on 
purpose.


Hopefully I will post the first version of the code around 15/07 the 
time to send the Contributor License Agreement and to make some more 
progress in the writing/coding process



If you have some ideas on the subject or could help me to review my 
design, just let me know. I’m also very interested by any suggestion 
like implementing the multi-character sets support… This part doesn’t 
look like a piece of cake to me.


Thank you for reading me.


Bruno Couleau, Marseille – France.









 
____________________________________________________________________________________
TV dinner still cooling? 
Check out "Tonight's Picks" on Yahoo! TV.
http://tv.yahoo.com/

Reply via email to