-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
零・二版新增了「若」、「術」兩語句,並增加了比較、餘數運算子。 | ||
|
||
## 運算子優先級語法定義 | ||
|
||
零・一版的算式語法如下: | ||
|
||
```語法 | ||
算式 = 乘除式・(+・乘除式)* | ||
| 乘除式・(-・乘除式)* | ||
乘除式 = 原子式・(*・原子式)* | ||
| 原子式・(/・原子式)* | ||
原子式 = 數字 | ||
| 變數 | ||
| "("・算式・")" | ||
``` | ||
|
||
為了區分**乘除**與**加減**以及括號的優先級,吾人生造了**乘除式**與**原子式**以讓剖析器自動以正確層級構造算式。 | ||
|
||
新增的比較、餘數運算子也可依照此法,再切分出更多運算子的語法: | ||
|
||
```語法 | ||
算式 = 加減式・(==・加減式)* | ||
| 加減式・(!=・加減式)* | ||
| 加減式・(>=・加減式)* | ||
| 加減式・(>・加減式)* | ||
| 加減式・(<=・加減式)* | ||
| 加減式・(<・加減式)* | ||
加減式 = 餘數式・(+・餘數式)* | ||
餘數式 = 乘除式・(%・乘除式)* | ||
乘除式 = 原子式・(*・原子式)* | ||
| 原子式・(/・原子式)* | ||
原子式 = 數字 | ||
| 變數 | ||
| "("・算式・")" | ||
``` | ||
|
||
### 特殊處理運算子優先級 | ||
|