Is there a parser that interprets the colon and comma?

I am new to using boost :: program_options and I would like to parse a numeric command line argument with a colon and comma. For example, I would like to have an argument like this:

myprogram --numbers 1:100,200,300 

Produce a vector with integers 1-100, then 200, and finally 300.

Is there a name for these designations?

My first inclination is that I will have to consider this argument as a string, and then pass it to a function-function that performs parsing. This seems to be a great candidate for "something that someone has already done and made available."

+4
source share
1 answer

I would use boost :: spirit and define some custom semantic actions . Make sure the boost :: spirit version you are using is compatible with the compiler with this. I had problems using the newer boost :: spirit with older compilers. Matlab calls the colon designation 1: 5. Pretty anti-climatic ??

0
source

Source: https://habr.com/ru/post/1403969/


All Articles