New XML parser written for D1 and D2.

Jeremie Pelletier jeremiep at gmail.com
Wed Oct 14 19:48:28 PDT 2009


Justin Johansson wrote:
> Jeremie Pelletier Wrote:
> 
>> He meant range structs as found in std.range and their array wrappers in 
>> std.array.
> 
> Oh, okay.  Just groked src and looks like it is a D2 only thing.  Do you happen to know
> what the derivation of the word "range" with respect to streams is?  I haven't come
> across it before used in this context.

I don't know where the word range comes from, sorry. I see them as 
streams because they work just the same, except for the different method 
names (ie front/back and put instead of read and write respectively).

>> A range is D's version of streams, so for example a simple reader might 
>> look like:
>>
>> void read(T)(in T range) if(isInputRange!T) {
>> 	while(!range.empty()) {
>> 		auto elem = range.front();
>> 		// process element
>> 		range.popFront();
>> 	}
>> }
>  
>> I think you confuse ranges with slices. Ranges are simply an interface 
>> for sequential or random data access. DOM trees and SAX callbacks are 
>> different methods of parsing the xml, a range is a method of accessing 
>> the data :)
> 
> Yes seems that way; my question apparently asked upon D1 knowledge only.
> 
> Re SAX, it easy enough to get James Clark's Expat 'C' parser happening with D.
> That has an event-based API.  Perhaps all the std D library needs do is wrap this.
> Whilst it's open source, dunno about the specific licensing issues though.
> 
> -- JJ
> 

Isn't expat slower than libxml2's SAX? Anyways I'd rather code a SAX 
module in D, if only to better know the internals of this method.

Jeremie



More information about the Digitalmars-d mailing list