GithubHelp home page GithubHelp logo

cfcompiler's Introduction

Compiler for the CF language by Kevin Hammond

#Design Decisions

  • I decided to interpret while (condition) don't {dostuff} as while (not condition) do {dostuff}.
  • I decided to implement the comefrom statement by making each label a goto statement and each comefrom a label. This requires that every label has exactly one comefrom statement and vice versa. The alternative is to perform an additional pass over the AST to determine which labels are unneccessary.

#Features

  • I have introduced an extra AST node type - the Line class - to represent a line of code. If a node within the line fails to compile, the error message can include the line number and context.
  • If a stat fails to compile within a Stats node, the compiler will log the failure and attempt to continue compiling. This allows it to detect multiple compilation failures while compiling. lines
  • One problem with the comefrom statement is that the stack may be different at the label to what is at the comefrom. To stop this, I decided that label-comefrom pairs must be within the same stats list, where the stack will always be the same.
  • Comefrom statements may also allow a variable declaration to be skipped (e.g. l;new x=5;comefrom l;print x would cause problems). The Stats compiler class checks for this possibility and logs an error if it happens.

Future Work

  • Tiling - boolean operations (among others) such as the not operation would benefit from a tiling algorithm to remove useless code.
  • More control flow in the language, such as if statements.
  • Integration of a lexer.

#Build Instructions

  • To compile: sbt package
  • To test: sbt test
  • To run code coverage while testing: sbt clean scoverage:test

cfcompiler's People

Contributors

neilw4 avatar

Watchers

 avatar  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.