Giter Site home page Giter Site logo

yot-lang's Introduction

Yotc

LLVM frontend for yot - a toy language.

Loosely based off of LLVM Kaleidoscope

Running

  • Install LLVM 9.0
  • Install yotc with cargo install yotc
  • For automatic linking (a.k.a. default output format "executable"), gcc needs to be in PATH
  • Usage: yotc (path to file)
  • Run yotc --help for more options

Yot Syntax

  • Note: every variable is a 32-bit int and functions must return an int as well. Comparison operators return 1 or 0
  • Functions:
    • Regular syntax
      @sum[a, b] {
          -> a + b // -> is the return keyword
      }
      
    • Short-hand notation for just return statement
      @sum[a, b] -> a + b;
      
    • External functions
      @!print[_, _];
      
    • Calling a function
      sum(a, b);
      
  • Variables:
    • Declaration with value
      @a = 5;
      
    • Declaration without value (will be assigned to trash value)
      @a;
      
    • Referencing a variable
      @b = a + 5;
      
  • Operations
    • Available operations =, +, -, *, /, ==, !=, <, >, <=, >=.
      @a = (-b + 5) - 10 / -(5 - -2);
      
  • Comments
    • Comments start with // and tokens are ignored until the end of the line
  • Programs
    • A program consists of just top-level functions (no global variables yet)
    • main function entry point
  • Example
    • See examples/
    • Run by first generating the object file of equals_ten.yot with yotc equals_ten.yot -f object-file
    • Compile and link io.cpp with g++ io.cc equals_ten.o to generate an executable

Todo

  • If, for, while statements
  • LLVM IR optimization
  • Support printing string literals
  • Better compiler errors
    • Current errors are either vague or plain wrong and dont have any information about line number
    • Most errors are caught by LLVM, meaning more ugly and vague error messages
  • More data types (float, bool, char)
  • Testing

yot-lang's People

Contributors

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