
1. Update Package Lists
sudo apt update

2. Install Flex and Bison

sudo apt install flex bison

3. Verify the Installation

flex --version
bison --version


1. Process the Bison Parser File

Run Bison first to generate the parser C code and the token header file (y.tab.h or parser.tab.h), which the lexer needs:

bison -d parser.y

Note: This generates parser.tab.c and parser.tab.h (or y.tab.c/y.tab.h depending on your version).

2. Process the Flex Lexer File

Run Flex to generate the lexer C code:

flex lexer.l

Note: This generates a file named lex.yy.c.

3. Compile the Generated C Files

Compile all the generated C files together using gcc and link the Flex library (-lfl):

gcc parser.tab.c lex.yy.c -lfl -o my_program

(If your code includes a custom main() function and doesn't rely on the default flex library library, you can omit -lfl).

4. Run the Executable

Execute your compiled program:

./my_program
