pupa-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Argument parser


From: Marco Gerards
Subject: Re: Argument parser
Date: 15 Dec 2003 23:51:15 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

"Yoshinori K. Okuji" <address@hidden> writes:

> On Monday 15 December 2003 22:51, Marco Gerards wrote:
> > Not always.  In your example the arguments (short, long and other)
> > age mixed up.  In that case you cannot use an array.
> 
> I mixed up them intentionally, because you said that the GNU way was 
> easy to implement. I showed a simple example that the GNU way was not 
> easy actually.

Ah, ok.  It is not hard to implement IMO.  The logic is in the parser
(which is small as well).  Perhaps it looked hard to you to implement
a parser using what I proposed.  I think this is actually is easier to
do.  The produced binary won't be too big I think because most lines
are just descriptions of the arguments and parts of the switch
statement.

> If you follow the GNU way, your parser or the implementation of a 
> command function must be complex. If you make your parser easier, the 
> burden would just move to one who uses your parser.

It does not have to be complex (see my code, it is not complex IMHO).
All the parsing is done by the global parser, the command doesn't need
to do anything to special to support GNU features.  I like putting the
burden at one single place so it is not required to do much parsing in
the command itself.

> > Of course it is easy to make an array of the arguments that are not a
> > short/long option.  This array can be passed to the command as
> > well. So a command can look like this:
> >
> > int pupa_cmd_ls (..., char *args[]);
> 
> That's right. That's the very thing I wanted to mean.

Ok, does this remove the complexity for your feeling?

> I still think it would be better to use the POSIX way than the GNU way, 
> to make everything easier and simpler. As most people don't use a boot 
> loader interactively frequently, this should be a good decision.

It is not hard to support the GNU way with this little code.  Do you
think the parser is still to big? (It's 10% of the code of the
smallest popt implementation...)

What do you exactly mean with the POSIX way?  Only short options?

What would you like to see?  Should I change my parser by calling the
command with the "char *args[]" like I explained in my previous mail
or do you want to see more changes or something completely different?

To me this just seems like a matter of taste. :)

Thanks,
Marco





reply via email to

[Prev in Thread] Current Thread [Next in Thread]