Skip to content

wcho21/kal

Repository files navigation

English Korean

🗡️ KALANG

KALANG logo

KALANG: Korean Programming Language.

  • < 0.03 MB.
  • Tested with >250 cases.
  • JavaScript-implemented, which runs natively on web browsers.
  • Minimal syntax with Korean keywords.

Try KALANG at Playground.

You can load a KALANG interpreter in browsers, or build manually (see below).

🗡️ Installation

Load the interpreter script in HTML as follows:

<script src="https://cdn.jsdelivr.net/gh/wcho21/kal@latest/dist/index.min.js"></script>

After that, you can execute KALANG code with kal.execute(code-to-execute) as follows:

kal.execute("5+5"); // === 10

You can attach an event handler for standard output writing as follows:

const stdouts = [];

kal.execute("쓰기('사과')", stdout => stdouts.push(stdout)); // stdout === ["사과"]

🗡️ Examples

Statements and expressions

Variable assignment:

사과 = 42

Comparison:

사과 < 99

Conditional statement:

만약 사과 < 99 {
    사과 = 99
} 아니면 {
    사과 = 100
}

Defining and calling function:

더하기 = 함수(숫자1, 숫자2) {
    결과 숫자1 + 숫자2
}

더하기(42, 10)

which yields 52.

Closure and currying:

더하기 = 함수(숫자1) {
    결과 함수(숫자2) {
        결과 숫자1 + 숫자2
    }
}

하나더하기 = 더하기(1)

하나더하기(42)

더하기(1)(42)

which yields 43 twice.

Builtin functions

쓰기():

쓰기('사과')
쓰기('포도', '바나나')

which yields

사과
포도 바나나

길이():

길이('사과')

which yields 2.

Types

Number type: any floating-point numbers

사과 = 42
포도 = -9.5

String type: characters surrounded with single quotes

사과 = '맛있음'

Boolean type: , 거짓

사과 = 참
포도 = 거짓

🗡️ Building

Note that building process is based on Node.js.

With pnpm, you can build a KALANG interpreter by running pnpm install && pnpm build.

The output will be in the directory /dist/index.min.js.