I’ve looked through codeshare for a command parser that would do what I need to achieve and don’t think I see any that will do what I want. I have very little (actually no ) experience writing command parsers.
I basically need it to read in a command with 1 or more optional parms to build the actual call to the correct module in my code.
Here is a sample command
MOVE [*ABSOLUTE|RELATIVE] TO [+|-] NNNNNNN.NN IN [*STEPS|MICRONS|INCHES|MILLIMETERS] [[WITH|*WITHOUT] COMPENSATION] AT [*SPEED *SLOW|MEDIUM|FAST|NNN] * are defaults for the command Some sample commands would be • MOVE TO 5000 // uses defaults ABSOLUTE,STEPS,WITHOUT COMPENSATION and SPEED SLOW • MOVE ABSOLUTE TO 5000 IN STEPS WITH COMPENSATION AT SPEED 10 // MOVES to positio 5000 steps with compensation on at 10 step per steps • MOVE RELATIVE TO -254 IN MICRONS WITHOUT COMPENSATION // MOVES -254 MICRONS from the current position without compensation at a slow speed
This would result in call to move( struct move_parms ) or similar call
I can use a massive number of if/then/else or case statements but that can get messy and this is only one of the commands I’ll be coding.
So I am looking at some kind of command parser.
I’ve looked at various ones out there including some command parse generators like Irony but the language is very new to me and not yet sure how to implement it.
So I am looking for something simple that allows me to build command structure with about 20 commands and even more parms
Any idea’s or suggestions on where to start?