logo       

changes to command line parsing: msg#00017

lang.nasm.devel

Subject: changes to command line parsing

In cleaning up the preproc.c interfaces, I notice that several functions are exported solely for the use of nasm.c when it processes command line options. It occurred to me that it might provide a better and more concise interface if the interface were made a little more generic, since my primary interest in cleaing up the interface is to allow for alternate preprocessors to be built. I thought of several options on which I would like your opinions:

OPTION A:
One way to do this would be to give the preprocessor a function which nasm.c would call and pass the whole command line (argc, argv). The preproc function would pick out and react to the things that affected it, returning the modified command line with the already processed arguments removed. Advantages are that new preprocessors could handle different command line arguments, and that the interface is very clean and easily understood. Disadvantages are that command line processing would no longer be localized to nasm.c, and that there would be no protection against future preprocessor modules overloading existing NASM command line parameters.

OPTION B:
Replace the torturous nested switch/case statements in nasm.c with code which separates the parsing of command line options from the processing of those options. I have in mind something like popt to parse. If we did it this way, then again, the preprocessor could get first chance at parsing the command line but it would use a common function that would be within nasm.c (or maybe moved to nasmlib). Disadvantages are that it still doesn't supply protection against preprocessor modules overloading existing NASM command line parameters. The advantage over option A is that the parsing is localized to one place.

OPTION C:
As option B, but instead of calling a function in preproc.c, preproc.c would supply only a data structure which describes command line args and nasm.c would perhaps append that to its own list and actually do all of the parsing on behalf of all other modules. Advantages over B are that now there is protection against overloading parameters. Disadvantages are that the interface between nasm.c and preproc.c is a little larger and more complex.

Opinions?

Ed



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise