Hello,
the program I am writting receives a very complicated command line. One of the command line parameter itself actually describes some structure.
For example, the parameter may look something like this:
Code:
QUEUE1[1-50,700-1000],QUEUE2,QUEUE3[1-10,50-100]{1-3,5-5=CUAC,CUAD},QUEUE4{1-4=CUAU}
etc.
Or in other words, it consists of name of queues, than there may be a list of substrings (i.e. take only characters 1 to 50 and 700 to 1000), and than there may be a list of filters (i.e. character 1,2,3 and 5 must equal to 'CUAC' or 'CUAD'), etc.
Because of how the program is called, it has to be one string (no spaces). I am looking for an (academic) advice of how to parse such string effectively. For now, I have only implemented the queue names and substrings, and the parsing logic is getting pretty complicated and pain to modify. On the other hand, I would really prefer not creating a "sort-of" compiler with its own grammar.
I can expect that the command line is correct, and i may modify it a little (instead of ',' use '@', add " if required, or something like that...), but it must remain a single string and must be callable from bash.