Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Need help on File parsing

Thread Tools

Need help on File parsing

Rui Maciel
Posts: n/a
Nobody wrote:

> On Tue, 29 Mar 2011 01:15:09 +0100, Rui Maciel wrote:
>> But considering that the programmer opts for a SAX-type approach, and
>> knowing that the only thing that he gets is a tricked-out lexer and
>> that he is still forced to develop his own parser,

> You make it sound as if it's a significant issue. Once you have the
> lexer, XML is trivial to parse. There are no shift-reduce or
> reduce-reduce conflicts, because every construct begins with a token
> which is unique to that construct.

Writing your own parser is not a significant issue. That's why people opt
for the SAX approach. And you only stumble on shift-reduce/reduce-reduce
conflicts if you are trying to develop a parser for a language which
suffers from ambiguity issues, which doesn't really apply to XML or any
language based on XML.

>> So, if a generic XML API doesn't eliminate the need to develop a parser
>> to extract information then what's the point of adopting a generic
>> parser to begin with, let alone base their document format on XML?

> The point is that you don't have to code dedicated utilities for common
> tasks, as you can just use xslt, xquery, etc.

The point is that if a programmer tries to avoid developing a parser for
his language because he believes it takes too much work, adopting layers
of 3rd party libraries won't save him any work in the end, nor will it
make his life any easier.

Probably the only benefit a programmer gets from insisting in using those
3rd party libraries is that he can pad his resume with lots of buzzwords,
although in the end the only thing they demonstrate is that that
programmer invests his time implementing bloated tools and forcing the
wrong solutions onto jobs which otherwise would be considerably simpler
and more efficient.

> You don't have to write
> bindings for a variety of languages

It's irrelevant. Once you know how to develop a parser in a given
language you are able to develop a parser in any language you know.

> , as every common language already
> has XML parsers (and more, e.g. tools which will generate class
> definitions from a DTD or vice-versa).

As I've stated before, adopting a 3rd party library that handles XML
doesn't mean you avoided the need to develop your parser. You are still
forced to develop a parser, whether to parse a tree structure which is
assembled by the 3rd party library or to implement a working parser from
the glorified lexer which has been provided.

Adding to this, when someone mindlessly adopts a 3rd party library to
process XML documents and does so not because he believes XML is the right
tool for the job but simply because the 3rd party library is there and he
doesn't know any better, that person tends to be forced to shoe-horn XML
into an application which it isn't suited. This is one of the reasons we
tend to see XML being forced into uses that clearly it isn't the best tool
for the job. Or even adequate. It's one of those examples of "if all you
have is a hammer, everything looks like a nail".

> In many cases, the only valid reason for /not/ using XML is efficiency
> (I don't consider the vendor lock-in which proprietary formats offer to
> be a "valid" reason).

There are plenty of reasons why XML is not the right tool for the job, and
thanks to the "but there is an API for that" mentality, there are plenty
of examples that demonstrate how XML is being forced into jobs it isn't
fit to do. For example, it doesn't make any sense to rely on XML to
encode any data structure beyond trees. And some people insist on
pounding the XML hammer on that nail.

Rui Maciel
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Advice Help On Parsing A File Mrmaster Mrmaster Ruby 9 06-30-2009 04:55 AM
Need Help Parsing From File John Frame Python 12 12-10-2006 12:23 AM
Parsing data file, need help with the logic Perl Misc 6 06-27-2006 09:45 PM
In file parsing, taking the first few characters of a text file after a readfile or streamreader file read... .Net Sports ASP .Net 11 01-17-2006 12:44 AM
(noob) need help parsing Apache log file Koncept Ruby 9 03-03-2004 09:17 PM