diff options
Diffstat (limited to 'chapter06/docs')
| -rw-r--r-- | chapter06/docs/06-grammar.ja.md | 86 | ||||
| -rw-r--r-- | chapter06/docs/06-grammar.md | 81 |
2 files changed, 0 insertions, 167 deletions
diff --git a/chapter06/docs/06-grammar.ja.md b/chapter06/docs/06-grammar.ja.md deleted file mode 100644 index fba9379a..00000000 --- a/chapter06/docs/06-grammar.ja.md +++ /dev/null @@ -1,86 +0,0 @@ -# 第6章の文法 - -[English](06-grammar.md) | 日本語 - -この文書は [原文](06-grammar.md) の日本語訳です。 - - -[第6章に戻る](../README.ja.md) - -```antlrv4 -grammar SimpleLanguage; - -program - : statement+ EOF - ; - -statement - : returnStatement - | declStatement - | blockStatment - | expressionStatement - | ifStatement - ; - -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/chapter06/docs/06-grammar.md b/chapter06/docs/06-grammar.md deleted file mode 100644 index 2dbde035..00000000 --- a/chapter06/docs/06-grammar.md +++ /dev/null @@ -1,81 +0,0 @@ -# Grammar for Chapter 6 - -English | [日本語](06-grammar.ja.md) - -```antlrv4 -grammar SimpleLanguage; - -program - : statement+ EOF - ; - -statement - : returnStatement - | declStatement - | blockStatment - | expressionStatement - | ifStatement - ; - -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]; -``` |
