Skip to content

RiverDave/InterfuseLang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Interfuse

Programming language developed for fun & with the intention of learning compiler theory!. Its syntax its inspired on C, its based upon most modern programming languages and its currently under development.

Installation(Tested on MacOS)

Build the project using the following commands:

# Make sure to have LLVM installed on your system. It may be different
# depending on your OS.
mkdir build
cd build
cmake ..
make

To compile the program, you can use the following command:

./interfuse [path_to_file] [flags] [binary_name] # Will generate an executable with the specified binary name
  • Flags:
-v # Verbose mode (prints the LLVM IR code & explicitly display lexing process)
-o # Output file name
-d # Dump LLVM IR to a file

Examples

Its core syntax as of now:

  • Mutable Variable declaration:
@sum : int
  • Function declaration:
fn @add(@a: int, @b: int) -> int {
    ret @a + @b
}
  • Mutable Variable assignment to function expression:
@sum : int = @add(1, 2)
  • Basic Logical Paths:
@a : int

if @sum {

    @a = 10

} else {

    @a = 100
};
  • As of now it is also possible to print an expression to the standard output via either the printf function or puts function which are wrappers around their original C counterparts:
@printf(@sum)
# or
@puts("Hello, World!")
  • For loops :
fn @my_fn() -> void {

    for @i in @i < 100 : @i + 1 {
       @out(@i)
    }

}
  • A more complex function:
fn @power(@base : int, @exponent : int) -> int {
  @result : int = 1
  for @i in @i <= @exponent : @i + 1 {
    @result = @result * @base
  }
  ret @result
}

Dependencies

LLVM

Libraries & Techniques used

Interfuse is written purely in C++17. It uses the following libraries:

  • CLI11: Used to parse command line arguments.
  • GNU Bison: Employed uniquely for the parsing process.
  • LLVM: LLVM Represents the Core and most fundamental part of the compiler. It is used to generate the intermediate representation of the code(machine code.

Motivation

Interfuse was created with the goal of challenging myself to create a challenging programming project of larger scale. This project has been the effort of months of research and development, and it has been a great self learning experience.

License

Interfuse is licensed under the GNU General Public License. See the LICENSE file for more information.

About

C based programming language using the LLVM compiler infrastructure. made for fun.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages