Skip to content

A mini-compiler which produces intermediate code using Lex and Bison

Notifications You must be signed in to change notification settings

jnmunene/subset-compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MINI COMPILER USING FLEX & BISON

This repository has been created as a part of the compiler assignment . The compiler developed is upto the intermediate code generation phase.

Compiling the Code

flex lexanalyser.l

bison -d parser.y

gcc -c lex.yy.c parser.tab.c

gcc -o com.out lex.yy.o parser.tab.o

The 3rd command produces a warning which can be ignored .

Running the Compiler

The above sequence of commands produces an executable com.out which is our compiler . You can feed in the program to be compiled after typing ./com.out

followed by the input program . Type exit ; to escape from the process. The intermediate code will be available in a file named output.txt .

Alternatively you can write a program in a file and put it in the same directory and you canb compile it by using the redirection operator '<' Suppose the filename is program.txt

  ./com.out < program.txt

Dont Forget to put exit; at the end of the program to terminate compilations.

Intermediate Code will be available in output.txt

Sample program with its outputs

sample output

Documentation

The explanation for code portions are present in the comments in code .

Contribute

If you feel any changes to be made feel free to issue a pull request . The code performs poorly in memory optimisation for generating code

About

A mini-compiler which produces intermediate code using Lex and Bison

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published