I'm trying to read a known number (at runtime) of characters in a Flex lexer. I know it starts with a CRLF, so I match that, then read literal_length characters using yyinput.
<EXPECT_LITERAL>"\r\n" {
for(int i=0;i<literal_length;i++){
int c= yyinput(yyg);
if(c == EOF) break;
}
*yylval = val_new_s(yytext);
return(LITERAL);
}
But yyinput does not add the new characters, instead it contains:
*yy_c_buf_p = '\0'; /* preserve yytext */
yy_hold_char = *++yy_c_buf_p;
which means that yytext doesn't get the extra literal_length characters. I'd rather not create a new buffer to store them if I can avoid it, because I know the character sequence is already in memory.
Aside from completely redefining yyinput(), is there any way to keep the extra characters in yytext?