Coder Social home page Coder Social logo

dolorem's Introduction

Overview

The idea is to have a programming language with macros are so powerful, they can even call directly into the code generator.

Example

include "def.dlr";
funproto puts (str a;) i32;
defun main () i32 {
  puts "Hello, world!";
};

Macro Example

This is the current implementation of the not operator as a macro:

defun lower-not ((rtv a)) rtv
  (make-twin-rtv (LLVMBuildNot bldr (unwrap-llvm-value a) "not") a);
defmacro not
  (lower-not (eval (car args)));

This defines not as a macro, a function that is called at compile-time, that is passed a list of arguments and that can generate code.

not does so by evaluating its first argument (read: generating run-time code for evaluation of its first argument) and then calling into a regular function called lower-not which calls LLVMBuildNot and generates type information for the front-end.

Dependencies

  • Mac OS/Linux (BSD might work)
  • LLVM 12+

Compiling it

Just type make. You may need to specify the environment variables CC, CXX and LLVMPREFIX.

If you encounter any compiler errors, try running make report or use another version of LLVM.

Examples

You can find some examples -- including a pong implementation and a REPL for testing -- in the example folder.

dolorem's People

Contributors

shenniger avatar

Stargazers

Edward Berman avatar ebigram avatar Max Bernstein avatar Nada Amin avatar

Watchers

Nada Amin 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.