This is a homework question. I would like to write a simple parser for Unix command line options.
First, I would like to define a grammar with BNF.
Options = Option | Options, space, Option; Option = OptionName | OptionName, OptionArguments; OptionName = '--', any character excluding '-' | OptionName, any character; OptionArguments = OptionArgument | OptionArguments, space, OptionArgument; OptionArgument = any character excluding '-' | OptionArgument, any character;
("any character" here is any alphanumeric character).
Does it make sense ? The next question is how to add "old" Unix options, which start with a single hyphen and can be grouped together (e.g.