Grammar for order insensitive command line options in antlr4 -


I am using NTLR 4 for command line parsing.
Format of my grammar
Commands: subcommand1 | Sub Command 2: Sub-Command1: 'Sub 1' option 1 Option 2 - Sub Command 2: Option 2 option '1' - Option 1 'id - Option 2:' - Option 2 ' ID option - 3: 'Option 3' id - Option 4: '-Payment 4' ID - ID: [A-GA-Z-09] +

I have insensitive options for each sub command I want to - for example sub command - paragraph 1 ABC-PIN2 should be treated as a valid input - as well as sub-order - page 2 - PQR - option 1 AB The person should also be considered as a valid input

A tremendous force to change grammar method sub-command 1: 'sub 1' (option 1 option 2 | option 2 option 1)
sub Order 2: 'all 2' (option3 option4 | option3 option 4)

But this does not make it normal and another option would require 6 numbering of options.
Is this an easy way to do this?

You should make your grammar generic, do not name the hardcod option in grammar, but generate a generic laser and Then explain the option names in your application.

I mean something like this:

  grammar command line; Command: ID option *; Option: Option ID; Options: '-' ID; ID: [A-zA-Z0- 9] +;  

Then use the code to remove the alternate names.


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -