Giter Site home page Giter Site logo

pascalcompiler's Introduction

Semesteral Work

Intro

What is this?

For my programming languages and compilers course I was tasked with writing the front end of a compiler that creates either a GCC AST or LLVM Ir code. I chose LLVM partly because it was newer and seemed to have better documentation. My compiler will take pascal-looking code and spit out LLVM byte code which then gets compiled down to an executable.

What's in it?

In this project you'll find the lexical analyzer, the parser, the AST, and the IR codegen for that AST.

Usage

I used cmake to make my project and link llvm but the project can be made by just running make. It compiles to an executable called compiler. Run it to see the usage. It will display an ast and the outputted llvm code. It then writes the bitcode to the filename provided. If you want to do a full compile (compiler -> llc -> gcc) I made a compile.sh that will run each of those taking only the source filename as input.

Samples

The samples are located in the tests/testPrograms/samples folder. In there you'll find all the given samples plus the two of my own. They can be compiled all together by using the compileAllSamples.sh script in the root directory. It will output the bitcode, objects, and executables into separate folders in the samples directory.

- NOTE: Not all of the programs will compile successfully. I did not implement arrays so bubble sort and a few others will fail.

Grammar

The grammar can be found in the grammer.md, grammer-formal.md and first-follow.md files in the root directory. The grammer.md is simply a simplified version of the grammer-formal.md used to easier understand what was going on from the beginning. It might not be completely up to date.

pascalcompiler's People

Contributors

zachwood0s avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.