diff --git a/README.md b/README.md index 43faaa9..2c542d9 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,11 @@ +[![English](https://img.shields.io/badge/Lang-en-green)][readme-en] +[![Korean](https://img.shields.io/badge/Lang-ko-blue)][readme-ko] + +[readme-en]: ./ +[readme-ko]: ./docs/README_KR.md + + + # ๐Ÿ—ก๏ธ KAL KAL logo @@ -16,6 +24,8 @@ Try _KAL_ at [KAL Playground][playground]. ## ๐Ÿ—ก๏ธ Examples +### Statements and expressions + Variable assignment: ``` ์‚ฌ๊ณผ = 42 @@ -35,6 +45,50 @@ Conditional statement: } ``` +Defining and calling function: +``` +๋”ํ•˜๊ธฐ = ํ•จ์ˆ˜(์ˆซ์ž1, ์ˆซ์ž2) { + ๊ฒฐ๊ณผ ์ˆซ์ž1 + ์ˆซ์ž2 +} + +๋”ํ•˜๊ธฐ(42, 10) +``` +which yields `52`. + +Closure: +``` +๋”ํ•˜๊ธฐ = ํ•จ์ˆ˜(์ˆซ์ž1) { + ๊ฒฐ๊ณผ ํ•จ์ˆ˜(์ˆซ์ž2) { + ๊ฒฐ๊ณผ ์ˆซ์ž1 + ์ˆซ์ž2 + } +} + +ํ•˜๋‚˜๋”ํ•˜๊ธฐ = ๋”ํ•˜๊ธฐ(1) + +ํ•˜๋‚˜๋”ํ•˜๊ธฐ(42) +``` +which yields `43`. + + + +### Types + +_Number type_: any floating-point numbers +``` +์‚ฌ๊ณผ = 42 +ํฌ๋„ = -9.5 +``` + +_String type_: characters surrounded with single quotes +``` +์‚ฌ๊ณผ = '๋ง›์žˆ์Œ' +``` + +_Boolean type_: `์ฐธ`, `๊ฑฐ์ง“` +``` +์‚ฌ๊ณผ = ์ฐธ +ํฌ๋„ = ๊ฑฐ์ง“ +``` ## ๐Ÿ—ก๏ธ Manual building and installation diff --git a/docs/README_KR.md b/docs/README_KR.md new file mode 100644 index 0000000..6c9f8aa --- /dev/null +++ b/docs/README_KR.md @@ -0,0 +1,128 @@ +[![English](https://img.shields.io/badge/Lang-en-green)][readme-en] +[![Korean](https://img.shields.io/badge/Lang-ko-blue)][readme-ko] + +[readme-en]: ../ +[readme-ko]: ./ + + + +# ๐Ÿ—ก๏ธ KAL + +KAL logo + +_KAL: Korean Algorithmic Language_. + +ํ•œ๊ตญ์–ด๋ฅผ ์ง€์›ํ•˜๋Š” ์ธํ„ฐํ”„๋ฆฌํ„ฐ ์–ธ์–ด. + +_KAL_ ์ธํ„ฐํ”„๋ฆฌํ„ฐ๋ฅผ ๋ธŒ๋ผ์šฐ์ €์— ๋กœ๋“œํ•˜๊ฑฐ๋‚˜ ์ง์ ‘ ๋นŒ๋“œํ•˜๋Š” ๋ฐฉ๋ฒ•์€ ์•„๋ž˜๋ฅผ ์ฐธ๊ณ ํ•˜์„ธ์š”. + +_KAL_ ์„ [ํ”Œ๋ ˆ์ด๊ทธ๋ผ์šด๋“œ][playground]์—์„œ ์ฒดํ—˜ํ•ด๋ณด์„ธ์š”. + +[playground]: https://kal-playground.rooi.dev/ + + + +## ๐Ÿ—ก๏ธ ์˜ˆ์‹œ + +### ๋ฌธ๋ฒ•๋“ค + +๋ณ€์ˆ˜ ๋Œ€์ž…ํ•˜๊ธฐ: +``` +์‚ฌ๊ณผ = 42 +``` + +๊ฐ’ ๋น„๊ตํ•˜๊ธฐ: +``` +์‚ฌ๊ณผ < 99 +``` + +์กฐ๊ฑด๋ฌธ ์“ฐ๊ธฐ: +``` +๋งŒ์•ฝ ์‚ฌ๊ณผ < 99 { + ์‚ฌ๊ณผ = 99 +} ์•„๋‹ˆ๋ฉด { + ์‚ฌ๊ณผ = 100 +} +``` + +ํ•จ์ˆ˜ ์‚ฌ์šฉํ•˜๊ธฐ: +``` +๋”ํ•˜๊ธฐ = ํ•จ์ˆ˜(์ˆซ์ž1, ์ˆซ์ž2) { + ๊ฒฐ๊ณผ ์ˆซ์ž1 + ์ˆซ์ž2 +} + +๋”ํ•˜๊ธฐ(42, 10) +``` +๊ฒฐ๊ณผ๋Š” `52`์ž…๋‹ˆ๋‹ค. + +ํด๋กœ์ €: +``` +๋”ํ•˜๊ธฐ = ํ•จ์ˆ˜(์ˆซ์ž1) { + ๊ฒฐ๊ณผ ํ•จ์ˆ˜(์ˆซ์ž2) { + ๊ฒฐ๊ณผ ์ˆซ์ž1 + ์ˆซ์ž2 + } +} + +ํ•˜๋‚˜๋”ํ•˜๊ธฐ = ๋”ํ•˜๊ธฐ(1) + +ํ•˜๋‚˜๋”ํ•˜๊ธฐ(42) +``` +๊ฒฐ๊ณผ๋Š” `42`์ž…๋‹ˆ๋‹ค. + + + +### ํƒ€์ž…๋“ค + +_์ˆซ์ž ํƒ€์ž…_: ์•„๋ฌด ๋ถ€๋™์†Œ์ˆ˜์  ์ˆซ์ž +``` +์‚ฌ๊ณผ = 42 +ํฌ๋„ = -9.5 +``` + +_๋ฌธ์ž์—ด ํƒ€์ž…_: ์ž‘์€๋”ฐ์˜ดํ‘œ๋กœ ๋‘˜๋Ÿฌ์‹ผ ๋ฌธ์ž๋“ค +``` +์‚ฌ๊ณผ = '๋ง›์žˆ์Œ' +``` + +_๋ถˆ๋ฆฌ์–ธ ํƒ€์ž…_: `์ฐธ`, `๊ฑฐ์ง“` +``` +์‚ฌ๊ณผ = ์ฐธ +ํฌ๋„ = ๊ฑฐ์ง“ +``` + + +## ๐Ÿ—ก๏ธ ๋นŒ๋“œ์™€ ์„ค์น˜ + +### ๋นŒ๋“œํ•˜๊ธฐ + +๋นŒ๋“œ ๊ณผ์ •์€ [Node.js][node]๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•ฉ๋‹ˆ๋‹ค. + +_KAL_ ์ธํ„ฐํ”„๋ฆฌํ„ฐ๋ฅผ ๋‹ค์Œ ์ปค๋งจ๋“œ๋กœ [`pnpm`]์„ ์ด์šฉํ•ด ๋นŒ๋“œํ•ฉ๋‹ˆ๋‹ค. + +``` +pnpm install && pnpm build && pnpm bundle` +``` + + +๊ฒฐ๊ณผ๋Š” `/bundle/index.js` ๋””๋ ‰ํ† ๋ฆฌ์— ์œ„์น˜ํ•ฉ๋‹ˆ๋‹ค. + +[pnpm]: https://pnpm.io/ +[node]: https://nodejs.org/ + + + +### ๋ธŒ๋ผ์šฐ์ €์—์„œ ์‚ฌ์šฉํ•˜๊ธฐ + +๋นŒ๋“œํ•œ ํŒŒ์ผ `index.js`๋ฅผ ์›ํ•˜๋Š” ๋””๋ ‰ํ† ๋ฆฌ์— ๋†“๊ณ , ๋‹ค์Œ๊ณผ ๊ฐ™์ด HTML ์ƒ์—์„œ ๋กœ๋“œํ•ฉ๋‹ˆ๋‹ค. + +```HTML + +``` + +์ดํ›„, _KAL_ ์ฝ”๋“œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด `kal.execute(code-to-execute)`๋กœ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค. + +```HTML + +```