পৃষ্ঠাসমূহ

Wednesday, April 30, 2014

How to get & install Flex & Bison ?

Flex

Flex is a tool for generating scanners. A scanner, sometimes called a tokenizer, is a program which recognizes lexical patterns in text. The flex program reads user-specified input files, or its standard input if no file names are given, for a description of a scanner to generate. The description is in the form of pairs of regular expressions and C code, called rules. Flex generates a C source file named, "lex.yy.c", which defines the function yylex(). The file "lex.yy.c" can be compiled and linked to produce an executable. When the executable is run, it analyzes its input for occurrences of text matching the regular expressions for each rule. Whenever it finds a match, it executes the corresponding C code.

Bison

GNU bison, commonly known as Bison, is a parser generator that is part of the GNU Project. Bison reads a specification of acontext-free language, warns about any parsing ambiguities, and generates a parser (either in CC++, or Java) which reads sequences of tokens and decides whether the sequence conforms to the syntax specified by the grammar. Bison by default generates LALR parsers but can also create GLR parsers

How to get and install Flex & Bison?

For Windows user: 

you should download this file ( link ). Unzip it. Copy the path of the Bin folder. Then goto Control Panel -> System -> Advanced System Settings. New pop up will come, click Advanced tab, and click environmental variables button below. A new pop up will come. Under the System Variable section, find the row named path. Double Click on that row, new message box will open, go to the end of the string. Paste the path of the Bin folder ( Unzipped folder ) and add a semicolon (;) at the end. Save it. Close all the Boxes. 

For Ubuntu ( linux) user:

you should write this on terminal : sudo apt-get install flex && bison. This command will automatically install flex and bison. 

Checking whether installation is OK

Now open "Command Line Window" or "Terminal" , write flex --version or bison --version command, you will see the version of flex and bison, that means flex and bison are installed on your computer.

No comments: