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

Appearance settings

A compiler front-end for Golang implemented using Python Lex and YACC that handles the switch and loop constructs

Notifications You must be signed in to change notification settings

abaksy/golang-mini-compiler

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

golang-mini-compiler

A compiler front-end for Golang implemented using Python Lex and YACC (PLY) that handles the switch and loop constructs of Golang

Optimizations implemented:

  • Constant folding and constant propagation
  • Packing temporaries (removing all unnecesary temp variables from TAC)

Code Structure

  • src/lexer.py - Generates Lex tokens from the input source file
  • src/parser.py - Takes a stream of tokens as input from lexer.py and runs the LALR parser logic (rules and actions) on the tokens (outputs the three address code)
  • src/optimize_tac.py - Runs the above mentioned optimizations on the generated Three Address Code from the parser
  • src/code.py - Contains class definitions for Three Address Code and AST nodes
  • src/symboltable.py - Contains class definition for SymbolTable

Command to run till IC Optimization Step:

export PATH=$PATH:/your-path-here/golang-mini-compiler
go-compile <path-to-filename.go>

About

A compiler front-end for Golang implemented using Python Lex and YACC that handles the switch and loop constructs

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.