Wednesday, October 9, 2013

How to Compile & Run LEX / YACC Programs on Windows ?

If you are installing Ubuntu (or any Linux based OS) on your system either through Virtual Box or by making your system Multi-Bootable, just to execute your Lex & Yacc programs; then you might be wasting your HDD space & your valuable time. You can easily skip this annoying process and run your programs in Windows OS without any hassles.

Here's how you can do it:


Installing Softwares:
  1. Download Flex 2.5.4a
  2. Download Bison 2.4.1
  3. Download DevC++
  4. Install Flex at "C:\GnuWin32"
  5. Install Bison at "C:\GnuWin32"
  6. Install DevC++ at "C:\Dev-Cpp"
  7. Open Environment Variables.
  8. Add "C:\GnuWin32\bin;C:\Dev-Cpp\bin;" to path.

Compilation & Execution of your Program:

  1. Open Command prompt and switch to your working directory where you have stored your lex file (".l") and yacc file (".y")
  2. Let your lex and yacc files be "hello.l" and "hello.y". Now, follow the preceding steps to compile and run your program.
    1. For Compiling Lex file only:
      1. flex hello.l
      2. gcc lex.yy.c
    2. For Compiling Lex & Yacc file both:
      1. flex hello.l
      2. bison -dy hello.y
      3. gcc lex.yy.c y.tab.c
    3. For Executing the Program
      1. a.exe

Video:






Labels

alp (8) c (11) c++ (5) command (4) computer (21) convolution (5) download (2) knowledge_stuff (62) laboratory (21) leisure_stuff (11) matlab (3) ppt (3) programming (3) project (4) report (2) samples (2) seminar (3) university (21)

Share and Spread...!!