While doing some reverse engineering of ptxas I discovered that their lexer was generated by lex in fast mode (lex -f). Knowing that nvidia trying to hide from us as much as possible it would be good to extract what tokens their lexer able to consume. Surprisingly I was unable to find in google solution for this simple task of tokens recovery. And even worse - seems that nobody understand how 40 year code in lex DFA works. So as usually I had do it by myself
Code
struct yy_trans_info
{
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
static const struct yy_trans_info *yy_start_state_list[3] =
{
&yy_transition[1],
&yy_transition[3],
&yy_transition[24],
} ;
if ( ! (yy_start) )
(yy_start) = 1; /* first start state */
while(1) {
yy_current_state = yy_start_state_list[(yy_start)];
yy_match:
{
const struct yy_trans_info *yy_trans_info;
YY_CHAR yy_c;
for ( yy_c = YY_SC_TO_UI(*yy_cp);
(yy_trans_info = &yy_current_state[yy_c])->yy_verify == yy_c;
yy_c = YY_SC_TO_UI(*++yy_cp) )
{
yy_current_state += yy_trans_info->yy_nxt;
if ( yy_current_state[-1].yy_nxt )
{
(yy_last_accepting_state) = yy_current_state;
(yy_last_accepting_cpos) = yy_cp;
}
}
yy_find_action:
yy_act = yy_current_state[-1].yy_nxt;
do_action:
switch ( yy_act )
{ /* beginning of action switch */
case 0: /* must back up */
/* undo the effects of YY_DO_BEFORE_ACTION */
*yy_cp = (yy_hold_char);
yy_cp = (yy_last_accepting_cpos) + 1;
yy_current_state = (yy_last_accepting_state);
goto yy_find_action;