diff options
Diffstat (limited to 'chapter02/docs')
| -rw-r--r-- | chapter02/docs/02-grammar.ja.md | 47 | ||||
| -rw-r--r-- | chapter02/docs/02-grammar.md | 4 |
2 files changed, 50 insertions, 1 deletions
diff --git a/chapter02/docs/02-grammar.ja.md b/chapter02/docs/02-grammar.ja.md new file mode 100644 index 00000000..c08359e3 --- /dev/null +++ b/chapter02/docs/02-grammar.ja.md @@ -0,0 +1,47 @@ +# 第2章の文法 + +[English](02-grammar.md) | 日本語 + +この文書は [第2章の文法定義](02-grammar.md) の日本語版です。 +文法定義そのものは原文と同一です。 + +[第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..994a398a 100644 --- a/chapter02/docs/02-grammar.md +++ b/chapter02/docs/02-grammar.md @@ -1,4 +1,6 @@ -# Grammar for Chapter 1 +# Grammar for Chapter 2 + +English | [日本語](02-grammar.ja.md) ```antlrv4 grammar SimpleLanguage; |
