flex 2.5.35 gives error when ctrl-M used in lex file

159 views Asked by At

I have a simple lex file.

%{
#include <stdio.h>
%}

space_char      [ \t\^M]
space           {space_char}+ 

%%

%%

int yywrap(void) {
    return 1;
}

int main(void) {
    yylex();
    return 0;
}

When I compile this file with flex-2.5.35, it gives following errors: lex.l:5: bad character: lex.l:5: name defined twice

But, with flex-2.5.4, it runs fine. I understand this error is due to special character ctrl-m (carriage-return). I want to know if flex-2.5.35 doesn't support special characters like ctrl-l, ctrl-m? And if so, then what's the alternate way? Please note, I am restricted with the use of 2.5.35 only.

Thanks.

1

There are 1 answers

0
rici On

As in C, you can use \r for the carriage return character.