yacc/lex or bison/flex in visual studio?

V

Volker Hetzer

Hi!
We are finding ourselves in a situation where we have to parse
several more or less free format text files.
In the past, on linux, we had flex and bison for generating
very fast parsers for these files.
Is there any equivalent in the visual studio world?

Lots of Greetings!
Volker
 
C

Carl Daniel [VC++ MVP]

Volker said:
Hi!
We are finding ourselves in a situation where we have to parse
several more or less free format text files.
In the past, on linux, we had flex and bison for generating
very fast parsers for these files.
Is there any equivalent in the visual studio world?

Yes, they're spelled YACC, Lex, Bison and Flex. All can be built for
Windows just as easily as for *nix. Just go download the sources & build
'em.

-cd
 
N

Norman Diamond

Carl Daniel said:
Volker Hetzer wrote:

Yes, they're spelled YACC, Lex, Bison and Flex. All can be built for
Windows just as easily as for *nix. Just go download the sources & build
'em.

If the goal is just to run them under Windows without needing to integrate
them into Visual Studio, then there's an even easier way to get yacc and lex
under Windows. Windows Services for Unix comes as part of MSDN, and I seem
to recall reading that anyone can download it freely.
 
V

Volker Hetzer

Norman said:
"Carl Daniel [VC++ MVP]"
Volker Hetzer wrote:

Yes, they're spelled YACC, Lex, Bison and Flex. All can be built for
Windows just as easily as for *nix. Just go download the sources &
build 'em.

If the goal is just to run them under Windows without needing to
integrate them into Visual Studio, then there's an even easier way to
get yacc and lex under Windows. Windows Services for Unix comes as part
of MSDN, and I seem to recall reading that anyone can download it freely.
Uh, if possible we would like to integrate them into visual studio, a bit like
a preprocessor.
We have almost no experience using visual studio.
Is there some equivalent to Unix' make mechanism where I just define two
suffixes and the rule transforming one file into the other automatically?

Lots of Greetings!
Volker
 
C

Carl Daniel [VC++ MVP]

Volker said:
Norman said:
"Carl Daniel [VC++ MVP]"
Volker Hetzer wrote:
In the past, on linux, we had flex and bison for generating very
fast parsers for these files.
Is there any equivalent in the visual studio world?

Yes, they're spelled YACC, Lex, Bison and Flex. All can be built
for Windows just as easily as for *nix. Just go download the
sources &
build 'em.

If the goal is just to run them under Windows without needing to
integrate them into Visual Studio, then there's an even easier way to
get yacc and lex under Windows. Windows Services for Unix comes as
part
of MSDN, and I seem to recall reading that anyone can download it
freely.
Uh, if possible we would like to integrate them into visual studio, a
bit like a preprocessor.
We have almost no experience using visual studio.
Is there some equivalent to Unix' make mechanism where I just define
two suffixes and the rule transforming one file into the other
automatically?

Yes. Under VS 2005 you can define custom tools that the C++ project system
will use to build new file types. Some of the beta versions of VS 2005
actually included tool definitions for yacc/lex, but they don't appear to be
included in the released version, so you'll have to define them yourself.

Finding the options in the help is rather torturous, but...

In the solution explorer, right-click on your C++ project and choose "Custom
Build Rules..." from the context menu.
On the dialog that appears, click "New Rule File...".
Give your new rule file a name, like "Compile with YACC"

.... and so on. It's a bit more involved than one might hope (but it's also
pretty powerful). See

http://msdn2.microsoft.com/en-us/library/03t8bzzy.aspx

as a starting point.

-cd
 
V

Volker Hetzer

Carl said:
Yes. Under VS 2005 you can define custom tools that the C++ project system
will use to build new file types. Some of the beta versions of VS 2005
actually included tool definitions for yacc/lex, but they don't appear to be
included in the released version, so you'll have to define them yourself.
Great!
As soon as we get VS2005 we will try it.

Thanks a lot!
Volker
 
C

Carl Daniel [VC++ MVP]

Volker Hetzer said:
Great!
As soon as we get VS2005 we will try it.

You can also do something a little less fancy with older versions of VC -
you can define a custom build step for a file. In terms of building your
project, it's just as useful as the custom tool file, but you have to re-do
the custom build step in each new project, while you can simply re-use the
custom tool file once you've built it once.

-cd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top