I have performed the required translation in lex (scanner.l). After receiving arguments from the command line, the required value is generated. args_for_gen_value ({digit}{1,3}{space}{digit}{1,3}) {args_for_gen_value} { unsigned char paf_field[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; yylval->string = xstrdup(build_paf_val(yytext, paf_field)); return STRING; } Hopefully this will be of some use to someone.