나만의 프로그래밍 언어
#
소개
#
// C언어
#include <stdio.h>
int main(void) {
printf("Hello, World!\n");
}
std: lib.std;
pub main():
return std.out("Hello, World!");
;
구조체
#
pub Person{}:
str name: "이름";
str phone: "010-1234-5678"
str email: "example@example.com"
(name, phone, email): (.name, .phone, .email);
;
변수
#
i4 int: 10; // 4바이트 정수에 숫자 10 할당
f8 float: 0.1234 // 8바이트 부동소수
s string: "test" // 문자열
a[6] array: [0, 1, 2, 3, 4, 5] // 배열
함수
#
exam():
return 10;
;
exam2(i4 a, i4 b):
i4 c: a + b;
return c;
;
형변환
#
to: lib.std.to;
to.int('10'); // '10' -> 10
to.str(10); // 10 -> '10'
반환 타입
#
func test(int a, int b) int:
return a + b;
;
함수 선언 형식
#
hello() void:
print("Hello, World!");
;
기본 라이브러리
#
Map
#
std: lib.std;
map: std.map;
func main:
map m;
m: "key1": "value1", "key2": "value2";
;
map m;
m.key: "name"; // {"name":""}
m.value: "smith"; // {"name":"smith"}
Set
#
std: lib.std;
set: std.set;
func main:
set s;
s: "1", "2", "3";
;
List
#
std: lib.std;
list: std.list;
func main:
list l;
l: "a", "b", "c";
;