MCPcopy Index your code
hub / github.com/Danue1/danube

github.com/Danue1/danube @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
355 symbols 1,155 edges 27 files 3 documented · 1%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Danube Programming Language

Danube: For A New Era Language Standard.

It supports the basic features that are refined with reference to the trial and failure of existing languages.

Hello, World!

fn main() {
  println("Hello, World!");
}

Syntax

Variables

let x = 10;
let mut name = "Danube";

Conditions

if x > 5 {
  println("Hello, Danube!");
} else {
  println("Hello, World!");
}

Loops

for i in 1..5 {
  println("For! {i}");
}

while condition {
  println("While!");
}

loop {
  println("Loops!");
}

Function Declarations and Calling

fn add(a: u8, b: u8) -> u8 {
  a + b
}

add(1, 2); // 3

Struct Declarations and Instantiation

struct User {
  name: String,
}

impl User {
  fn name(self) -> str {
    self.name
  }
}

let user = User {
  name: "Danuel",
}

println(user.name());

Module System

// math.dnb
pub fn add(a: u8, b: u8) -> u8 {
  a + b
}

// main.dnb
use math::add;

add(1, 2); // 3
math::add(1, 2); // 3

Context Parameters

fn say(|f: mut Debug|, user: User) {
  f.debug("Hello, {user.name}!");
}

impl User {
  pub fn say(self, |f: mut Debug|) {
    f.debug("Hello, {self.name}");
  }
}

impl<T1> T1 {
  fn with<U>(self, f: (|T1|) -> U) -> U {
    f(|self|)
  }
}

// Formatter has a Debug trait.
Formatter::new().with(fn (|formatter|) {
  let user = User::new("Danuel");

  // 1 will be same as 2
  say(user); // 1
  say(|formatter|, user); // 2
})

Traits

trait Identity {
  fn identity(self) -> Id;
}

struct User {
  id: Id,
}

impl Identity for User {
  fn identity(self) -> Id {
    self.id
  }
}

Effect System

trait ^DivByZero {
  fn on_div_by_zero() -> u8;
}

fn div(a: u8, b: u8): ^DivByZero -> u8 {
  if b == 0 {
    ^DivByZero::on_div_by_zero()
  } else {
    a / b
  }
}

Special Thanks

This language was named Danube by @thehighestend!

License

This project is licensed under the MIT license. Please see the LICENSE file for more details.

Core symbols most depended-on inside this repo

report
called by 140
compiler/danubec_diagnostic/src/lib.rs
complete
called by 119
compiler/danubec_parse/src/grammar.rs
start
called by 69
compiler/danubec_parse/src/grammar.rs
eat
called by 63
compiler/danubec_parse/src/grammar.rs
at
called by 38
compiler/danubec_parse/src/grammar.rs
is_empty
called by 36
compiler/danubec_diagnostic/src/lib.rs
report
called by 29
compiler/danubec_parse/src/grammar.rs
bump
called by 27
compiler/danubec_parse/src/grammar.rs

Shape

Function 165
Method 124
Class 40
Enum 26

Languages

Rust100%

Modules by API surface

compiler/danubec_parse/src/grammar.rs125 symbols
compiler/danubec_semantic/src/collect.rs51 symbols
compiler/danubec_hir/src/lib.rs40 symbols
compiler/danubec_semantic/src/env.rs18 symbols
compiler/danubec_parse/src/tests/mod.rs18 symbols
compiler/danubec_lex/src/tests.rs16 symbols
compiler/danubec_parse/src/event.rs12 symbols
compiler/danubec_lex/src/lib.rs10 symbols
compiler/danubec_ast/src/lib.rs10 symbols
compiler/danubec_semantic/src/fs.rs9 symbols
compiler/danubec_syntax/src/syntax_kind.rs8 symbols
compiler/danubec_parse/src/token_stream.rs7 symbols

For agents

$ claude mcp add danube \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact