MCPcopy Index your code
hub / github.com/aNNiMON/Own-Programming-Language-Tutorial

github.com/aNNiMON/Own-Programming-Language-Tutorial @v2.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.1.0 ↗ · + Follow
2,142 symbols 7,612 edges 300 files 96 documented · 4%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

OwnLang

OwnLang - dynamic functional programming language inspired by Scala and Python. Available for PC, Android and Java ME devices.

Installing

Free Pro Desktop
Free Pro v2.1.0

Also available as AUR package:

yay -S ownlang

Key features

Higher-order functions

Functions are values, so we can store them to variables for operating.

operations = {
  "+" : def(a,b) = a+b,
  "-" : def(a,b) = a-b,
  "*" : def(a,b) = a*b,
  "/" : ::division
}

def division(v1, v2) {
  if (v2 == 0) return "error: division by zero"
  return v1 / v2
}

for name, operation : operations {
  println "2 " + name + " 3 = " + operation(2, 3)
}

Pattern Matching

Pattern matching with value pattern, tuple pattern, list pattern and optional condition.

def factorial(n) = match n {
  case 0: 1
  case n if n < 0: 0
  case _: n * factorial(n - 1)
}

def fizzbuzz(limit = 100) {
  for i = 1, i <= limit, i++ {
    println match [i % 3 == 0, i % 5 == 0] {
      case (true, false): "Fizz"
      case (false, true): "Buzz"
      case (true, true): "FizzBuzz"
      case _: i
    }
  }
}

// run
fizzbuzz()

Functional data operations

Operate data in functional style.

use std, functional

nums = [1,2,3,4,5,6,7,8,9,10]
nums = filter(nums, def(x) = x % 2 == 0)
// Squares of even numbers
squares = map(nums, def(x) = x * x)
foreach(squares, ::echo)
// Sum of squares
sum = reduce(squares, 0, def(x, y) = x + y)
println "Sum: " + sum
// Same using stream
println "Sum: " + stream(range(1, 11))
  .filter(def(x) = x % 2 == 0)
  .map(def(x) = x * x)
  .reduce(0, def(x, y) = x + y)

Operator overloading

Why not?

use std, types, math

def `..`(a, b) = range(a, b)
def `**`(a, b) = int(pow(a, b))
for y : 1 .. 10 {
  println sprintf("2 ^ %d = %d", y, 2 ** y)
}

Network module

Easy async HTTP requests with http module.

use std, http, functional, json

// GET request
http("https://api.github.com/events", def(r) {
  events = jsondecode(r)
  println events[0]
})

// POST request
http("http://jsonplaceholder.typicode.com/users", "POST", {
  "name": "OwnLang",
  "versionCode": 10
}, ::echo)

// PATCH request
http("http://jsonplaceholder.typicode.com/users/2", "PATCH", {"name": "Patched Name"}, ::patch_callback)

def patch_callback(v) {
  println v
}

Language specification

English and Russian

Examples

Build

Build using Gradle ./gradlew shadowJar

or take a look to latest release for binaries.

Run

To run script use command

java -jar OwnLang.jar -f input.own

or

java -jar OwnLang.jar < input.own

License

MIT - see MIT license information

Extension points exported contracts — how you extend this code

Statement (Interface)
@author aNNiMON [22 implementers]
ownlang-parser/src/main/java/com/annimon/ownlang/parser/ast/Statement.java
Module (Interface)
Main interface for modules @author aNNiMON [52 implementers]
ownlang-core/src/main/java/com/annimon/ownlang/modules/Module.java
ReplConsole (Interface)
(no doc) [4 implementers]
ownlang-utils/src/main/java/com/annimon/ownlang/utils/repl/ReplConsole.java
Node (Interface)
@author aNNiMON [40 implementers]
ownlang-parser/src/main/java/com/annimon/ownlang/parser/ast/Node.java
Value (Interface)
@author aNNiMON [13 implementers]
ownlang-core/src/main/java/com/annimon/ownlang/lib/Value.java
ResultVisitor (Interface)
@author aNNiMON @param the result type @param the type if the input [17 implementers]
ownlang-parser/src/main/java/com/annimon/ownlang/parser/ast/ResultVisitor.java
Function (Interface)
@author aNNiMON [100 implementers]
ownlang-core/src/main/java/com/annimon/ownlang/lib/Function.java
Visitor (Interface)
@author aNNiMON [18 implementers]
ownlang-parser/src/main/java/com/annimon/ownlang/parser/ast/Visitor.java

Core symbols most depended-on inside this repo

set
called by 639
ownlang-parser/src/main/java/com/annimon/ownlang/parser/ast/Accessible.java
put
called by 434
ownlang-core/src/main/java/com/annimon/ownlang/stages/StagesData.java
of
called by 380
ownlang-core/src/main/java/com/annimon/ownlang/lib/NumberValue.java
asInt
called by 319
ownlang-core/src/main/java/com/annimon/ownlang/lib/Value.java
asString
called by 311
ownlang-core/src/main/java/com/annimon/ownlang/lib/Value.java
type
called by 214
ownlang-core/src/main/java/com/annimon/ownlang/lib/Value.java
asNumber
called by 193
ownlang-core/src/main/java/com/annimon/ownlang/lib/Value.java
set
called by 192
ownlang-core/src/main/java/com/annimon/ownlang/lib/MapValue.java

Shape

Method 1,675
Class 377
Interface 68
Enum 11
Function 11

Languages

Java99%
TypeScript1%

Modules by API surface

modules/canvasfx/src/main/java/com/annimon/ownlang/modules/canvasfx/canvasfx.java113 symbols
modules/main/src/main/java/com/annimon/ownlang/modules/files/files.java92 symbols
ownlang-parser/src/main/java/com/annimon/ownlang/parser/Parser.java69 symbols
ownlang-core/src/main/java/com/annimon/ownlang/lib/Converters.java68 symbols
modules/jdbc/src/main/java/com/annimon/ownlang/modules/jdbc/JdbcConverters.java52 symbols
modules/main/src/main/java/com/annimon/ownlang/modules/java/java.java46 symbols
modules/main/src/main/java/com/annimon/ownlang/modules/canvas/canvas.java32 symbols
modules/main/src/main/java/com/annimon/ownlang/modules/date/date.java31 symbols
ownlang-parser/src/main/java/com/annimon/ownlang/parser/ast/MatchExpression.java29 symbols
ownlang-parser/src/main/java/com/annimon/ownlang/parser/Lexer.java25 symbols
ownlang-core/src/main/java/com/annimon/ownlang/lib/ScopeHandler.java23 symbols
ownlang-core/src/main/java/com/annimon/ownlang/lib/MapValue.java23 symbols

For agents

$ claude mcp add Own-Programming-Language-Tutorial \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact