Git Product home page Git Product logo

csci-468-spring2021-private's Introduction

CSCI 468: Compilers

This is the base upstream repository for CSCI 468, compilers. It holds the base code for the compiler that we will write for the class. The project will be done in pairs. Note that this class is a capstone class in the CSCI department and, as such, requires capstone documentation. An outline of this can be found in the /capstone directory.

Getting Your Repo Set Up

For the project leader, please follow these instructions

  • Create a private repository in your own account by
    • Going to https://github.com/new
    • Enter the name csci-468-spring2021-private
    • Select Private
    • DO NOT ADD A README.MD or .gitignore!
    • Navigate to the Settings -> Manage Access section
    • Add 1cg as a collaborator
    • Add your partner as a collaborator

Once your repository is initialized, you and your partner can pull it down to your local machines. Instructions can be found on the home page of your new repository.

Next, you and your partner should both add the class repository as an upstream git repo:

$ git remote add upstream https://github.com/msu/csci-468-spring2021.git
$ git pull upstream main
$ git push

This will synchronize your private repository with the class repository.

When you want to get an update from the public class repository you can run this command:

$ git pull upstream main

CatScript

In this course we will be creating a small programming language called CatScript

CatScript Grammar

catscript_program = { program_statement };

program_statement = statement |
                    function_declaration;

statement = for_statement |
            if_statement |
            print_statement |
            variable_statement |
            assignment_statement |
            function_call_statement;

for_statement = 'for', '(', IDENTIFIER, 'in', expression ')', 
                '{', { statement }, '}';

if_statement = 'if', '(', expression, ')', '{', 
                    { statement }, 
               '}' [ 'else', ( if_statement | '{', { statement }, '}' ) ];

print_statement = 'print', '(', expression, ')'

variable_statement = 'var', IDENTIFIER, 
     [':', type_expression, ] '=', expression;

function_call_statement = function_call;

assignment_statement = IDENTIFIER, '=', expression;

function_declaration = 'function', IDENTIFIER, '(', parameter_list, ')' + 
                       [ ':' + type_expression ], '{',  { function_body_statement },  '}';

function_body_statement = statement |
                          return_statement;

parameter_list = [ parameter, {',' parameter } ];

parameter = IDENTIFIER [ , ':', type_expression ];

return_statement = 'return' [, expression];

expression = equality_expression;

equality_expression = comparison_expression { ("!=" | "==") comparison_expression };

comparison_expression = additive_expression { (">" | ">=" | "<" | "<=" ) additive_expression };

additive_expression = factor_expression { ("+" | "-" ) factor_expression };

factor_expression = unary_expression { ("/" | "*" ) unary_expression };

unary_expression = ( "not" | "-" ) unary_expression | primary_expression;

primary_expression = IDENTIFIER | STRING | INTEGER | "true" | "false" | "null"| 
                     list_literal | function_call | "(", expression, ")"

list_literal = '[', expression,  { ',', expression } ']'; 

function_call = IDENTIFIER, '(', argument_list , ')'

argument_list = [ expression , { ',' , expression } ]

type_expression = 'int' | 'string' | 'bool' | 'object' | 'list' [, '<' , type_expression, '>']

CatScript Types

CatScript is statically typed, with a small type system as follows

  • int - a 32 bit integer
  • string - a java-style string
  • bool - a boolean value
  • list - a list of value with the type 'x'
  • null - the null type
  • object - any type of value

:) :) :)

csci-468-spring2021-private's People

Contributors

micmicmw avatar 1cg avatar buwanim 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.