diff options
| author | Jun Kawasaki <jun784@gmail.com> | 2026-10-06 13:01:11 +0900 |
|---|---|---|
| committer | Jun Kawasaki <jun784@gmail.com> | 2026-10-06 13:01:11 +0900 |
| commit | 863a6ed0ad723e06c76f392d4fb3a5f6bd22863c (patch) | |
| tree | cb0c42e19afbd06c455e977fa05980042da2e1d7 /chapter09/docs | |
| parent | 81b654d76444d747fdf1d053760e507b50f26e18 (diff) | |
| download | Simple-863a6ed0ad723e06c76f392d4fb3a5f6bd22863c.tar.gz Simple-863a6ed0ad723e06c76f392d4fb3a5f6bd22863c.zip | |
docs: add Japanese translations for all chapters
Diffstat (limited to 'chapter09/docs')
| -rw-r--r-- | chapter09/docs/09-grammar.ja.md | 103 | ||||
| -rw-r--r-- | chapter09/docs/09-grammar.md | 2 |
2 files changed, 105 insertions, 0 deletions
diff --git a/chapter09/docs/09-grammar.ja.md b/chapter09/docs/09-grammar.ja.md new file mode 100644 index 00000000..f89b449b --- /dev/null +++ b/chapter09/docs/09-grammar.ja.md @@ -0,0 +1,103 @@ +# 第9章の文法 + +[English](09-grammar.md) | 日本語 + +この文書は [原文](09-grammar.md) の日本語訳です。 + +> 訳注: 原文の見出しは「Grammar for Chapter 8」ですが、このファイルは第9章に属するため、訳の見出しは第9章としています。文法は原文のまま保持しています。 + + +[第9章に戻る](../README.ja.md) + +```antlrv4 +grammar SimpleLanguage; + +program + : statement+ EOF + ; + +statement + : returnStatement + | declStatement + | blockStatment + | expressionStatement + | ifStatement + | whileStatement + | breakStatement + | continueStatment + ; + +whileStatement + : 'while' '(' expression ')' statement + ; + +breakStatement + : 'break' ';' + ; + +continueStatement + : 'continue' ';' + ; + +ifStatement + : 'if' '(' expression ')' statement ('else' statement)? + ; + + +expressionStatement + : IDENTIFIER '=' expression ';' + ; + +blockStatement + : '{' statement+ '}' + ; + +declStatement + : 'int' IDENTIFIER '=' expression ';' + ; + +returnStatement + : 'return' expression ';' + ; + +expression + : comparisonExpression + ; + +comparisonExpression + : additiveExpression (('==' | '!='| '>'| '<'| '>='| '<=') additiveExpression)* + ; + +additiveExpression + : multiplicativeExpression (('+' | '-') multiplicativeExpression)* + ; + +multiplicativeExpression + : unaryExpression (('*' | '/') unaryExpression)* + ; + +unaryExpression + : ('-') unaryExpression + | primaryExpression + ; + +primaryExpression + : IDENTIFIER + | INTEGER_LITERAL + | 'true' + | 'false' + | '(' expression ')' + ; + +INTEGER_LITERAL + : [1-9][0-9]* + | [0] + ; + +IDENTIFIER + : NON_DIGIT (NON_DIGIT | DIGIT)* + ; + +NON_DIGIT: [a-zA-Z_]; +DEC_DIGIT: [0-9]; +``` diff --git a/chapter09/docs/09-grammar.md b/chapter09/docs/09-grammar.md index 00f93e04..5f6d5209 100644 --- a/chapter09/docs/09-grammar.md +++ b/chapter09/docs/09-grammar.md @@ -1,5 +1,7 @@ # Grammar for Chapter 8 +English | [日本語](09-grammar.ja.md) + ```antlrv4 grammar SimpleLanguage; |
