I am studying viruses and trying to figure out how the FLEX module works for C++. I have taken classes before on regular languages, context free, etc. Is FLEX dealing with regular languages or regular expressions, and also what is the difference exactly? Could you give an example of how a flex program works and or point me to a link that does? How it integrates with C++? I am trying to use it to scan for particular code in viruses as a parser.

Is FLEX dealing with regular languages or regular expressions, and also what is the difference exactly?

A regular language is, by one of many definitions, a formal language that can be described by a regular expression. Regular expressions are a convenient way to describe a regular language without having to specify all of the sequences that are in the language. This is convenient when the language is infinite.

Flex generates code that checks an input stream to see if it matches any one of a list of regular expressions.

Could you give an example of how a flex program works and or point me to a link that does? How it integrates with C++?

The Flex manual is a good place to start; it has some simple examples near the start.

Flex generates a C source file with the scanner definition and assorted support code. This should work with a C++ program as is, but there is also experimental support for generating a C++ scanner.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.