5

Note: Someone with over 1500 rep.. please add flex++ and bison++ as tags :).

Seems like people all over the Internet have been getting the following errors with Flex++:

scanner.l:1: bad character: %
scanner.l:1: unknown error processing section 1

This happens on any example I give Flex++. The version I have is from here and I have tried the exact examples on that page and I still get these errors. I've tried on Linux and Mac and have completely run out of ideas!

Seems like Flex++ is a name for an old virus out there too so it's particularly hard getting useful discussion!

EDIT:

Here's an example that produces the above error (first few lines from example taken from the link above):

%name CalcScanner
%define IOSTREAM
%define LEX_PARAM YY_CalcParser_STYPE *val, YY_CalcParser_LTYPE *loc
%define MEMBERS public: int line, column;                                                                                               
%define CONSTRUCTOR_INIT : line(1), column(1)

%header{
#include<sstream>
#include "parser.h"
%}

Any help would be more than fantastic.

EDIT 2: Please can people not edit this post by putting the 'flex' tag in? Flex would be what I would use to tag but Flex is also an Adobe technology - it's NOT the tool I am using. The flex tag on SO is for the Adobe product (hence the logo on the tag). Thank you :).

Lesmana
  • 25,663
  • 9
  • 82
  • 87
ale
  • 11,636
  • 27
  • 92
  • 149

1 Answers1

2

Check your line-endings? CR+LF vs NL might make a difference here.

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720
  • Good idea but unfortunately, doesn't seem to be the case. Also, it complains about the very first character in the file which is confusing :s! – ale Jul 09 '11 at 23:42
  • If the line endings were wrong, then flex++ would consider the entire file to be in line 1. It could then be the second instance of `%` it's complaining about. Can you put just the first line into a file by itself and see if the error messages are the same? – Ben Voigt Jul 09 '11 at 23:44
  • Thanks for the tips Ben. Firstly, changing the line endings doesn't fix the problem... I've tried both types by switching endings, saving as a new file and running it on the new file. Putting the first line into a file of its own produces this: – ale Jul 09 '11 at 23:58
  • `scanner2.l:1: bad character: % scanner2.l:1: unknown error processing section 1 scanner2.l:1: unknown error processing section 1 scanner2.l:1: unknown error processing section 1 scanner2.l:1: premature EOF` – ale Jul 09 '11 at 23:59