GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - aNNiMON/Own-Programming-Language-Tutorial: Source code for course "How to create your own programming language"

BranchesTags
Open more actions menu

Latest commit

 

History

495 Commits
495 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
dist
dist
 
 
docs
docs
 
 
editors
editors
 
 
examples
examples
 
 
gradle/wrapper
gradle/wrapper
 
 
modules
modules
 
 
ownlang-core
ownlang-core
 
 
ownlang-desktop
ownlang-desktop
 
 
ownlang-parser
ownlang-parser
 
 
ownlang-utils
ownlang-utils
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
Dockerfile
Dockerfile
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
build.gradle
build.gradle
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
program.own
program.own
 
 
proguard.properties
proguard.properties
 
 
settings.gradle
settings.gradle
 
 

Repository files navigation

OwnLang

build Ask DeepWiki

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

About

Source code for course "How to create your own programming language"

www.youtube.com/playlist?list=PL81SFGIHr5IJFsoWX0qTeQ9_-MFBE552C

Topics

interpreted-programming-languageinterpreterjavalexerparserprogramming-languagetutorial

Resources

Readme
MIT license
Activity

Stars

136 stars

Watchers

16 watching

Forks

23 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.