Skip to content
/ nrc Public

A toy R compiler in R

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

igjit/nrc

Repository files navigation

nrc

Travis-CI Build Status Coverage status

nrc aims to be an R version of 9cc: R compiler written in R.

Installation

You can install nrc from github with:

# install.packages("remotes")
remotes::install_github("igjit/nrc")

Note: currently nrc only works on Linux.

Try in Docker:

$ docker run --rm -it rocker/tidyverse:3.6.2 R -q
> remotes::install_github("igjit/nrc")

How to play

library(nrc)

compile("1 + 2")
#> .intel_syntax noprefix
#> .global main
#> main:
#>   push rbp
#>   mov rbp, rsp
#>   sub rsp, 0
#>   push 1
#>   push 2
#>   pop rdi
#>   pop rax
#>   add rax, rdi
#>   push rax
#>   pop rax
#>   mov rsp, rbp
#>   pop rbp
#>   ret
compile("1 + 2") %>% assemble() %>% execute()
#> [1] 3
compile("a <- 2; a * 3") %>% assemble() %>% execute()
#> [1] 6
compile("add2 <- function(x) x + 2; add2(40)") %>% assemble() %>% execute()
#> [1] 42

About

A toy R compiler in R

Topics

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published