So I have to make a flex program that matches numbers, floats, symbols, and comments.
The regular expressions are in the file.
The flex.l file http://pastebin.com/iuJ8WW6m
The weird part is the output.
Lets say I’m giving it:
0 0.0 323 323.4 1.3.4
variable another_variable
"string"
;comment
69
This is the output:
Number: -->0<--
Float: -->0.0<--
Number: -->323<--
Float: -->323.4<--
Float: -->1.3<--
Number: -->4<--
Symbol: -->variable<--
<--bol: -->another_variable
String: -->"string"<--
<--ment: -->;comment
Number: -->69<--
Why is the output at “another_variable” like this <–bol: –>another_variable ?
I know some c/c++ and for me this makes 0 sense.
Same goes for <–ment: –>;comment
Apparently it takes the 3 last character (<–) and places them on top of the first 3(Com), But why?
If i give it only
;comment
The output is “Comment: –>;comment<–“, As soon as I insert a new line after it, it messes up again. I also tried the same with printf and using ECHO, but the result is the same.
Help, thanks!
I suspect that part of the the newline sequence that follows the recognized comment or symbol is being captured into yytext, and hence echoed back in your debug trace.
Try adding \r to the character class, like so:
In any event, you might want to pipe your debug output into a file so that you can examine it characterwise, with a tool like od.