I am working with Lexical Analysis. For this I am using Flex
and I fetch following Problems.
int cnt = 0,num_l
I'm not very sure about the tab problem but one explanation is that if you don't place tab and write in the first section something like:
int cnt = 0;
Then note that in the first section you may also write "shortcuts" like:
Digit [0-9]
which is a regular expression that defines what digit is instead of writing all the time [0-9]
to denote digit.
So when writing int cnt = 0;
in the first column without using tab is like defining the keyword int (that's probably why the error tells you did you mean int’?
). So tab is a way to distinguish the two above cases.
According to flex in order to write c/c++ code it needs to be inside:
%{ ... c/c++ code... %}
so for your example:%{ int cnt = 0,num_lines=0,num_chars=0; %}
So I thing the best way is to write your c-code inside %{ %}
.