summaryrefslogtreecommitdiff
path: root/chapter02/docs
diff options
context:
space:
mode:
authorJun Kawasaki <jun784@gmail.com>2026-10-06 13:01:11 +0900
committerJun Kawasaki <jun784@gmail.com>2026-10-06 13:01:11 +0900
commit863a6ed0ad723e06c76f392d4fb3a5f6bd22863c (patch)
treecb0c42e19afbd06c455e977fa05980042da2e1d7 /chapter02/docs
parent81b654d76444d747fdf1d053760e507b50f26e18 (diff)
downloadSimple-863a6ed0ad723e06c76f392d4fb3a5f6bd22863c.tar.gz
Simple-863a6ed0ad723e06c76f392d4fb3a5f6bd22863c.zip
docs: add Japanese translations for all chapters
Diffstat (limited to 'chapter02/docs')
-rw-r--r--chapter02/docs/02-grammar.ja.md48
-rw-r--r--chapter02/docs/02-grammar.md2
2 files changed, 50 insertions, 0 deletions
diff --git a/chapter02/docs/02-grammar.ja.md b/chapter02/docs/02-grammar.ja.md
new file mode 100644
index 00000000..4a36b68e
--- /dev/null
+++ b/chapter02/docs/02-grammar.ja.md
@@ -0,0 +1,48 @@
+# 第2章の文法
+
+[English](02-grammar.md) | 日本語
+
+この文書は [第2章の文法定義](02-grammar.md) の日本語版です。
+文法定義そのものは原文と同一です。原文の見出しは「Grammar for Chapter 1」ですが、
+このファイルは第2章の算術演算の文法を定義しているため、日本語版の見出しでは第2章としています。
+
+[第2章:算術演算に戻る](../README.ja.md)
+
+```antlrv4
+grammar SimpleLanguage;
+
+program
+ : statement EOF
+ ;
+
+statement
+ : 'return' expression ';'
+ ;
+
+expression
+ : additiveExpression
+ ;
+
+additiveExpression
+ : multiplicativeExpression (('+' | '-') multiplicativeExpression)*
+ ;
+
+multiplicativeExpression
+ : unaryExpression (('*' | '/') unaryExpression)*
+ ;
+
+unaryExpression
+ : ('-') unaryExpression
+ | primaryExpression
+ ;
+
+primaryExpression
+ : INTEGER_LITERAL
+ | '(' expression ')'
+ ;
+
+INTEGER_LITERAL
+ : [1-9][0-9]*
+ | [0]
+ ;
+```
diff --git a/chapter02/docs/02-grammar.md b/chapter02/docs/02-grammar.md
index ce875eda..762bed5d 100644
--- a/chapter02/docs/02-grammar.md
+++ b/chapter02/docs/02-grammar.md
@@ -1,5 +1,7 @@
# Grammar for Chapter 1
+English | [日本語](02-grammar.ja.md)
+
```antlrv4
grammar SimpleLanguage;