Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Compiler for a subset of C language

NotificationsYou must be signed in to change notification settings

Mahim1997/Compiler-Simplified

Repository files navigation

Compiler for a subset of C language

Input: A program in C language (a subset)

Output: Corresponding assembly code (with certain optimizations)

Highlights

  • Performed lexical analysis using Flex.

  • Performed syntactic analysis using Bison.

  • Implemented certain optimizations while generating assembly code such as:

    • NOP removal
    • Efficient usage of temporary variables
    • Faster multiplication/division by 2 using shift operations.
    • Removal of consecutive same operations

Execution Commands

For script execution

## Input file:  1505022_Input.txt## Output file: 1505022.asm  ./command.sh

For step-by-step execution

  bison -d -y 1505022.y# To run Bisonecho'===>>> 1st step bison -d -y 1505022_Bison.y done\n'  g++ -fpermissive -w -c -o y.o y.tab.cecho'===>>> 2nd step g++ -fpermissive -w -c -o y.o y.tab.c done \n'  flex 1505022.l# To run flexecho'====>> 3rd step flex 1505022_Flex.l done \n'  g++ -fpermissive -w -c -o l.o lex.yy.cecho'====>> 4th step g++ -fpermissive -w -c -o l.o lex.yy.c done\n'  g++ -o a.out y.o l.o -lfl -lyecho'====>> 5th step g++ -o a.out y.o l.o -lfl -ly done\n\n\n'  ./a.out 1505022_Input.txt# Run the program  g++ -o outOpt.out IntermediateCodeStuffs/OptimizerRunner.cpp# Run optimizations  ./outOpt.out

About

Compiler for a subset of C language

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp