All Projects → MaxXSoft → YuLang

MaxXSoft / YuLang

Licence: GPL-3.0 license
The Yu (羽) programming language.

Programming Languages

C++
36643 projects - #6 most used programming language

Projects that are alternatives of or similar to YuLang

pacxx-llvm
Programming Accelerators with C++ (PACXX)
Stars: ✭ 57 (+23.91%)
Mutual labels:  llvm
movForth
LLVM frontend for the Forth Language
Stars: ✭ 71 (+54.35%)
Mutual labels:  llvm
CMLFS
Clang-Built Musl Linux From Scratch
Stars: ✭ 51 (+10.87%)
Mutual labels:  llvm
clad
clad -- automatic differentiation for C/C++
Stars: ✭ 161 (+250%)
Mutual labels:  llvm
compiler lab
Some toy labs for compiler course
Stars: ✭ 49 (+6.52%)
Mutual labels:  llvm
LLVM-Obfuscator
LLVM Obfuscator
Stars: ✭ 44 (-4.35%)
Mutual labels:  llvm
evm llvm
Official repo of the EVM LLVM project
Stars: ✭ 72 (+56.52%)
Mutual labels:  llvm
llvm-compile-time-data
LLVM compile-time performance data over time.
Stars: ✭ 16 (-65.22%)
Mutual labels:  llvm
los
Los是一个c/c++语言编译型的虚拟机。它使用llvm/clang作为其前端,losld做后端对源代码进行编译,生成los指令文件。Los is a c/c++-compiled virtual machine. It uses llvm/clang as its front end, losld does the backend to compile the source code, and generates the los directive file.
Stars: ✭ 46 (+0%)
Mutual labels:  llvm
mollusc
Pure-Rust libraries for parsing, interpreting, and analyzing LLVM
Stars: ✭ 49 (+6.52%)
Mutual labels:  llvm
lhc
The LLVM LHC Haskell Optimization System
Stars: ✭ 194 (+321.74%)
Mutual labels:  llvm
alon
Remix for Solana.
Stars: ✭ 87 (+89.13%)
Mutual labels:  llvm
Star-lang-specification
Work in progress specs for the Star programming language
Stars: ✭ 26 (-43.48%)
Mutual labels:  llvm
kotlin-native
Kotlin/Native infrastructure
Stars: ✭ 7,066 (+15260.87%)
Mutual labels:  llvm
OS-CFI
Origin-sensitive Control Flow Integrity (OS-CFI) - USENIX Security 2019
Stars: ✭ 27 (-41.3%)
Mutual labels:  llvm
ebpfault
A BPF-based syscall fault injector
Stars: ✭ 65 (+41.3%)
Mutual labels:  llvm
OCCAM
OCCAM: Object Culling and Concretization for Assurance Maximization
Stars: ✭ 20 (-56.52%)
Mutual labels:  llvm
mlir-hs
Haskell bindings for MLIR
Stars: ✭ 53 (+15.22%)
Mutual labels:  llvm
systemc-compiler
This tool translates synthesizable SystemC code to synthesizable SystemVerilog.
Stars: ✭ 128 (+178.26%)
Mutual labels:  llvm
Chromium Clang
Chromium browser compiled with the Clang/LLVM compiler.
Stars: ✭ 77 (+67.39%)
Mutual labels:  llvm

Yu

YuLang

Build and Test 羽语言简明教程

Yu (羽) is a simple system programming language.

Documentations

Visit YuLang-doc for more details.

Features

  • Block expression
  • Modules and import statement
  • Type deduction and reference type
  • Inline function/variable/constant
  • Function/operator overloading
  • Operator-formed identifier
  • Dot function and infix function
  • Iterator

Examples: Hello World

C style:

import sys.unistd
import sys.string

extern def main(argc: i32, argv: u8**): i32 {
  let hello = "Hello world!\n", len = strlen(hello)
  write(FD_STDOUT, hello, len)
  0
}

OOP-like style (but not real OOP):

import sys.unistd
import sys.string

struct Output {}

def println(this: Output&, str: u8*) {
  write(FD_STDOUT, str, strlen(str))
  write(FD_STDOUT, "\n", 1 as u32)
}

let out = [Output] {}

extern def main(argc: i32, argv: u8**): i32 {
  out.println("Hello world!")
  0
}

C++ cout style with custom operator <<<:

import io

extern def main(argc: i32, argv: u8**): i32 {
  out <<< "Hello world! " <<< 123 <<< '\n'
  0
}

Natural language style (see natural.yu):

extern def main(argc: i32, argv: u8**): i32 {
  // be polite
  please put "Hello world! " and 123 to stdout
  thanks
}

Building from Source

Before building YuLang compiler, please make sure you have installed the following dependencies:

  • cmake 3.13 or later
  • llvm 10.0 or later
  • C++ compiler supporting C++17

You may want to check the toolchain configuration in toolchain.mk. Then you can build this repository by executing the following command lines:

$ git clone --recursive https://github.com/MaxXSoft/YuLang.git
$ cd YuLang
$ mkdir build
$ cd build
$ cmake .. && make -j8

EBNF of Yu

program   ::= {line};
line      ::= stmt {";" stmt} [";"];
stmt      ::= var_def   | let_def | fun_def | declare
            | ty_alias  | struct  | enum    | import;

var_def   ::= property "var" var_elem {"," var_elem};
let_def   ::= property "let" let_elem {"," let_elem};
fun_def   ::= property "def" [id | bin_op | unary_op]
              "(" [arg_list] ")" [":" type] block;
declare   ::= property "declare" ["var"] id ":" type;
ty_alias  ::= property "type" id "=" type;
struct    ::= property "struct" id "{" arg_list [","] "}";
enum      ::= property "enum" id [":" type] "{" enum_list "}";
import    ::= property "import" id {"." id};

property  ::= ["public" | "extern" | "inline"]
var_elem  ::= id [":" type] ["=" expr];
let_elem  ::= id [":" type] "=" expr;
arg_list  ::= id ":" type ["," arg_list];
enum_list ::= id ["=" expr] ["," enum_list] [","];

block     ::= "{" {blk_line} "}";
blk_line  ::= blk_stmt {";" blk_stmt} [";"];
blk_stmt  ::= var_def | let_def | declare | ty_alias  | struct
            | enum    | if_else | when    | while     | for_in
            | asm     | control | expr;

if_else   ::= "if" expr block ["else" (if_else | block)];
when      ::= "when" expr "{" when_elem {when_elem} ["else" block] "}";
while     ::= "while" expr block;
for_in    ::= "for" id "in" expr block;
asm       ::= "asm" "{" string {string} "}";
control   ::= "break" | "continue"  | ("return" [expr]);

when_elem ::= expr {"," expr} block;

expr      ::= binary {id binary};
binary    ::= cast {bin_op cast};
cast      ::= unary {"as" type};
unary     ::= [unary_op] factor | "sizeof" type;
factor    ::= value | block     | if_else   | when
            | index | fun_call  | access    | "(" expr ")";

bin_op    ::= "+"   | "-"   | "*"   | "/"   | "%"   | "&"
            | "|"   | "^"   | "&&"  | "||"  | "<<"  | ">>"
            | "=="  | "!="  | "<"   | "<="  | ">"   | ">="
            | "="   | "+="  | "-="  | "*="  | "/="  | "%="
            | "&="  | "|="  | "^="  | "<<=" | ">>=" | ".";
unary_op  ::= "+"   | "-"   | "!"   | "~"   | "*"   | "&";
index     ::= factor "[" expr "]";
fun_call  ::= factor "(" [expr {"," expr}] ")";
access    ::= factor "." id ["(" [expr {"," expr}] ")"];

value     ::= INT_VAL | FLOAT_VAL | CHAR_VAL | id
            | string  | bool      | null_ptr | val_init;
id        ::= ID_VAL;
string    ::= STR_VAL;
bool      ::= "true"  | "false";
null_ptr  ::= "null";
val_init  ::= "[" type "]" "{" [expr {"," expr} [","]] "}";

type      ::= (prim_type | id | pointer | array | ref | func) ["volatile"];
prim_type ::= "i8"  | "i16" | "i32"   | "i64" | "isize" | "u8"  | "u16"
            | "u32" | "u64" | "usize" | "f32" | "f64" | "bool";
pointer   ::= type ["var"] "*";
array     ::= type "[" expr "]";
ref       ::= type ["var"] "&";
func      ::= "(" [type {"," type}] ")" [":" type];

Changelog

See CHANGELOG.md

License

Copyright (C) 2010-2020 MaxXing. License GPLv3.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].