Home

Frequently Asked Questions
 

 

 

 

Topics

bulletFlex
bulletBison
bulletLinking Errors With the Parser
bulletResolving Conflicts
bulletMain Function for Compiler
bulletSample Programs

Flex

bulletThe file flex.ske must be in the same directory as your compiler. 
bulletIn the file flex.ske, comment out the line #define yywrap() 1.

Back

Bison

bulletThe files bison.hai and bison.sim must be in the same directory as your compiler. 

Back 

Linking Errors With the Parser

bulletIt is possible to get a linking error because of alloca. This can be solved by including malloc.h in the tiger.y (tiger.grm) file.

Back

Resolving Conflicts

bulletIt is sometimes helpful to add key words to the precedence rules. This eliminates some conflicts. I would add the following at the lowest precedence. 
%right OF
%right ELSE THEN DO 
%right ASSIGN

Back

Main Function for Compiler

bulletLook at the file main.c for the main function. You can add to it as needed. 

Back

Sample Programs

bullet

The follow are examples of an interesting applications:

towers.cpsl is the solution to Towers of Hanoi. Input is the number of disks.
fractions.cpsl computes the fractions 1/i, i = 1 ... 32, exactly. There is no input.
powers.cpsl computes the values of 2i and 2-i, for i = 1 ... 32. There is no input.
primes.cpsl computes the first 252 prime numbers. There is no input. 
postfix.cpsl changes infix expressions into postfix expressions. Input is an expression with each character on a separate line and the final line having only a newline character.
queens.cpsl shows all solutions to the eight queens problem. There is no input.
permute.cpsl generates all permutations of the input string. Input is the string to permute.

 Back

Send mail to Steve.Allan@usu.edu with questions or comments about this web site.
Last modified October 05, 2005