Project Phase 2:

Syntax Analysis: Parser

Your tasks:

1. You will be using Bison parser generator.

2. Use this grammar  with bison, together with your previous lexer.

3. At that point of the project, you need to generate the following:

Example: The first few lines of rules.out may look like:

What you need to Submit:

  1. Your input file to bison
  2. Your input file to flex
  3. Any extra code you have written external to the above files
  4. A small README file to tell us how to compile and run your project.

Submission rules
  1. The lab submission must be sent as an attachment to an email sent to the TA.
  2. Subject: of the email must be Compiler-Parser-lastname-firstname, lastname is your last name in lower case and firstname is your first name in lower case.
  3.  Put all your submission files in a directory called "parer-lastname-firstname"  then tar/zip the whole directory.
  4. Send the tar/zip file as an attachement to the email.

A useful comment about Bison:

There is an array called yytoknum, and you need to pass the index from yytname to yytoknum to get the actual value of the token.  This is not documented in the Bison 1.875 manual.  You have to specify 
"#define YYPRINT" in order for the yytoknum array to be created. Here is the link to the bug report I found:


You can call bison with flag –d to create header file containing token numbers (used in flex). Since bison creates token numbers, bisonshould be called before flex

You can also call bison with –v flag to dump output file showing resulting LR state machine and any shift-reduce, reduce-reduceerrors.