canlang
v0.2.6
Published
Rust + napi-rs interpreter for the 깡/통 esolang
Maintainers
Readme
Rust + napi-rs 기반으로 Node에서 바로 구동되는 깡/통(HRON) 인터프리터입니다. 레지스트리에서 받아 쓰면 네이티브 바이너리가 함께 설치되고, Git clone 후 빌드하려면 Rust toolchain이 필요합니다.
Run
- 전역 설치(권장):
npm install -g canlang후can yourfile.cancanplanet - 로컬 실행: repo에서
npm install(Rust toolchain 필요) →npm run build→node bin/can.js examples/example_code_1.cancanplanet - HTTP(S)로도 실행:
can https://example.com/foo.cancanplanet(자동 다운로드 후 실행)
Core Syntax (요약)
- Alphabet: only
깡,통, and the final깡깡행성line. - Program ends when the interpreter reads
깡깡행성. - Tokens are space-separated.
- Values are binary written with 깡(1)/통(0).
- Commands can be reused as variable names; the parser decides meaning from token position.
Literals / Types
깡통통— integer. Example 값:깡통통(10₂=2),깡통깡깡깡통(101110₂=46)깡깡통— character (ASCII via 깡/통 binary). Example:깡통통통통통깡→A(1000001₂)
Variables
- Declare + assign:
깡통깡통 (var) (type) (value) - Reassign existing:
깡통 (var) (type) (value)
I/O
- Read line:
깡깡통깡통 (var) - Print:
깡통깡깡통 (var)
Utility (fun names)
- Random int in range (inclusive):
저리가 (startVar) (endVar) (dst) - Length of string/sequence:
뿡뿡 (srcVar) (dstVar)
Operators — (op) (lhs) (rhs) (dst) → stores result in dst
- Arithmetic:
깡통깡통깡(+),깡통통깡(-),깡통깡통깡통깡(*),깡통통깡통통깡(//),깡통깡통깡통깡통깡(**),깡통통깡깡통깡(%) - Relational (booleans):
깡깡통통깡깡(==),깡깡통통깡통(!=),깡통깡통통깡통(>),깡통통통깡통깡(<),깡통깡통통깡깡(>=),깡깡통통깡통깡(<=)
Control Flow
- If / Elif / Else (aliases in parentheses):
깡통깡통통깡(바보) /깡통깡통통깡통(또바보) /깡통깡통통깡통통(진짜바보) …통통 - For:
깡통통통(완전멍청이)(i) (start) (end) (step)…통통(runs whilei < end, incrementing bystep) - While:
멍청이 (cond_var)…통통(loops while the boolean variable is truthy) - Function: define with
캔 (name) (params...) ... 통통, call with캔캔 (name) (argVars...) [retVar] - Loop control:
믕믕(break),뿡(continue) - Function return: inside a function, use
ㅎㅇㅎㅇ [var]to return (optionally returning the value ofvar). If캔캔is given an extra trailingretVar, the returned value is stored there; otherwise it is discarded.
Comments
- Block start
*/깡깡하다*/, block end*/깡깡한*/. Stripped before parsing; can span lines.
모든 문법을 담은 예제
*/깡깡하다*/ 이 구간은 해석되지 않는다 */깡깡한*/
깡통깡통 깡통 깡통통 통 # counter i
깡통깡통 깡깡 깡통통 통 # start = 0
깡통깡통 통통 깡통통 깡통깡 # end = 5
깡통깡통 깡통깡 깡통통 깡 # step = 1
깡통깡통 깡통깡통 깡통통 통 # sum = 0
깡통깡통 깡통깡통깡 깡통통 깡 # product = 1
깡통깡통 깡통통깡 깡통통 통 # diff = 0
깡통깡통 깡통깡통깡통 깡통통 통 # power result = 0
깡통깡통 깡통통깡통 깡통통 통 # mod result = 0
깡통깡통 깡깡통 깡깡통 깡통통통통통깡 # 'A'
깡통깡통 깡깡통통 깡깡통 깡통통통통깡 # '!'
깡통깡통깡 깡깡통 깡깡통통 깡깡통깡 # "A" + "!"
깡깡통깡통 깡깡통통깡 # read user input
완전멍청이 깡통 깡깡 통통 깡통깡 # for (i = start; i < end; i += step)
깡통깡통깡 깡통깡통 깡통 깡통깡통 # sum += i
깡통깡통깡통깡 깡통깡통깡 깡통 깡통깡통깡통 # product *= i
통통
깡통통깡 깡통깡통 깡깡 깡통통깡 # diff = sum - start
깡통깡통깡통깡 깡통통깡 깡통깡 깡통깡통깡통 # product * step
깡통통깡통통깡 깡통깡통 깡통깡 깡통통깡통 # sum // step
깡통깡통깡통깡통깡 깡통깡 깡통깡 깡통깡통깡통 # step ** step
깡통통깡깡통깡 깡통깡통 깡통깡 깡통통깡통 # sum % step
깡통깡통통깡통 깡통깡통 깡통깡 깡깡통통 # cond = sum > step (True)
멍청이 깡깡통통
깡깡통통깡통깡 깡통깡통 깡통깡 깡깡통통 # cond = sum <= step (False → loop ends)
통통
깡통깡깡통 깡통깡통 # print sum (10)
깡통깡깡통 깡통통깡통 # print mod result
깡통깡깡통 깡깡통깡 # print "A!"
깡통깡깡통 깡깡통통깡 # print user input
깡깡행성기존 예제들
- examples/example_code_1.md: 덧셈 후 출력
- examples/example_code_2.md: Hello World! 문자열 조합
- examples/example_code_3.md: 중첩 for 루프로 별 찍기
- examples/example_code_4.md:
바보/멍청이별칭 사용 if/while
Install
- 일반 사용:
npm install -g canlang→can yourfile.cancanplanet(HTTP(S) URL도 지원) - 로컬 개발:
npm install후npm run build(Rust toolchain + Node 18 필요) - VS Code 진단/확장 개발이 필요하면
extensions/vscode쪽 Python 스크립트를 그대로 사용 가능합니다.
License
MIT License. Forked from HRON, heavily modified by CANCANSTUDIO. See LICENSE.
