Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BNF command line parser #17

Open
sylvainhalle opened this issue Mar 14, 2023 · 0 comments
Open

BNF command line parser #17

sylvainhalle opened this issue Mar 14, 2023 · 0 comments

Comments

@sylvainhalle
Copy link
Owner

sylvainhalle commented Mar 14, 2023

Existing command line parsers (including Bullwinkle's CliParser) offer a restricted way of defining command line arguments: either -parameter or -parameter value.

Create a new parser where arguments are defined with a BNF grammar. Parsing a command line produces a parse tree that the user can then traverse.

Example:

<S>     := <param> <S> | <param> ;
<param> := <p1> | <p2> ;
<p1>    := -p <args1> ;
<args1> := <num> <num> | zig <num>;
<p2>    := ^foo(bar|baz)$;
<num>   := ^\d+$;

Valid calls would be, for example:

  • -p 123 45
  • foobaz
  • foobar -p zig 2
  • -p 1 2 foobar -p zig 34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant