On Friday 02 September 2005 07:27, Zac Medico wrote:
> Paul de Vrieze wrote:
> > On Wednesday 31 August 2005 14:57, Brian Harring wrote:
> >> Re: tagging EAPI at the top of a file, infra would probably shoot me
> >> for doing such- till a live, fully compatible and *roughly*
> >> equivalent parser is available, portage would have to do a bit of
> >> grepping, jacking up the regen times.
> >
> > If in cache EAPI can be gotten from the cache. If not, I don't think
> > it matters where in the file EAPI occurs from the standpoint of
> > getting it's value. The only thing would be that in the future a fast
> > EAPI parser could be made that would just look at EAPI and get its
> > version. I could easilly write you such a parser.
>
> It is impossible write a parser for an unconstrained and unknown format
> that may exist in the future.  If we put a constraint on the format, in
> order to parse the EAPI, then we contradict our original goal (to
> unconstrain the format).

It would be possible to make these restrictions small. A workable 
restriction could be to put the EAPI statement in the front of the file 
only preceded by whitespace and comments. After the line with the EAPI 
statement anything could happen. Even a completely binary format could be 
used. But indeed no constraints is impossible, so putting the format 
statement in the start of the file is the best solution. Besides the fact 
that it makes detecting the format that much faster, and allows bailing 
out before parsing the whole file if an unsupported api is detected.

> A better approach IMO would be to store the EAPI in a separate file
> such as metadata.xml.  This would allow *absolute* flexibility in the
> "ebuild" format.  Portage would be able to select an appropriate parser
> with no need to examine the "ebuild" itself.

Please don't. Parsing xml is a lot harder than recognizing lines. A simple 
EAPI parser would probably use canned (library) line reading functions 
and then look if the line starts with "EAPI=". If so it reads the EAPI, 
else it checks the next line. No need to understand anything else of the 
file format.

Paul

-- 
Paul de Vrieze
Gentoo Developer
Mail: [EMAIL PROTECTED]
Homepage: http://www.devrieze.net

Attachment: pgp3kuxMM0HR2.pgp
Description: PGP signature

Reply via email to