Page 1
Prepared by Harald Gjermundrod
Bison Mini Tutorial
0) Requirements
a) The guide below should work for Windows Vista and Windows XP
b) Visual Studio C++ Express edition must be installed on your machine. You can
download this for free from: [Link]
1) Download and Install Bison
a) Download Bison from
[Link]
Choose the Complete package, except sources Setup . You will now download
[Link].
b) Run the downloaded file to install Bison. Use the default selection that the wizard
provides.
2) Setting the System Path
See the Flex mini tutorial, you only need to do this once.
Page 2
Prepared by Harald Gjermundrod
3) A simple Bison example
a) To use Flex/Bison you must use the Visual Studio 2008 Command Prompt. Click
on Start -> All Programs -> Microsoft Visual C++ 2008 Express Edition -> Visual
Studio Tools -> Visual Studio 2008 Command Prompt. (See Figure 1)
Figure 1: Start the Visual Studio 2008 Command Prompt
Page 3
Prepared by Harald Gjermundrod
b) You may want to navigate to a folder in your home-directory. Type cd
c:\Users\Your User Name (my user name is gjermundrod.h). Then you may want to
create a separate folder for comp375 course; this is done with the mkdir command.
In order to go to a new folder you use cd, to go back to the previous folder use cd ..
(that is cd followed by two dots).To list all the files in a directory use dir. To see all
the options that the Flex program provides to you can type bison -h (see Figure 2)
Figure 2: Use the Bison program
Page 4
Prepared by Harald Gjermundrod
c) You can use an editor to create your bison specification or download the example
([Link]) from the website and save it in your comp375 folder. You will then use
the following three commands:
flex calc3.l
bison -dl --o=[Link].c calc3.y
cl [Link].c [Link].c interpreter.c -o [Link]
[Link] argument (where argument is a source file like: [Link] )
See Figure 3 for an execution run.
Figure 3: Execution run