2

I'm running on a Debian Squeeze and I get flex/flex++ installed using apt-get install flex.

However I noted that flex++ is just a sym link to flex. So, really exists an "program" flex++ that generate c++ scanners or is just a flex flag that I shoud switch?

Also, the common problem: Many examples on the internet can't "compile" under flex or flex++. Flex give the following error:

test.lex:1: invalid character: %
...

when processing an input with just:

%name Test

what is wrong here?

Flex/Flex++ version is 2.5.35

JohnTortugo
  • 6,356
  • 7
  • 36
  • 69
  • As a first guess, I would check to see if test.lex is saved as a UTF-8 file with a BOM. That trips up lots of these tools. – Jeffery Thomas Jul 14 '12 at 01:12
  • 1
    There is a good example in this page: http://www.thebinaryidiot.com/archives/2010/03/06/flex-bison-cpp-example/ I compiled and ran fine in my Debian Squeeze. I've installed bison with apt-get install bison – JohnTortugo Jul 18 '12 at 17:13

1 Answers1

5

There is actually a Flex++ project, but it is separate to the original Flex:

Flex does support generating scanner code for use with C++, but it is classed as experimental (though it has been there for quite some time):

The symlink is explained by the fact that some programs modify their behaviour based on how they are invoked. For compatibility reasons, they check argv[0] and look at the executable name. For example, when run as flex++, it can enable the -+ flag for C++ support.

(BusyBox uses this technique to have one binary behave as many separate programs, saving space.)

rici
  • 234,347
  • 28
  • 237
  • 341
gavinb
  • 19,278
  • 3
  • 45
  • 60
  • 1
    According to the package specs at http://packages.debian.org/squeeze/flex the Flex in squeeze is definitely the usual http://flex.sf.net/ . Try using %option yyclass="Test" rather than %name. – gavinb Jul 17 '12 at 00:22