diff --git a/Proto.kr b/Proto.kr index 9409941..45362a2 100644 --- a/Proto.kr +++ b/Proto.kr @@ -36,7 +36,7 @@ 결과는 0이에요. 수는 정수예요. 수를 1부터 끝까지 세면서 { - 수를 제곱해서 결과를 더해서 결과에 넣어요. + 결과는 수를 제곱해서 결과를 더한 값이에요. } 결과를 반환해요. } @@ -44,16 +44,16 @@ 정수를 반환하는 main() { 결과는 정수예요. - 3과 4를 더해서 결과에 넣어요. - 결과에 (결과 * 5)를 넣어요. // plain arithmetic, no call + 결과는 3과 4를 더한 값이에요. + 결과는 (결과 * 5)예요. // plain arithmetic, no call "%ld\n"과 결과를 printf해요. // (3 + 4) * 5 = 35 "%ld\n"과 ((결과 << 1) ^ 3)을 printf해요. // C operators: (35 << 1) ^ 3 = 69 - 7과 3을 비교해서 결과에 넣어요. + 결과는 7과 3을 비교한 값이에요. "%ld\n"과 결과를 printf해요. // 1 고정된 끝은 10이에요. - 끝을 합해서 결과에 넣어요. + 결과는 끝을 합한 값이에요. "%ld\n"과 결과를 printf해요. // 1² + … + 9² = 285 // even numbers from 1 to 끝 (excluded) @@ -61,7 +61,7 @@ 수는 정수예요. 수를 1부터 끝까지 세면서 { 만약 수 % 2 == 0이면 { - 개수와 1을 더해서 개수에 넣어요. + 개수는 개수와 1을 더한 값이에요. } } "%ld\n"과 개수를 printf해요. // 2, 4, 6, 8: 4 @@ -69,7 +69,7 @@ // first power of 2 above 100 숫자는 1이에요. 숫자 < 100인 동안 { - 숫자에 (숫자 * 2)를 넣어요. + 숫자는 (숫자 * 2)예요. } "%ld\n"과 숫자를 printf해요. // 128 @@ -82,7 +82,7 @@ // floating-point numbers 평균은 소수예요. - 1.5와 -2.25를 평균해서 평균에 넣어요. + 평균은 1.5와 -2.25를 평균한 값이에요. "%f\n"과 평균을 printf해요. // (1.5 - 2.25) / 2 = -0.375 0을 반환해요. diff --git a/README.ko.md b/README.ko.md index c9607d9..e5bcad8 100644 --- a/README.ko.md +++ b/README.ko.md @@ -13,9 +13,9 @@ ELF 목적 파일을 만듭니다. 중앙대학교(CAU) 컴파일러 수업에 두 정수 가와 나를 받아 나누고 정수를 반환 { 나머지는 정수예요. (나 == 0)이 아닌 동안 { - 나머지에 (가 % 나)를 넣어요. - 가에 나를 넣어요. - 나에 나머지를 넣어요. + 나머지는 (가 % 나)예요. + 가는 나예요. + 나는 나머지예요. } 가를 반환해요. } @@ -27,7 +27,7 @@ ELF 목적 파일을 만듭니다. 중앙대학교(CAU) 컴파일러 수업에 - **함수는 동사입니다.** 호출을 중첩하지 않고 문장처럼 이어서 씁니다: `3과 4를 더해서 제곱해서 반환해요` -- **인자에는 조사가 붙습니다.** 예: `나머지에 (가 % 나)를 넣어요` +- **인자에는 조사가 붙습니다.** 예: `48과 18을 나눈 값이에요` - **문장은 해요체로 끝납니다.** 예: `42를 반환해요.` - **libc 함수는 라틴 문자 이름에 `하다`를 붙여 호출합니다.** 예: `"%ld\n"과 가를 printf해요.` diff --git a/README.md b/README.md index da32306..e6e2d68 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,9 @@ Rust that produces x86-64 Linux ELF object files. Originally made for the Compil 두 정수 가와 나를 받아 나누고 정수를 반환 { 나머지는 정수예요. (나 == 0)이 아닌 동안 { - 나머지에 (가 % 나)를 넣어요. - 가에 나를 넣어요. - 나에 나머지를 넣어요. + 나머지는 (가 % 나)예요. + 가는 나예요. + 나는 나머지예요. } 가를 반환해요. } diff --git a/docs/LANGUAGE_DESIGN.md b/docs/LANGUAGE_DESIGN.md index af99bbe..558e3c4 100644 --- a/docs/LANGUAGE_DESIGN.md +++ b/docs/LANGUAGE_DESIGN.md @@ -7,7 +7,7 @@ to `printf`). Decisions already made: - Identifiers do not accept digits (hangul, latin and `_`). -- Speech level: 해요체 in function bodies (`예요`, `반환해요`, `넣어요`…). The sentence declaration +- Speech level: 해요체 in function bodies (`예요`, `반환해요`, `더해요`…). The sentence declaration reads like a line of a specification and ends with the noun `반환` (see [Sentence declaration](#sentence-declaration)). - End of statement: the ending in `요` ends the statement, no `;`. A `.` is accepted right after @@ -26,8 +26,8 @@ Decisions already made: attached. - Plain arithmetic is always possible: wherever a value is expected (assignment, argument, return, declaration, condition), an expression with operators is accepted, without going through a - function. Between parentheses if a particle follows: `개수에 (개수 + 1)을 넣어요` (`a = a + 1`), - `결과에 (가 * 나)를 넣어요` (`a = b * c`). + function. Between parentheses if a particle follows: `개수는 (개수 + 1)이에요` (`a = a + 1`), + `결과는 (가 * 나)예요` (`a = b * c`). - Negative number: `-5` is a simple term (`-5를 반환해요`). The `-` stays a separate token in the lexer (otherwise `가-5` would give `가` then `-5`); the parser attaches `-` to a number. `-가` stays an expression: `(-가)를 반환해요`. @@ -302,7 +302,7 @@ choice against the 받침 (`나을` → "받침이 없으니 '를'을 쓰세요" | | Concept | Word | Notes | | --- | --- | --- | --- | | ★ | function | `TYPE을/를 반환하는 VERB다(TYPE name, …) { … }` | "VERB, which gives a TYPE"; without return: `VERB다(…) { … }` | -| | variable | `NAME은/는 VALUE이에요/예요` or `NAME은/는 TYPE이에요/예요` | with a value: deduced type (`0` → `정수`, `0.5` → `소수`); with a type: default value (zero of the type); `이에요` after a consonant, `예요` after a vowel; mutable by default | +| | variable | `NAME은/는 VALUE이에요/예요` or `NAME은/는 TYPE이에요/예요` | with a value: deduced type (`0` → `정수`, `0.5` → `소수`); with a type: default value (zero of the type); `이에요` after a consonant, `예요` after a vowel; mutable by default; with a value on a name already declared: a new value (see Modifiers) | | | constant | `고정된 NAME은/는 VALUE이에요/예요` | see Modifiers | | | function of another file | `TYPE을/를 반환하는 VERB다(TYPE name, …)` | no body, no `외부`: defined in another file of the program, see Several files | | ★ | external function (libc) | `외부 TYPE을/를 반환하는 name(TYPE name, …)` | latin name only (`외부` is for the libc), no body; `…` for variadics: `외부 정수를 반환하는 printf(문자 주소 형식, …)` | @@ -339,8 +339,7 @@ A file calls a function of another file through a declaration without a body and 정수를 반환하는 더하다(정수 가, 정수 나) // defined in lib.kr 정수를 반환하는 main() { - 결과는 정수예요. - 40과 2를 더해서 결과에 넣어요. + 결과는 40과 2를 더한 값이에요. 결과를 반환해요. // 42 } ``` @@ -422,7 +421,8 @@ next word. A particle (`를`, `과`…) announces a call chain, `인 동안` a l Every arithmetic operator of C that has no Korean word keeps its symbol, with the precedence and associativity of C. Only `&&`, `||` and `!` are replaced by words (see the next section). -Assignment (`=`, `+=`…) and `++` / `--` do not exist: use `넣다`. +Assignment (`=`, `+=`…) and `++` / `--` do not exist: write the new value like a declaration, +`개수는 (개수 + 1)이에요`. | Precedence (high → low) | Operators | Associativity | | --- | --- | --- | @@ -471,20 +471,22 @@ negation right after a condition. | | immutable | `고정된` | "fixed" (고정되다 → `고정된`); placed before the name, like `짧은 정수`; longer variant: `바뀌지 않는` ("that does not change") | ``` -개수는 0이에요 // mutable -고정된 합은 3과 4를 더한 값이에요 // immutable -개수에 1을 넣어요 // assignment: "put 1 into 개수" -개수와 1을 더해서 개수에 넣어요 // 개수 = 개수 + 1 -개수에 개수와 1을 더해서 넣어요 // the same, with the destination first -합에 5를 넣어요 // error: 합 is 고정된 +개수는 0이에요 // mutable +고정된 합은 3과 4를 더한 값이에요 // immutable +개수는 1이에요 // assignment: 개수 is already declared +개수는 개수와 1을 더한 값이에요 // 개수 = 개수 + 1 +개수는 (개수 + 1)이에요 // the same, without a function +합은 5예요 // error: 합 is 고정된 +개수는 정수예요 // error: 개수 is already declared ``` -Assignment uses the built-in verb 넣다 ("put into") with `에` ("into"): it naturally goes at the -end of a chain. `넣어요` ends the sentence, `넣어서` continues the chain with the assigned value. +An assignment is written like the declaration: `NAME은/는 VALUE이에요/예요` on a name already +declared in the block or a block around it gives that variable a new value, of its type. There +is no shadowing, so the sentence cannot declare a second variable of the same name. Only a +value assigns: a type (`개수는 정수예요`) or `고정된` on a name already declared is an error. -The destination `NAME에` can also open the sentence, before the chain: a leading `NAME에` is an -argument of the **last** verb of the chain. There is no ambiguity, since only that verb can take -it and no other step expects an `에`. +The value can be the result of a chain: its last verb takes the adnominal form before `값` +(`개수는 3과 4를 더해서 제곱한 값이에요`, `결과는 "%ld\n"과 1을 printf한 값이에요`). ## Predefined names @@ -493,7 +495,6 @@ it and no other step expects an `에`. | ★ | entry point (`main`) | `main` | the only exception to the all-Korean language: the libc calls it by this name | | ★ | print | — | no built-in function: `printf` of the libc, declared with `외부` | | ★ | return a value | `반환하다` | `반환해요`: end of a chain that returns the result (see Control flow); `반환하는` and `반환` in declarations | -| | assign | `넣다` | `NAME에 VALUE을/를 넣어요`; at the end of a chain: `… 개수에 넣어요` | | | convert | `바꾸다` | `TERM을/를 TYPE(으)로 바꿔서` (see Word operators) | | | count (loop) | `세다` | `[TYPE] NAME을/를 A부터 B까지 세면서` (see Control flow) | @@ -503,7 +504,7 @@ These verbs are reserved: a user function cannot take their name. 외부 정수를 반환하는 printf(문자 주소 형식, …) "%ld\n"과 42를 printf해요 // 42 -3과 4를 더해서 결과에 넣어요 +결과는 3과 4를 더한 값이에요 "%ld\n"과 결과를 printf해요 // 7 ``` diff --git a/docs/index.md b/docs/index.md index 40414b8..c4d8ce4 100644 --- a/docs/index.md +++ b/docs/index.md @@ -13,9 +13,9 @@ particles. It started in the Compiler class of Chung-Ang University and now cont 두 정수 가와 나를 받아 나누고 정수를 반환 { 나머지는 정수예요. (나 == 0)이 아닌 동안 { - 나머지에 (가 % 나)를 넣어요. - 가에 나를 넣어요. - 나에 나머지를 넣어요. + 나머지는 (가 % 나)예요. + 가는 나예요. + 나는 나머지예요. } 가를 반환해요. } @@ -56,7 +56,7 @@ Then compile and run it: - **Functions are verbs.** Calls chain like a sentence, without nesting: `3과 4를 더해서 제곱해서 반환해요`. -- **Arguments carry their particles**, as in `나머지에 (가 % 나)를 넣어요`. +- **Arguments carry their particles**, as in `48과 18을 나눈 값이에요`. - **Statements end in the polite 해요 style**, as in `42를 반환해요.`. - **libc functions are called with `하다`**, like foreign words in Korean: `"%ld\n"과 가를 printf해요.`. diff --git a/docs/ko.md b/docs/ko.md index 21525ba..a3b3435 100644 --- a/docs/ko.md +++ b/docs/ko.md @@ -13,9 +13,9 @@ ELF 목적 파일을 만듭니다. 함수는 동사이고, 인자에는 조사 두 정수 가와 나를 받아 나누고 정수를 반환 { 나머지는 정수예요. (나 == 0)이 아닌 동안 { - 나머지에 (가 % 나)를 넣어요. - 가에 나를 넣어요. - 나에 나머지를 넣어요. + 나머지는 (가 % 나)예요. + 가는 나예요. + 나는 나머지예요. } 가를 반환해요. } @@ -56,7 +56,7 @@ cd krc-v0.1.0-x86_64-linux - **함수는 동사입니다.** 호출을 중첩하지 않고 문장처럼 이어서 씁니다: `3과 4를 더해서 제곱해서 반환해요` -- **인자에는 조사가 붙습니다.** 예: `나머지에 (가 % 나)를 넣어요` +- **인자에는 조사가 붙습니다.** 예: `48과 18을 나눈 값이에요` - **문장은 해요체로 끝납니다.** 예: `42를 반환해요.` - **libc 함수는 라틴 문자 이름에 `하다`를 붙여 호출합니다.** 예: `"%ld\n"과 가를 printf해요.` diff --git a/sample/03_chains.kr b/sample/03_chains.kr index 5e5ee3a..9f36cd5 100644 --- a/sample/03_chains.kr +++ b/sample/03_chains.kr @@ -25,19 +25,19 @@ 정수를 반환하는 main() { 결과는 정수예요. - 10과 4를 빼서 결과에 넣어요. + 결과는 10과 4를 뺀 값이에요. "%ld\n"과 결과를 printf해요. // 6 - 3과 4를 더해서 제곱해서 2를 빼서 결과에 넣어요. + 결과는 3과 4를 더해서 제곱해서 2를 뺀 값이에요. "%ld\n"과 결과를 printf해요. // (3 + 4)² - 2 = 47 - 계산해서 결과에 넣어요. + 결과는 계산한 값이에요. "%ld\n"과 결과를 printf해요. // 81 // name intermediate results with -(으)ㄴ 값 합은 3과 4를 더한 값이에요. // 7 차는 10과 4를 뺀 값이에요. // 6 - 합과 차를 더해서 결과에 넣어요. + 결과는 합과 차를 더한 값이에요. "%ld\n"과 결과를 printf해요. // 13 0을 반환해요. diff --git a/sample/04_conditions.kr b/sample/04_conditions.kr index d011d9d..b732c21 100644 --- a/sample/04_conditions.kr +++ b/sample/04_conditions.kr @@ -39,9 +39,9 @@ } "%ld %ld\n"과 가와 나를 printf해요. - 가를 확인해서 가에 넣어요. + 가는 가를 확인한 값이에요. "%ld\n"과 가를 printf해요. // 1 - 나를 부호해서 나에 넣어요. + 나는 나를 부호한 값이에요. "%ld\n"과 나를 printf해요. // -1 0을 반환해요. diff --git a/sample/05_loops.kr b/sample/05_loops.kr index fca6500..9631295 100644 --- a/sample/05_loops.kr +++ b/sample/05_loops.kr @@ -10,14 +10,14 @@ 숫자는 1이에요. 숫자 < 100인 동안 { "%ld\n"과 숫자를 printf해요. - 숫자에 (숫자 * 2)를 넣어요. + 숫자는 (숫자 * 2)예요. } // while not: countdown 3, 2, 1 남은은 3이에요. (남은 == 0)이 아닌 동안 { "%ld\n"과 남은을 printf해요. - 남은에 (남은 - 1)을 넣어요. + 남은은 (남은 - 1)이에요. } // the loop declares 칸: 0 to 4 diff --git a/sample/06_types.kr b/sample/06_types.kr index 885e37e..a06e056 100644 --- a/sample/06_types.kr +++ b/sample/06_types.kr @@ -25,7 +25,7 @@ "%ld\n"과 넓이를 printf해요. // conversion with the built-in verb 바꾸다 - 7을 소수로 바꿔서 비율에 넣어요. + 비율은 7을 소수로 바꾼 값이에요. "%f\n"과 비율을 printf해요. // 7.0 0을 반환해요. diff --git a/sample/07_sentences.kr b/sample/07_sentences.kr index 2ab6c78..f9e6529 100644 --- a/sample/07_sentences.kr +++ b/sample/07_sentences.kr @@ -39,13 +39,13 @@ 정수를 반환하는 main() { 결과는 정수예요. - 7과 3을 비교해서 결과에 넣어요. + 결과는 7과 3을 비교한 값이에요. 결과를 보여줘요. // 1 - 21을 두배해서 결과에 넣어요. + 결과는 21을 두배한 값이에요. 결과를 보여줘요. // 42 - 6과 7을 곱해서 결과에 넣어요. + 결과는 6과 7을 곱한 값이에요. 결과를 보여줘요. // 42 - 10과 4를 빼서 결과에 넣어요. + 결과는 10과 4를 뺀 값이에요. 결과를 보여줘요. // 6 0을 반환해요. } diff --git a/sample/08_fibonacci.kr b/sample/08_fibonacci.kr index 3aadbe3..36c9098 100644 --- a/sample/08_fibonacci.kr +++ b/sample/08_fibonacci.kr @@ -11,9 +11,9 @@ 정수 번을 0부터 20까지 세면서 { "%ld\n"과 앞을 printf해요. - 합에 (앞 + 뒤)를 넣어요. - 앞에 뒤를 넣어요. - 뒤에 합을 넣어요. + 합은 (앞 + 뒤)예요. + 앞은 뒤예요. + 뒤는 합이에요. } 0을 반환해요. diff --git a/sample/09_primes.kr b/sample/09_primes.kr index f9ea88c..a7751e7 100644 --- a/sample/09_primes.kr +++ b/sample/09_primes.kr @@ -15,7 +15,7 @@ 만약 가 % 약수 == 0이면 { 0을 반환해요. } - 약수에 (약수 + 1)을 넣어요. + 약수는 (약수 + 1)이에요. } 1을 반환해요. } @@ -23,7 +23,7 @@ 정수를 반환하는 main() { 판정은 정수예요. 정수 후보를 0부터 50까지 세면서 { - 후보를 검사해서 판정에 넣어요. + 판정은 후보를 검사한 값이에요. 만약 판정 == 0이면 { 넘어가요. } "%ld\n"과 후보를 printf해요. } diff --git a/sample/10_gcd.kr b/sample/10_gcd.kr index b355f2d..99bace9 100644 --- a/sample/10_gcd.kr +++ b/sample/10_gcd.kr @@ -8,16 +8,16 @@ 두 정수 가와 나를 받아 나누고 정수를 반환 { 나머지는 정수예요. (나 == 0)이 아닌 동안 { - 나머지에 (가 % 나)를 넣어요. - 가에 나를 넣어요. - 나에 나머지를 넣어요. + 나머지는 (가 % 나)예요. + 가는 나예요. + 나는 나머지예요. } 가를 반환해요. } 정수를 반환하는 main() { 결과는 정수예요. - 48과 18을 나눠서 결과에 넣어요. + 결과는 48과 18을 나눈 값이에요. "gcd(48, 18) = %ld\n"과 결과를 printf해요. // 6 결과를 반환해요. } diff --git a/sample/11_assignment.kr b/sample/11_assignment.kr index aaf1333..ff5c125 100644 --- a/sample/11_assignment.kr +++ b/sample/11_assignment.kr @@ -1,12 +1,13 @@ /* - * 11_assignment.kr: initializations and assignments of literals and variables. + * 11_assignment.kr: initializations and assignments of literals and variables. A name already + * declared gets a new value with the same sentence as its declaration. * main returns 7: `echo $?` prints 7 after the run. */ 정수를 반환하는 main() { 가는 1이에요. 나는 2예요. - 7을 가에 넣어요. - 가를 나에 넣어요. + 가는 7이에요. + 나는 가예요. 나를 반환해요. } diff --git a/sample/13_operators.kr b/sample/13_operators.kr index 66a7b73..c95c2a0 100644 --- a/sample/13_operators.kr +++ b/sample/13_operators.kr @@ -20,32 +20,32 @@ 오른쪽은 (가 >> 2)예요. // 5 결과는 0이에요. - 결과에 (결과 + 합)을 넣어요. - 결과에 (결과 + 차)를 넣어요. - 결과에 (결과 + 곱)을 넣어요. - 결과에 (결과 + 몫)을 넣어요. - 결과에 (결과 + 앤드)를 넣어요. - 결과에 (결과 + 오어)를 넣어요. - 결과에 (결과 + 엑스)를 넣어요. - 결과에 (결과 + 왼쪽)을 넣어요. - 결과에 (결과 + 오른쪽)을 넣어요. + 결과는 (결과 + 합)이에요. + 결과는 (결과 + 차)예요. + 결과는 (결과 + 곱)이에요. + 결과는 (결과 + 몫)이에요. + 결과는 (결과 + 앤드)예요. + 결과는 (결과 + 오어)예요. + 결과는 (결과 + 엑스)예요. + 결과는 (결과 + 왼쪽)이에요. + 결과는 (결과 + 오른쪽)이에요. // ~0 is 2^64 - 1 here; read as signed, it would be -1 가득은 부호 없는 정수예요. - 가득에 0을 넣어요. - 가득에 (~가득)을 넣어요. + 가득은 0이에요. + 가득은 (~가득)이에요. 양몫은 (가득 / 9223372036854775807)이에요. // 2; signed: 0 양나머지는 (가득 % 10)이에요. // 5; signed: -1 양오른쪽은 (가득 >> 60)이에요. // 15; signed: -1 둘은 정수예요. - 양몫을 정수로 바꿔서 둘에 넣어요. + 둘은 양몫을 정수로 바꾼 값이에요. 다섯은 정수예요. - 양나머지를 정수로 바꿔서 다섯에 넣어요. + 다섯은 양나머지를 정수로 바꾼 값이에요. 열다섯은 정수예요. - 양오른쪽을 정수로 바꿔서 열다섯에 넣어요. - 결과에 (결과 + 둘)을 넣어요. - 결과에 (결과 + 다섯)을 넣어요. - 결과에 (결과 + 열다섯)을 넣어요. + 열다섯은 양오른쪽을 정수로 바꾼 값이에요. + 결과는 (결과 + 둘)이에요. + 결과는 (결과 + 다섯)이에요. + 결과는 (결과 + 열다섯)이에요. 결과를 반환해요. } diff --git a/sample/14_short.kr b/sample/14_short.kr index b06adb8..7bb11da 100644 --- a/sample/14_short.kr +++ b/sample/14_short.kr @@ -14,12 +14,12 @@ 짧은 정수를 반환하는 main() { 가는 짧은 정수예요. 나는 짧은 정수예요. - 가에 5를 넣어요. // Copy: without the size, 나 would overwrite 가 - 나에 7을 넣어요. + 가는 5예요. // Copy: without the size, 나 would overwrite 가 + 나는 7이에요. 다는 (가 + 나)예요. // Binary: without the size, the result would overwrite 나 라는 짧은 정수예요. - 라에 -20을 넣어요. + 라는 -20이에요. 마는 짧은 정수예요. - 30과 8을 빼서 마에 넣어요. // 22 + 마는 30과 8을 뺀 값이에요. // 22 ((((가 + 나) + 다) + 마) + (라 / 6))을 반환해요. // (라 / 6) = -3 } diff --git a/sample/15_floats.kr b/sample/15_floats.kr index e2cb9ce..2416bd2 100644 --- a/sample/15_floats.kr +++ b/sample/15_floats.kr @@ -20,32 +20,32 @@ 다는 (가 + 나)예요. // 3.75 라는 (다 - 0.75)예요. // 3.0 마는 소수예요. - 라와 4.5를 곱해서 마에 넣어요. // 13.5, parameters and return in xmm0 / xmm1 + 마는 라와 4.5를 곱한 값이에요. // 13.5, parameters and return in xmm0 / xmm1 바는 (마 / 0.5)예요. // 27.0 사는 (-바)예요. // -27.0 "%f %f\n"과 바와 사를 printf해요. // 짧은 소수: 4 bytes; printf wants a double, hence the conversion 아는 짧은 소수예요. - 아에 2.5를 넣어요. + 아는 2.5예요. 자는 소수예요. - 아를 소수로 바꿔서 자에 넣어요. + 자는 아를 소수로 바꾼 값이에요. "%f\n"과 자를 printf해요. // back to an integer: cvttsd2si truncates toward 0 차는 정수예요. - 바를 정수로 바꿔서 차에 넣어요. // 27 + 차는 바를 정수로 바꾼 값이에요. // 27 카는 정수예요. - 자를 정수로 바꿔서 카에 넣어요. // 2 + 카는 자를 정수로 바꾼 값이에요. // 2 파는 (차 + 카)예요. // ucomisd sets ZF on a NaN, as if equal: == and != must also read PF 타는 (0.0 / 0.0)이에요. 만약 타 == 타면 { - 파에 (파 + 2)를 넣어요. + 파는 (파 + 2)예요. } 만약 타 != 타면 { - 파에 (파 + 1)을 넣어요. + 파는 (파 + 1)이에요. } 파를 반환해요. } diff --git a/sample/16_zero.kr b/sample/16_zero.kr index 2ba8411..3356257 100644 --- a/sample/16_zero.kr +++ b/sample/16_zero.kr @@ -22,23 +22,23 @@ 이름은 문자 주소예요. 결과는 0이에요. 만약 수 != 0이면 { - 결과에 (결과 + 1)을 넣어요. + 결과는 (결과 + 1)이에요. } 만약 소 != 0.0이면 { - 결과에 (결과 + 2)를 넣어요. + 결과는 (결과 + 2)예요. } 만약 논이면 { - 결과에 (결과 + 4)를 넣어요. + 결과는 (결과 + 4)예요. } 만약 이름 != 빈 주소면 { - 결과에 (결과 + 8)을 넣어요. + 결과는 (결과 + 8)이에요. } 결과를 반환해요. } 정수를 반환하는 main() { 결과는 정수예요. - 0을 채워서 결과에 넣어요. // no call between: printf would write over the slots - 0을 읽어서 결과에 넣어요. + 결과는 0을 채운 값이에요. // no call between: printf would write over the slots + 결과는 0을 읽은 값이에요. 결과를 반환해요. } diff --git a/sample/errors/already_declared.kr b/sample/errors/already_declared.kr index eeb9d09..44d7d04 100644 --- a/sample/errors/already_declared.kr +++ b/sample/errors/already_declared.kr @@ -1,7 +1,7 @@ -// Converter: 가 is declared twice in the same block. +// Converter: 가 is declared twice: a type after a name already declared is no new value. 정수를 반환하는 main() { 가는 1이에요. - 가는 2이에요. + 가는 정수예요. 가를 반환해요. } diff --git a/sample/errors/assign_without_target.kr b/sample/errors/assign_without_target.kr deleted file mode 100644 index 53000d3..0000000 --- a/sample/errors/assign_without_target.kr +++ /dev/null @@ -1,7 +0,0 @@ -// Post-parser: 넣어요 without a variable with 에. - -정수를 반환하는 main() { - 가는 0이에요. - 1을 넣어요. - 가를 반환해요. -} diff --git a/sample/errors/constant_modified.kr b/sample/errors/constant_modified.kr index 9e3c6e9..ae630bb 100644 --- a/sample/errors/constant_modified.kr +++ b/sample/errors/constant_modified.kr @@ -1,7 +1,7 @@ -// Converter: 끝 is 고정된, 넣어요 cannot change its value. +// Converter: 끝 is 고정된, a new value cannot change it. 정수를 반환하는 main() { 고정된 끝은 10이에요. - 끝에 20을 넣어요. + 끝은 20이에요. 끝을 반환해요. } diff --git a/sample/errors/invalid_cast.kr b/sample/errors/invalid_cast.kr index bb6d89e..f93ae10 100644 --- a/sample/errors/invalid_cast.kr +++ b/sample/errors/invalid_cast.kr @@ -2,6 +2,6 @@ 정수를 반환하는 main() { 비율은 소수예요. - "abc"를 소수로 바꿔서 비율에 넣어요. + 비율은 "abc"를 소수로 바꾼 값이에요. 0을 반환해요. } diff --git a/sample/errors/latin_function_name.kr b/sample/errors/latin_function_name.kr index 0c62047..45483e2 100644 --- a/sample/errors/latin_function_name.kr +++ b/sample/errors/latin_function_name.kr @@ -6,6 +6,6 @@ 정수를 반환하는 main() { 결과는 정수예요. - foo해서 결과에 넣어요. + 결과는 foo한 값이에요. 결과를 반환해요. } diff --git a/sample/errors/literal_too_big.kr b/sample/errors/literal_too_big.kr index 50dcf79..279adcf 100644 --- a/sample/errors/literal_too_big.kr +++ b/sample/errors/literal_too_big.kr @@ -2,6 +2,6 @@ 정수를 반환하는 main() { 작은은 짧은 정수예요. - 작은에 5000000000을 넣어요. + 작은은 5000000000이에요. 0을 반환해요. } diff --git a/sample/errors/negative_unsigned.kr b/sample/errors/negative_unsigned.kr index bf88efb..6c82630 100644 --- a/sample/errors/negative_unsigned.kr +++ b/sample/errors/negative_unsigned.kr @@ -2,6 +2,6 @@ 정수를 반환하는 main() { 양은 부호 없는 정수예요. - 양에 -1을 넣어요. + 양은 -1이에요. 0을 반환해요. } diff --git a/sample/errors/shadow_in_block.kr b/sample/errors/shadow_in_block.kr index 83ce294..16618e2 100644 --- a/sample/errors/shadow_in_block.kr +++ b/sample/errors/shadow_in_block.kr @@ -1,9 +1,9 @@ -// Converter: 가 is declared again in a 만약, while the 가 of main is still visible. +// Converter: 가 is declared again with a type in a 만약, while the 가 of main is still visible. 정수를 반환하는 main() { 가는 1이에요. 만약 가 == 1이면 { - 가는 가예요. + 가는 정수예요. } 가를 반환해요. } diff --git a/sample/errors/shadow_parameter.kr b/sample/errors/shadow_parameter.kr index 5524d6b..04ce525 100644 --- a/sample/errors/shadow_parameter.kr +++ b/sample/errors/shadow_parameter.kr @@ -1,7 +1,7 @@ -// Converter: the body declares the parameter 가 again. +// Converter: the body declares the parameter 가 again, with a type. 정수를 반환하는 확인하다(정수 가) { - 가는 2예요. + 가는 정수예요. 가를 반환해요. } diff --git a/sample/errors/value_without_type.kr b/sample/errors/value_without_type.kr index 0336b45..4c978bf 100644 --- a/sample/errors/value_without_type.kr +++ b/sample/errors/value_without_type.kr @@ -8,6 +8,6 @@ 정수를 반환하는 main() { 가는 0이에요. - 1을 보여줘서 가에 넣어요. + 가는 1을 보여준 값이에요. 0을 반환해요. } diff --git a/sample/errors/wrong_assignment.kr b/sample/errors/wrong_assignment.kr index 8cdff3e..e6e1b4e 100644 --- a/sample/errors/wrong_assignment.kr +++ b/sample/errors/wrong_assignment.kr @@ -1,7 +1,7 @@ -// Converter: 가 is a 정수, 넣어요 cannot give it a 논리. +// Converter: 가 is a 정수, a new value cannot make it a 논리. 정수를 반환하는 main() { 가는 0이에요. - 가에 참을 넣어요. + 가는 참이에요. 가를 반환해요. } diff --git a/specs/10-warn-unreachable-code/cases/after_continue.kr b/specs/10-warn-unreachable-code/cases/after_continue.kr index 2587a9e..66bd5a9 100644 --- a/specs/10-warn-unreachable-code/cases/after_continue.kr +++ b/specs/10-warn-unreachable-code/cases/after_continue.kr @@ -3,9 +3,9 @@ 정수를 반환하는 main() { 가는 0이에요. 가 < 3인 동안 { - 가에 (가 + 1)을 넣어요. + 가는 (가 + 1)이에요. 넘어가요. - 가에 9를 넣어요. + 가는 9예요. } 가를 반환해요. } diff --git a/specs/11-read-before-value/cases/assigned_first.kr b/specs/11-read-before-value/cases/assigned_first.kr index 274ec8f..8f839bd 100644 --- a/specs/11-read-before-value/cases/assigned_first.kr +++ b/specs/11-read-before-value/cases/assigned_first.kr @@ -2,6 +2,6 @@ 정수를 반환하는 main() { 나는 정수예요. - 나에 1을 넣어요. + 나는 1이에요. 나를 반환해요. } diff --git a/specs/17-particles-against-batchim/checks.sh b/specs/17-particles-against-batchim/checks.sh index 7ae2dd6..854857a 100644 --- a/specs/17-particles-against-batchim/checks.sh +++ b/specs/17-particles-against-batchim/checks.sh @@ -66,6 +66,6 @@ right_program string_gwa "$PRINTF"$'\n''정수를 반환하는 main() { "%ld\n" right_program string_wa "$PRINTF"$'\n''정수를 반환하는 main() { "%ld\n"와 3을 printf해요. 0을 반환해요. }' # (으)로 -wrong euro_after_vowel '가는 1이에요. 나는 소수예요. 가를 소수으로 바꿔서 나에 넣어요. 0을 반환해요.' -right ro_after_vowel '가는 1이에요. 나는 소수예요. 가를 소수로 바꿔서 나에 넣어요. 0을 반환해요.' +wrong euro_after_vowel '가는 1이에요. 나는 소수예요. 나는 가를 소수으로 바꾼 값이에요. 0을 반환해요.' +right ro_after_vowel '가는 1이에요. 나는 소수예요. 나는 가를 소수로 바꾼 값이에요. 0을 반환해요.' manual "로 after a ㄹ 받침 (결말로): names take no (으)로 and no type ends in ㄹ, so only a unit test of the rule can show it" diff --git a/specs/2-casts-from-unsigned/byte_to_int.kr b/specs/2-casts-from-unsigned/byte_to_int.kr index cfd1bee..1458f31 100644 --- a/specs/2-casts-from-unsigned/byte_to_int.kr +++ b/specs/2-casts-from-unsigned/byte_to_int.kr @@ -3,9 +3,9 @@ 정수를 반환하는 main() { 가는 바이트예요. - 200을 바이트로 바꿔서 가에 넣어요. + 가는 200을 바이트로 바꾼 값이에요. 나는 정수예요. - 가를 정수로 바꿔서 나에 넣어요. + 나는 가를 정수로 바꾼 값이에요. 만약 나 == 200이면 { 1을 반환해요. } diff --git a/specs/2-casts-from-unsigned/float_to_byte.kr b/specs/2-casts-from-unsigned/float_to_byte.kr index decd8e4..4247917 100644 --- a/specs/2-casts-from-unsigned/float_to_byte.kr +++ b/specs/2-casts-from-unsigned/float_to_byte.kr @@ -4,6 +4,6 @@ 정수를 반환하는 main() { 가는 7.5예요. 나는 바이트예요. - 가를 바이트로 바꿔서 나에 넣어요. + 나는 가를 바이트로 바꾼 값이에요. 나를 정수로 바꿔서 반환해요. } diff --git a/specs/2-casts-from-unsigned/float_to_char.kr b/specs/2-casts-from-unsigned/float_to_char.kr index ff737ed..139271b 100644 --- a/specs/2-casts-from-unsigned/float_to_char.kr +++ b/specs/2-casts-from-unsigned/float_to_char.kr @@ -4,6 +4,6 @@ 정수를 반환하는 main() { 가는 7.5예요. 나는 문자예요. - 가를 문자로 바꿔서 나에 넣어요. + 나는 가를 문자로 바꾼 값이에요. 나를 정수로 바꿔서 반환해요. } diff --git a/specs/2-casts-from-unsigned/unsigned_64_to_float.kr b/specs/2-casts-from-unsigned/unsigned_64_to_float.kr index ff05015..47ab04a 100644 --- a/specs/2-casts-from-unsigned/unsigned_64_to_float.kr +++ b/specs/2-casts-from-unsigned/unsigned_64_to_float.kr @@ -5,10 +5,10 @@ 정수를 반환하는 main() { 가는 부호 없는 정수예요. - 가에 1을 넣어요. - 가에 (가 << 63)을 넣어요. + 가는 1이에요. + 가는 (가 << 63)이에요. 나는 소수예요. - 가를 소수로 바꿔서 나에 넣어요. + 나는 가를 소수로 바꾼 값이에요. "%.0f\n"과 나를 printf해요. 0을 반환해요. } diff --git a/specs/20-unsigned-32-bit-integer/short_unsigned_compares_unsigned.kr b/specs/20-unsigned-32-bit-integer/short_unsigned_compares_unsigned.kr index 576e3e6..197615d 100644 --- a/specs/20-unsigned-32-bit-integer/short_unsigned_compares_unsigned.kr +++ b/specs/20-unsigned-32-bit-integer/short_unsigned_compares_unsigned.kr @@ -3,7 +3,7 @@ 정수를 반환하는 main() { 가는 짧은 부호 없는 정수예요. - 가에 3000000000을 넣어요. + 가는 3000000000이에요. 만약 가 > 2000000000이면 { 1을 반환해요. } diff --git a/specs/20-unsigned-32-bit-integer/unsigned_short_compares_unsigned.kr b/specs/20-unsigned-32-bit-integer/unsigned_short_compares_unsigned.kr index 7c59f97..04c0d2a 100644 --- a/specs/20-unsigned-32-bit-integer/unsigned_short_compares_unsigned.kr +++ b/specs/20-unsigned-32-bit-integer/unsigned_short_compares_unsigned.kr @@ -3,7 +3,7 @@ 정수를 반환하는 main() { 가는 부호 없는 짧은 정수예요. - 가에 3000000000을 넣어요. + 가는 3000000000이에요. 만약 가 > 2000000000이면 { 1을 반환해요. } diff --git a/specs/29-short-jumps-rel8/far_jump_still_runs.kr b/specs/29-short-jumps-rel8/far_jump_still_runs.kr index fa148f5..13243b2 100644 --- a/specs/29-short-jumps-rel8/far_jump_still_runs.kr +++ b/specs/29-short-jumps-rel8/far_jump_still_runs.kr @@ -4,26 +4,26 @@ 정수를 반환하는 main() { 가는 0이에요. 가 < 40인 동안 { - 가에 (가 + 1)을 넣어요. - 가에 (가 + 1)을 넣어요. - 가에 (가 + 1)을 넣어요. - 가에 (가 + 1)을 넣어요. - 가에 (가 + 1)을 넣어요. - 가에 (가 + 1)을 넣어요. - 가에 (가 + 1)을 넣어요. - 가에 (가 + 1)을 넣어요. - 가에 (가 + 1)을 넣어요. - 가에 (가 + 1)을 넣어요. - 가에 (가 + 1)을 넣어요. - 가에 (가 + 1)을 넣어요. - 가에 (가 + 1)을 넣어요. - 가에 (가 + 1)을 넣어요. - 가에 (가 + 1)을 넣어요. - 가에 (가 + 1)을 넣어요. - 가에 (가 + 1)을 넣어요. - 가에 (가 + 1)을 넣어요. - 가에 (가 + 1)을 넣어요. - 가에 (가 + 1)을 넣어요. + 가는 (가 + 1)이에요. + 가는 (가 + 1)이에요. + 가는 (가 + 1)이에요. + 가는 (가 + 1)이에요. + 가는 (가 + 1)이에요. + 가는 (가 + 1)이에요. + 가는 (가 + 1)이에요. + 가는 (가 + 1)이에요. + 가는 (가 + 1)이에요. + 가는 (가 + 1)이에요. + 가는 (가 + 1)이에요. + 가는 (가 + 1)이에요. + 가는 (가 + 1)이에요. + 가는 (가 + 1)이에요. + 가는 (가 + 1)이에요. + 가는 (가 + 1)이에요. + 가는 (가 + 1)이에요. + 가는 (가 + 1)이에요. + 가는 (가 + 1)이에요. + 가는 (가 + 1)이에요. } 가를 반환해요. } diff --git a/specs/33-declared-variable-not-zeroed/address.kr b/specs/33-declared-variable-not-zeroed/address.kr index 9bb66e2..a3aaa7e 100644 --- a/specs/33-declared-variable-not-zeroed/address.kr +++ b/specs/33-declared-variable-not-zeroed/address.kr @@ -16,7 +16,7 @@ 정수를 반환하는 main() { 결과는 정수예요. - 41을 채워서 결과에 넣어요. - 0을 읽어서 결과에 넣어요. + 결과는 41을 채운 값이에요. + 결과는 0을 읽은 값이에요. 결과를 반환해요. } diff --git a/specs/33-declared-variable-not-zeroed/address_of_address.kr b/specs/33-declared-variable-not-zeroed/address_of_address.kr index 63aeb1d..8f0ea60 100644 --- a/specs/33-declared-variable-not-zeroed/address_of_address.kr +++ b/specs/33-declared-variable-not-zeroed/address_of_address.kr @@ -16,7 +16,7 @@ 정수를 반환하는 main() { 결과는 정수예요. - 41을 채워서 결과에 넣어요. - 0을 읽어서 결과에 넣어요. + 결과는 41을 채운 값이에요. + 결과는 0을 읽은 값이에요. 결과를 반환해요. } diff --git a/specs/33-declared-variable-not-zeroed/array_compiles.kr b/specs/33-declared-variable-not-zeroed/array_compiles.kr index 6e29405..b15f424 100644 --- a/specs/33-declared-variable-not-zeroed/array_compiles.kr +++ b/specs/33-declared-variable-not-zeroed/array_compiles.kr @@ -13,7 +13,7 @@ 정수를 반환하는 main() { 결과는 정수예요. - 41을 채워서 결과에 넣어요. - 0을 읽어서 결과에 넣어요. + 결과는 41을 채운 값이에요. + 결과는 0을 읽은 값이에요. 결과를 반환해요. } diff --git a/specs/33-declared-variable-not-zeroed/bool.kr b/specs/33-declared-variable-not-zeroed/bool.kr index e136f02..08dacfa 100644 --- a/specs/33-declared-variable-not-zeroed/bool.kr +++ b/specs/33-declared-variable-not-zeroed/bool.kr @@ -16,7 +16,7 @@ 정수를 반환하는 main() { 결과는 정수예요. - 41을 채워서 결과에 넣어요. - 0을 읽어서 결과에 넣어요. + 결과는 41을 채운 값이에요. + 결과는 0을 읽은 값이에요. 결과를 반환해요. } diff --git a/specs/33-declared-variable-not-zeroed/byte.kr b/specs/33-declared-variable-not-zeroed/byte.kr index 8c59499..0cda7ef 100644 --- a/specs/33-declared-variable-not-zeroed/byte.kr +++ b/specs/33-declared-variable-not-zeroed/byte.kr @@ -13,7 +13,7 @@ 정수를 반환하는 main() { 결과는 정수예요. - 41을 채워서 결과에 넣어요. - 0을 읽어서 결과에 넣어요. + 결과는 41을 채운 값이에요. + 결과는 0을 읽은 값이에요. 결과를 반환해요. } diff --git a/specs/33-declared-variable-not-zeroed/char.kr b/specs/33-declared-variable-not-zeroed/char.kr index dba6859..2938727 100644 --- a/specs/33-declared-variable-not-zeroed/char.kr +++ b/specs/33-declared-variable-not-zeroed/char.kr @@ -13,7 +13,7 @@ 정수를 반환하는 main() { 결과는 정수예요. - 41을 채워서 결과에 넣어요. - 0을 읽어서 결과에 넣어요. + 결과는 41을 채운 값이에요. + 결과는 0을 읽은 값이에요. 결과를 반환해요. } diff --git a/specs/33-declared-variable-not-zeroed/float.kr b/specs/33-declared-variable-not-zeroed/float.kr index 699704b..416970a 100644 --- a/specs/33-declared-variable-not-zeroed/float.kr +++ b/specs/33-declared-variable-not-zeroed/float.kr @@ -16,7 +16,7 @@ 정수를 반환하는 main() { 결과는 정수예요. - 41을 채워서 결과에 넣어요. - 0을 읽어서 결과에 넣어요. + 결과는 41을 채운 값이에요. + 결과는 0을 읽은 값이에요. 결과를 반환해요. } diff --git a/specs/33-declared-variable-not-zeroed/int.kr b/specs/33-declared-variable-not-zeroed/int.kr index d729227..d8716e5 100644 --- a/specs/33-declared-variable-not-zeroed/int.kr +++ b/specs/33-declared-variable-not-zeroed/int.kr @@ -13,7 +13,7 @@ 정수를 반환하는 main() { 결과는 정수예요. - 41을 채워서 결과에 넣어요. - 0을 읽어서 결과에 넣어요. + 결과는 41을 채운 값이에요. + 결과는 0을 읽은 값이에요. 결과를 반환해요. } diff --git a/specs/33-declared-variable-not-zeroed/short_float.kr b/specs/33-declared-variable-not-zeroed/short_float.kr index 39c882f..2574ea5 100644 --- a/specs/33-declared-variable-not-zeroed/short_float.kr +++ b/specs/33-declared-variable-not-zeroed/short_float.kr @@ -16,7 +16,7 @@ 정수를 반환하는 main() { 결과는 정수예요. - 41을 채워서 결과에 넣어요. - 0을 읽어서 결과에 넣어요. + 결과는 41을 채운 값이에요. + 결과는 0을 읽은 값이에요. 결과를 반환해요. } diff --git a/specs/33-declared-variable-not-zeroed/short_int.kr b/specs/33-declared-variable-not-zeroed/short_int.kr index 35f02f5..03d8b7c 100644 --- a/specs/33-declared-variable-not-zeroed/short_int.kr +++ b/specs/33-declared-variable-not-zeroed/short_int.kr @@ -13,7 +13,7 @@ 정수를 반환하는 main() { 결과는 정수예요. - 41을 채워서 결과에 넣어요. - 0을 읽어서 결과에 넣어요. + 결과는 41을 채운 값이에요. + 결과는 0을 읽은 값이에요. 결과를 반환해요. } diff --git a/specs/33-declared-variable-not-zeroed/unsigned_int.kr b/specs/33-declared-variable-not-zeroed/unsigned_int.kr index 0c9ffc5..78bb83f 100644 --- a/specs/33-declared-variable-not-zeroed/unsigned_int.kr +++ b/specs/33-declared-variable-not-zeroed/unsigned_int.kr @@ -13,7 +13,7 @@ 정수를 반환하는 main() { 결과는 정수예요. - 41을 채워서 결과에 넣어요. - 0을 읽어서 결과에 넣어요. + 결과는 41을 채운 값이에요. + 결과는 0을 읽은 값이에요. 결과를 반환해요. } diff --git a/specs/4-sized-reads-return-and-args/byte_arg_to_c.kr b/specs/4-sized-reads-return-and-args/byte_arg_to_c.kr index 9461438..579fb01 100644 --- a/specs/4-sized-reads-return-and-args/byte_arg_to_c.kr +++ b/specs/4-sized-reads-return-and-args/byte_arg_to_c.kr @@ -6,8 +6,8 @@ 정수를 반환하는 main() { 가는 바이트예요. 나는 바이트예요. - 255를 바이트로 바꿔서 가에 넣어요. - 65를 바이트로 바꿔서 나에 넣어요. + 가는 255를 바이트로 바꾼 값이에요. + 나는 65를 바이트로 바꾼 값이에요. "%d\n"과 나를 printf해요. 0을 반환해요. } diff --git a/specs/4-sized-reads-return-and-args/short_arg_to_c.kr b/specs/4-sized-reads-return-and-args/short_arg_to_c.kr index 5929382..81b86e6 100644 --- a/specs/4-sized-reads-return-and-args/short_arg_to_c.kr +++ b/specs/4-sized-reads-return-and-args/short_arg_to_c.kr @@ -6,8 +6,8 @@ 정수를 반환하는 main() { 가는 짧은 정수예요. 나는 짧은 정수예요. - 가에 5를 넣어요. - 나에 7을 넣어요. + 가는 5예요. + 나는 7이에요. "%ld\n"과 나를 printf해요. 0을 반환해요. } diff --git a/specs/44-header-declaration/cases/prog.kr b/specs/44-header-declaration/cases/prog.kr index 490d9f9..6b8d842 100644 --- a/specs/44-header-declaration/cases/prog.kr +++ b/specs/44-header-declaration/cases/prog.kr @@ -4,6 +4,6 @@ 정수를 반환하는 main() { 결과는 정수예요. - 40과 2를 더해서 결과에 넣어요. + 결과는 40과 2를 더한 값이에요. 결과를 반환해요. } diff --git a/specs/5-stack-arguments/nine_float_args.kr b/specs/5-stack-arguments/nine_float_args.kr index c5a547a..6037d55 100644 --- a/specs/5-stack-arguments/nine_float_args.kr +++ b/specs/5-stack-arguments/nine_float_args.kr @@ -7,6 +7,6 @@ 정수를 반환하는 main() { 결과는 소수예요. - 1.0과 2.0과 3.0과 4.0과 5.0과 6.0과 7.0과 8.0과 9.0을 더해서 결과에 넣어요. + 결과는 1.0과 2.0과 3.0과 4.0과 5.0과 6.0과 7.0과 8.0과 9.0을 더한 값이에요. 결과를 정수로 바꿔서 반환해요. } diff --git a/specs/6-pointers-and-arrays/errors/assign_whole_array.kr b/specs/6-pointers-and-arrays/errors/assign_whole_array.kr index 6bc0912..cca8f9b 100644 --- a/specs/6-pointers-and-arrays/errors/assign_whole_array.kr +++ b/specs/6-pointers-and-arrays/errors/assign_whole_array.kr @@ -3,6 +3,6 @@ 정수를 반환하는 main() { 가는 정수 3개예요. 나는 정수 3개예요. - 나에 가를 넣어요. + 나는 가예요. 0을 반환해요. } diff --git a/src/converter/convert_error.rs b/src/converter/convert_error.rs index 3935d57..824e543 100644 --- a/src/converter/convert_error.rs +++ b/src/converter/convert_error.rs @@ -15,7 +15,7 @@ pub enum ConvertErrorKind { UnknownVariable(String), /// No function of this verb takes arguments of these types UnknownFunction { verb: String, types: String }, - /// `넣어요` or `세면서` on a `고정된` variable + /// A new value (`가는 1이에요.`) or `세면서` on a `고정된` variable AssignToConstant(String), /// `반환해요` in a function without `TYPE을 반환하는` ReturnWithoutType(String), @@ -29,7 +29,7 @@ pub enum ConvertErrorKind { MainNotInteger, /// `반환해요` of a value whose type is not the `TYPE을 반환하는` of its function WrongReturnType { expected: String, found: String }, - /// `넣어요` of a value whose type is not the type of its variable + /// A new value (`가는 1이에요.`) whose type is not the type of its variable WrongAssignType { name: String, expected: String, diff --git a/src/converter/statements.rs b/src/converter/statements.rs index d98d89e..9599942 100644 --- a/src/converter/statements.rs +++ b/src/converter/statements.rs @@ -3,8 +3,8 @@ use super::ir::structs::{Function as IrFunc, Instr as IrInstr, Operand as IrOper use super::scope::LoopLabels; use crate::lexer::span::Span; use crate::parser::postparser::structs::{ - Argument, Assign, BinaryOp, Declare, Expr, ExprKind, For, Function, If, Init, Statement, - StatementKind, Type, UnaryOp, While, + Argument, BinaryOp, Declare, Expr, ExprKind, For, Function, If, Init, Statement, StatementKind, + Type, UnaryOp, While, }; use super::convert_error::{ConvertError, ConvertErrorKind}; @@ -420,7 +420,8 @@ impl<'a> Converter<'a> { Ok(instr) } - /// `결과는 0이에요.`: adds the variable to `scope` + /// `결과는 0이에요.`: adds the variable to `scope`; on a name already declared, without + /// `고정된`, gives that variable a new value fn convert_init( &mut self, scope: &mut Scope, @@ -428,6 +429,9 @@ impl<'a> Converter<'a> { span: Span, ir_func: &mut IrFunc, ) -> Result, ConvertError> { + if !init.constant && scope.find_variable(&init.name).is_some() { + return self.convert_assign(scope, &init.name, &init.value, span, ir_func); + } let ty = match self.get_type(&init.value, scope)? { // `없음은 빈 주소예요.`: an address to nothing, the void* of C Type::Null => Type::Address(Box::new(Type::Null)), @@ -448,35 +452,33 @@ impl<'a> Converter<'a> { Ok(instrs) } - /// `… 결과에 넣어요.` + /// `결과는 (결과 + 1)이에요.` on `target`, a variable of `scope` fn convert_assign( &mut self, scope: &Scope, - assign: &'a Assign, + target: &str, + value: &Expr, span: Span, ir_func: &mut IrFunc, ) -> Result, ConvertError> { - // check if the variable exists - let Some(var) = scope.find_variable(&assign.target) else { - let kind = ConvertErrorKind::UnknownVariable(assign.target.clone()); - return Err(ConvertError::new(kind, span)); - }; - // check if the var is const + let var = scope + .find_variable(target) + .expect("convert_init reassigns only a declared variable"); if var.constant { - let kind = ConvertErrorKind::AssignToConstant(assign.target.clone()); + let kind = ConvertErrorKind::AssignToConstant(target.to_string()); return Err(ConvertError::new(kind, span)); } let mut instrs: Vec = vec![]; - let src = self.convert_expr(&assign.value, scope, ir_func, &mut instrs)?; - let assign_value_ty = self.get_type(&assign.value, scope)?; + let src = self.convert_expr(value, scope, ir_func, &mut instrs)?; + let assign_value_ty = self.get_type(value, scope)?; - if !fits(&assign.value, &assign_value_ty, &var.ty) { - if let Some(err) = range_error(&assign.value, &assign_value_ty, &var.ty) { + if !fits(value, &assign_value_ty, &var.ty) { + if let Some(err) = range_error(value, &assign_value_ty, &var.ty) { return Err(err); } let kind = ConvertErrorKind::WrongAssignType { - name: assign.target.clone(), + name: target.to_string(), expected: type_name(&var.ty), found: type_name(&assign_value_ty), }; @@ -646,9 +648,6 @@ impl<'a> Converter<'a> { StatementKind::Init(init) => { self.convert_init(&mut new_scope, init, statement.span, ir_func)? } - StatementKind::Assign(assign) => { - self.convert_assign(&new_scope, assign, statement.span, ir_func)? - } StatementKind::Return(value) => { self.convert_return(&new_scope, value, statement.span, ir_func)? } @@ -686,7 +685,6 @@ fn source_line(statement: &Statement) -> String { "{} {name} = {value}", if *constant { "const" } else { "let" } ), - StatementKind::Assign(Assign { target, value }) => format!("{target} = {value}"), StatementKind::Return(value) => format!("return {value}"), StatementKind::Call(call) => call.to_string(), StatementKind::If(If { condition, .. }) => format!("if {condition}"), diff --git a/src/lexer/lexer_error.rs b/src/lexer/lexer_error.rs index 2c3f274..e2a83a1 100644 --- a/src/lexer/lexer_error.rs +++ b/src/lexer/lexer_error.rs @@ -15,7 +15,7 @@ pub enum LexErrorKind { InvalidEscape(char), /// An integer literal above `i64::MAX` IntegerOverflow, - /// `=` alone: there is no assignment operator, it is written 넣어요 + /// `=` alone: there is no assignment operator, it is written `가는 1이에요` LoneEquals, /// `!` alone: there is no negation operator, it is written 아니면 LoneBang, @@ -54,7 +54,7 @@ impl fmt::Display for LexErrorKind { Self::IntegerOverflow => write!(f, "integer too large (maximum {})", i64::MAX), Self::LoneEquals => write!( f, - "'=' alone does not exist: assignment is written 넣어요, equality ==" + "'=' alone does not exist: assignment is written 가는 1이에요, equality ==" ), Self::LoneBang => write!( f, diff --git a/src/parser/cfg/rules.rs b/src/parser/cfg/rules.rs index eceafe4..1e928a2 100644 --- a/src/parser/cfg/rules.rs +++ b/src/parser/cfg/rules.rs @@ -162,8 +162,12 @@ pub const RULES: &[ParserProduction] = &[ ), rule!(DeclarationValue => NTerm(Operand)), rule!(DeclarationValue => NTerm(TypeSpec)), - rule!(DeclarationValue => NTerm(Arguments), term!(Verb::Adnominal), term!(Keyword::Value)), - rule!(DeclarationValue => term!(Verb::Adnominal), term!(Keyword::Value)), + rule!(DeclarationValue => NTerm(Steps), NTerm(ValueStep), term!(Keyword::Value)), + rule!(DeclarationValue => NTerm(ValueStep), term!(Keyword::Value)), + rule!(ValueStep => NTerm(Arguments), NTerm(AdnominalVerb)), + rule!(ValueStep => NTerm(AdnominalVerb)), + rule!(AdnominalVerb => term!(Verb::Adnominal)), + rule!(AdnominalVerb => term!(Name), term!(Verb::Adnominal)), // Call chains rule!(Chain => NTerm(Steps), NTerm(EndStep)), rule!(Chain => NTerm(EndStep)), diff --git a/src/parser/cfg/structs.rs b/src/parser/cfg/structs.rs index c4bea74..d3ec49d 100644 --- a/src/parser/cfg/structs.rs +++ b/src/parser/cfg/structs.rs @@ -46,10 +46,15 @@ pub enum NTerm { Statement, /// The `.` accepted after a final `요` OptionalDot, - /// `개수는 0이에요`, `고정된 합은 3과 4를 더한 값이에요` + /// `개수는 0이에요`, `고정된 합은 3과 4를 더한 값이에요`; also a reassignment when the name + /// is already declared VariableDeclaration, - /// What is before `이에요/예요`: a value, a type, or `… 더한 값` + /// What is before `이에요/예요`: a value, a type, or `… 더해서 제곱한 값` DeclarationValue, + /// The last step of a value, before `값`: `5를 곱한`, `제곱한` + ValueStep, + /// `곱한`, `제곱한`, `printf한` + AdnominalVerb, /// `3과 4를 더해서 5를 곱해서 반환해요` Chain, /// The `-아/어서` steps of a chain diff --git a/src/parser/parser_token.rs b/src/parser/parser_token.rs index 3ff62ba..4bf2d0d 100644 --- a/src/parser/parser_token.rs +++ b/src/parser/parser_token.rs @@ -14,7 +14,7 @@ pub enum ParserTokenKind { /// A Hangul word that is no keyword or type: an identifier, maybe with its particle (나를, /// 결과에, 결과); split into `Name` + `Particle` once the declared names are known Ident(String), - /// A conjugated verb, user-defined or built-in: 더해서, 넣어요, `printf해요` (two lexer tokens) + /// A conjugated verb, user-defined or built-in: 더해서, 바꿔요, `printf해요` (two lexer tokens) Verb { infinitive: String, ending: Ending, @@ -119,7 +119,7 @@ pub enum Ending { Da, /// -아/어서 : links a step of a chain (`더해서`) Seo, - /// -아/어요 : ends a chain (`더해요`, `넣어요`) + /// -아/어요 : ends a chain (`더해요`, `printf해요`) Yo, /// -(으)ㄴ : qualifies a noun (`더한 값`) Adnominal, @@ -140,7 +140,7 @@ pub enum Particle { Topic, /// 와/과 : and, links arguments With, - /// 에 : into, destination of 넣다 + /// 에 : in, to; an argument of a user verb (`결과에`) In, /// (으)로 : to, target type of 바꾸다 To, diff --git a/src/parser/postparser/display.rs b/src/parser/postparser/display.rs index 126a2a5..74e504e 100644 --- a/src/parser/postparser/display.rs +++ b/src/parser/postparser/display.rs @@ -1,7 +1,7 @@ use std::fmt; use super::structs::{ - Argument, Assign, BinaryOp, Declare, Expr, ExprKind, For, Function, If, Init, Param, Program, + Argument, BinaryOp, Declare, Expr, ExprKind, For, Function, If, Init, Param, Program, Statement, StatementKind, Type, UnaryOp, While, }; @@ -98,7 +98,6 @@ fn line(f: &mut fmt::Formatter, statement: &Statement, depth: usize) -> fmt::Res "{} {name} = {value}", if *constant { "const" } else { "let" } ), - StatementKind::Assign(Assign { target, value }) => writeln!(f, "{target} = {value}"), StatementKind::Return(value) => writeln!(f, "return {value}"), StatementKind::Call(call) => writeln!(f, "{call}"), StatementKind::If(If { diff --git a/src/parser/postparser/post_parse_error.rs b/src/parser/postparser/post_parse_error.rs index 3154339..e309166 100644 --- a/src/parser/postparser/post_parse_error.rs +++ b/src/parser/postparser/post_parse_error.rs @@ -17,8 +17,6 @@ pub enum PostParseErrorKind { CountArguments, /// `반환해요` with no value, two values, or a value without `을/를` GiveArguments, - /// `넣어요` without its value or its variable with `에`, or with another argument - PutArguments, /// `정수 가와 나를`: a name alone after a parameter without counter ParameterWithoutType(String), /// `두 정수 가와 나와 다를`: the counter announces `expected` names, the group has `found` @@ -57,9 +55,6 @@ impl fmt::Display for PostParseErrorKind { "세면서 takes a variable with 을/를, a start with 부터 and an end with 까지" ), Self::GiveArguments => write!(f, "반환해요 takes one value, with 을/를"), - Self::PutArguments => { - write!(f, "넣어요 takes a value with 을/를 and a variable with 에") - } Self::ParameterWithoutType(name) => write!( f, "the parameter '{name}' has no type: write it before the name, or count the \ diff --git a/src/parser/postparser/postparser.rs b/src/parser/postparser/postparser.rs index 836277a..388c4e4 100644 --- a/src/parser/postparser/postparser.rs +++ b/src/parser/postparser/postparser.rs @@ -8,7 +8,7 @@ use super::super::parser_token::{Keyword, ParserTokenKind, Particle, Type as Tok use super::post_parse_error::{PostParseError, PostParseErrorKind}; use super::structs::{ - Argument, Assign, BinaryOp, Declare, Expr, ExprKind, For, Function, If, Init, Param, Program, + Argument, BinaryOp, Declare, Expr, ExprKind, For, Function, If, Init, Param, Program, Statement, StatementKind, Type, UnaryOp, While, }; @@ -430,7 +430,8 @@ fn statement(node: &TreeNode) -> Result { } /// VariableDeclaration → [고정된] Name 는 DeclarationValue 이에요 OptionalDot -/// DeclarationValue → Operand | TypeSpec | Arguments VERB-ㄴ 값 | VERB-ㄴ 값 +/// DeclarationValue → Operand | TypeSpec | Steps ValueStep 값 | ValueStep 값 +/// ValueStep → Arguments VERB-ㄴ | VERB-ㄴ, a chain whose last verb gives the value fn variable_declaration(node: &TreeNode) -> Result { let children = branch(node).1; let constant = children.len() == 6; @@ -452,23 +453,15 @@ fn variable_declaration(node: &TreeNode) -> Result expression(operand)?, - [args, adnominal, _] => Expr { - kind: ExprKind::Call { - verb: verb(adnominal), - args: arguments(args)? - .into_iter() - .map(to_argument) - .collect::>()?, - }, - span: span(declared), - }, - [adnominal, _] => Expr { - kind: ExprKind::Call { - verb: verb(adnominal), - args: Vec::new(), - }, - span: span(declared), - }, + [steps, last, _] => { + let previous = chain_steps(step_list(steps)?)?; + let (args, last_verb, last_span) = step(last)?; + call(last_verb.unwrap(), previous, args, last_span)? + } + [last, _] => { + let (args, last_verb, last_span) = step(last)?; + call(last_verb.unwrap(), None, args, last_span)? + } _ => unreachable!(), }; Ok(StatementKind::Init(Init { @@ -587,21 +580,17 @@ fn to_argument((arg, arg_span): (Arg, Span)) -> Result /// Steps → Step | Steps Step /// Step → Arguments LinkVerb | LinkVerb, and EndStep the same with EndVerb /// The result of each step is the first argument of the next one; the end verb makes the -/// statement: 반환해요 a `Return`, 넣어요 an `Assign`, any other verb a `Call` +/// statement: 반환해요 a `Return`, any other verb a `Call` fn chain(node: &TreeNode) -> Result { let (steps, end) = match branch(node).1 { [steps, end] => (step_list(steps)?, end), [end] => (Vec::new(), end), _ => unreachable!(), }; - let mut previous = None; - for (args, verb, step_span) in steps { - previous = Some(call(verb.unwrap(), previous, args, step_span)?); - } + let previous = chain_steps(steps)?; let (args, end_verb, end_span) = step(end)?; match end_verb.as_deref() { None => give(previous, args, span(node)), - Some("넣다") => put(previous, args, span(node)), Some(_) => Ok(StatementKind::Call(call( end_verb.unwrap(), previous, @@ -611,6 +600,16 @@ fn chain(node: &TreeNode) -> Result { } } +/// The calls of the `-아/어서` steps, each one the first argument of the next: the last one, +/// `None` without steps +fn chain_steps(steps: Vec) -> Result, PostParseError> { + let mut previous = None; + for (args, verb, step_span) in steps { + previous = Some(call(verb.unwrap(), previous, args, step_span)?); + } + Ok(previous) +} + /// The arguments, the verb and the source of each step type Step = (Vec<(Arg, Span)>, Option, Span); @@ -625,7 +624,8 @@ fn step_list(node: &TreeNode) -> Result, PostParseError> { } /// The arguments, the verb and the source of a step; the verb is `None` for 반환해요 -/// LinkVerb → VERB-서 | Name VERB-서 (`printf해서`), EndVerb → VERB-요 | Name VERB-요 | 반환해요 +/// LinkVerb → VERB-서 | Name VERB-서 (`printf해서`), EndVerb → VERB-요 | Name VERB-요 | 반환해요, +/// AdnominalVerb → VERB-ㄴ | Name VERB-ㄴ (`printf한`) fn step(node: &TreeNode) -> Result { let (args, verb_node) = match branch(node).1 { [args, verb_node] => (arguments(args)?, verb_node), @@ -688,36 +688,6 @@ fn give( Ok(StatementKind::Return(value)) } -/// `X를 Y에 넣어요`, or `… 해서 Y에 넣어요` that puts the result of the chain. The error is on -/// the argument that is none of them, or one of them twice; a missing one makes the whole chain -/// (`chain_span`) the error -fn put( - previous: Option, - args: Vec<(Arg, Span)>, - chain_span: Span, -) -> Result { - let error = |span| PostParseError::new(PostParseErrorKind::PutArguments, span); - let mut target = None; - let mut value = previous; - for (arg, arg_span) in args { - match arg { - Arg::Value( - Expr { - kind: ExprKind::Name(name), - .. - }, - Particle::In, - ) if target.is_none() => target = Some(name), - Arg::Value(object, Particle::Object) if value.is_none() => value = Some(object), - _ => return Err(error(arg_span)), - } - } - let (Some(target), Some(value)) = (target, value) else { - return Err(error(chain_span)); - }; - Ok(StatementKind::Assign(Assign { target, value })) -} - /// Arguments → Argument | Arguments Argument /// Argument → Operand ArgumentParticle | TypeSpec 로 | TypeSpec Name 를 fn arguments(node: &TreeNode) -> Result, PostParseError> { diff --git a/src/parser/postparser/postparser_tests.rs b/src/parser/postparser/postparser_tests.rs index a0980b8..6004104 100644 --- a/src/parser/postparser/postparser_tests.rs +++ b/src/parser/postparser/postparser_tests.rs @@ -8,9 +8,7 @@ use super::super::cfg::parser::Parser; use super::super::cfg::rules::RULES; use super::post_parse_error::PostParseErrorKind; use super::postparser::convert_to_ast_tree; -use super::structs::{ - Argument, Assign, Expr, ExprKind, If, Program, Statement, StatementKind, Type, -}; +use super::structs::{Argument, Expr, ExprKind, If, Init, Program, Statement, StatementKind, Type}; /// Building the table takes seconds in debug: once for all the tests fn parser() -> &'static Parser { @@ -114,20 +112,48 @@ fn previous(call: &Expr) -> &Expr { #[test] fn call_spans_from_the_start_of_its_chain() { - let source = "외부 정수를 반환하는 더하다(정수 가, 정수 나)\n외부 정수를 반환하는 곱하다(정수 가, 정수 나)\n정수를 반환하는 main() {\n 결과는 0이에요.\n 3과 4를 더해서 5를 곱해서 결과에 넣어요.\n}\n"; + let source = "외부 정수를 반환하는 더하다(정수 가, 정수 나)\n외부 정수를 반환하는 곱하다(정수 가, 정수 나)\n정수를 반환하는 main() {\n 결과는 0이에요.\n 결과는 3과 4를 더해서 5를 곱한 값이에요.\n}\n"; let program = ast(source); let assign = &body(&program)[1]; assert_eq!( text(source, assign.span), - "3과 4를 더해서 5를 곱해서 결과에 넣어요." + "결과는 3과 4를 더해서 5를 곱한 값이에요." ); - let StatementKind::Assign(Assign { value, .. }) = &assign.kind else { - panic!("an assignment was expected"); + let StatementKind::Init(Init { value, .. }) = &assign.kind else { + panic!("a value was expected"); }; - assert_eq!(text(source, value.span), "3과 4를 더해서 5를 곱해서"); + assert_eq!(text(source, value.span), "3과 4를 더해서 5를 곱한"); assert_eq!(text(source, previous(value).span), "3과 4를 더해서"); } +#[test] +fn value_of_one_step_has_no_previous() { + let source = "외부 정수를 반환하는 더하다(정수 가, 정수 나)\n정수를 반환하는 main() {\n 결과는 3과 4를 더한 값이에요.\n 결과를 반환해요.\n}\n"; + let program = ast(source); + let StatementKind::Init(Init { value, .. }) = &body(&program)[0].kind else { + panic!("a value was expected"); + }; + let ExprKind::Call { verb, args } = &value.kind else { + panic!("a call was expected"); + }; + assert_eq!(verb, "더하다"); + assert_eq!(args.len(), 2); + assert!(!matches!(args[0], Argument::Previous(_))); +} + +#[test] +fn value_of_a_latin_function() { + let source = "외부 정수를 반환하는 printf(문자 주소 형식, …)\n정수를 반환하는 main() {\n 결과는 \"%ld\\n\"과 42를 printf한 값이에요.\n 결과를 반환해요.\n}\n"; + let program = ast(source); + let StatementKind::Init(Init { value, .. }) = &body(&program)[0].kind else { + panic!("a value was expected"); + }; + let ExprKind::Call { verb, .. } = &value.kind else { + panic!("a call was expected"); + }; + assert_eq!(verb, "printf"); +} + #[test] fn not_spans_its_operand() { let source = "정수를 반환하는 main() {\n 가는 0이에요.\n 만약 (가 > 0)이 아니면 {\n 1을 반환해요.\n }\n 가를 반환해요.\n}\n"; @@ -207,21 +233,6 @@ fn give_without_object_particle_is_the_error() { assert_eq!(error(&source), (PostParseErrorKind::GiveArguments, "가에")); } -#[test] -fn put_without_target_is_an_error_on_the_chain() { - let source = in_main(" 1을 넣어요."); - assert_eq!( - error(&source), - (PostParseErrorKind::PutArguments, "1을 넣어요") - ); -} - -#[test] -fn second_target_of_put_is_the_error() { - let source = in_main(" 1을 가에 가에 넣어요."); - assert_eq!(error(&source), (PostParseErrorKind::PutArguments, "가에")); -} - #[test] fn count_without_until_is_an_error_on_its_arguments() { let source = in_main(" 가를 1부터 세면서 {\n }"); diff --git a/src/parser/postparser/structs.rs b/src/parser/postparser/structs.rs index b785273..8bc7f46 100644 --- a/src/parser/postparser/structs.rs +++ b/src/parser/postparser/structs.rs @@ -112,7 +112,6 @@ pub struct Statement { pub enum StatementKind { Declare(Declare), Init(Init), - Assign(Assign), /// A chain ending with `반환해요`: `(가 + 나)를 반환해요.` Return(Expr), /// A chain ending with any other verb, its result unused: `"%ld\n"과 결과를 printf해요.` @@ -132,7 +131,8 @@ pub struct Declare { pub ty: Type, } -/// `결과는 0이에요.`, `고정된 끝은 10이에요.`, `합은 3과 4를 더한 값이에요.` +/// `결과는 0이에요.`, `고정된 끝은 10이에요.`, `합은 3과 4를 더한 값이에요.`; the converter makes it a +/// reassignment when `name` is already declared pub struct Init { pub name: String, pub value: Expr, @@ -140,12 +140,6 @@ pub struct Init { pub constant: bool, } -/// A chain ending with `넣어요`: `3과 4를 더해서 결과에 넣어요.` -pub struct Assign { - pub target: String, - pub value: Expr, -} - /// `만약 COND면 { … } 아니면 { … }`; `아니면 만약` is an `If` alone in `otherwise` pub struct If { pub condition: Expr, diff --git a/src/parser/preparser/pre_parser.rs b/src/parser/preparser/pre_parser.rs index 2c9789b..1f5a9dc 100644 --- a/src/parser/preparser/pre_parser.rs +++ b/src/parser/preparser/pre_parser.rs @@ -466,7 +466,7 @@ impl<'a> PreParser<'a> { } /// Whether the word after `prev` starts a statement: first word, after `{`, `}`, `.`, 고정된, - /// or after a statement that ended in 요 (반환해요, 넣어요, 이에요…) + /// or after a statement that ended in 요 (반환해요, 더해요, 이에요…) fn starts_a_statement(prev: Option<&ParserTokenKind>) -> bool { matches!( prev, diff --git a/src/parser/preparser/pre_parser_tests.rs b/src/parser/preparser/pre_parser_tests.rs index e0d3374..eb390eb 100644 --- a/src/parser/preparser/pre_parser_tests.rs +++ b/src/parser/preparser/pre_parser_tests.rs @@ -273,9 +273,15 @@ fn definition_with_or_without_return_type() { #[test] fn builtin_verbs() { - assert_eq!(pre("넣어요"), [verb("넣다", Ending::Yo)]); - assert_eq!(pre("넣어서"), [verb("넣다", Ending::Seo)]); + assert_eq!(pre("바꿔요"), [verb("바꾸다", Ending::Yo)]); assert_eq!(pre("바꿔서"), [verb("바꾸다", Ending::Seo)]); + assert_eq!(pre("바꾼"), [verb("바꾸다", Ending::Adnominal)]); +} + +#[test] +fn put_is_no_builtin_verb() { + // an assignment is written like a declaration: `가는 1이에요` + assert_eq!(unknown("가는 0이에요. 가에 1을 넣어요"), "넣어요"); } #[test] @@ -386,7 +392,7 @@ fn variable_at_the_start_of_any_statement() { assert_names("고정된 끝은 10이에요.", &["끝"]); assert_names("0을 반환해요 결과는 0이에요", &["결과"]); assert_names( - "결과는 0이에요. 결과에 0을 넣어요 수는 1이에요", + "결과는 0이에요. 결과를 소수로 바꿔요 수는 1이에요", &["결과", "수"], ); // after 이에요 without a `.` diff --git a/src/parser/preparser/words.rs b/src/parser/preparser/words.rs index 68889eb..fc15ac3 100644 --- a/src/parser/preparser/words.rs +++ b/src/parser/preparser/words.rs @@ -137,9 +137,9 @@ pub(super) fn is_name_particle(rest: &str) -> Option { .map(|(_, particle)| *particle) } -/// Built-in verbs used in several forms (넣어요, 넣어서); 반환하다 and 세다 only appear as the +/// Built-in verbs used in several forms (바꿔서, 바꾼); 반환하다 and 세다 only appear as the /// keywords 반환해요 and 세면서 -pub(super) const BUILTIN_VERBS: &[&str] = &["넣다", "바꾸다", "하다"]; +pub(super) const BUILTIN_VERBS: &[&str] = &["바꾸다", "하다"]; /// Every form of `infinitive` the pre-parser recognizes: 더하다 → 더하다, 더해서, 더해요, 더한, /// 더하고; None if it is not a verb (no final 다)