Skip to content

alexander-koch/loopc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Loopc

License: GPL v3

This is a JIT compiler for the LOOP programming language written in Rust.

Language

The LOOP language is designed so that it computes only the functions that are primitive recursive. Therefore, it is not Turing Complete. A program consists of three diffent elements:

  • Assignment xi := xj (+|-) c
  • Sequential execution P1; P2
  • Loop loop xi do p end

Running programs

To run a program and display its result, you may want to specify input and output variables. An output variable is simply set by the output flag of the compiler. Inputs can be set using a 'start-up' program.

$ loopc x.loop -i "x1 := 5; x2 := 4" -o x1

The above example will run x1 := 5; x2 := 4 first and then execute the code contained in x.loop. By omitting the flags, the compiler will default to x0 as the output variable. If not set otherwise, variables will be initialized with zero.

Language extensions

The compiler offers simple language extensions that are not defined in the core language set. The following extensions are supported:

  • Assignment of variables to constants (and arithmetic)
  • Assignment of variables to other variables (and arithmetic)
  • Multiplication
  • Division
  • Modulo

You can disable these extensions by setting the --strict flag.

Compiling from source

To compile the source code, a system-wide copy of LLVM must be found within the PATH. The version must be compatible with llvm-sys found in the local Cargo.toml file. See https://crates.io/crates/llvm-sys for more info.

If there is a compatible version, just type

$ cargo install

Contributing

Feel free to file issues and send pull requests. Contributions are highly welcome!

License

Copyright (C) 2018 Alexander Koch. Licensed under GNU General Public License Version 3.

About

Compiler for the LOOP programming language

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages