summaryrefslogtreecommitdiff
path: root/chapter24/docs/18-grammar.md
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-10-07 09:53:15 -0700
committerCliff Click <cliffc@acm.org>2026-10-07 09:53:15 -0700
commitb2862f980f3d78012066ef1cc09d4ad58f886c0f (patch)
treebbeab7de6ac8b556911d117989ab4bbc0324ecb5 /chapter24/docs/18-grammar.md
parent863a6ed0ad723e06c76f392d4fb3a5f6bd22863c (diff)
downloadSimple-pr262-doc-followups.tar.gz
Simple-pr262-doc-followups.zip
Pick up japanese transaltionpr262-doc-followups
A bunch of minor README fixes, missing TOC, grammer cleanup
Diffstat (limited to 'chapter24/docs/18-grammar.md')
-rw-r--r--chapter24/docs/18-grammar.md132
1 files changed, 0 insertions, 132 deletions
diff --git a/chapter24/docs/18-grammar.md b/chapter24/docs/18-grammar.md
deleted file mode 100644
index 51539d0b..00000000
--- a/chapter24/docs/18-grammar.md
+++ /dev/null
@@ -1,132 +0,0 @@
-# Grammar for Chapter 16
-
-English | [日本語](18-grammar.ja.md)
-
-```antlrv4
-grammar SimpleLanguage;
-
-program : block EOF ;
-
-block : statement+ ;
-
-
-statement
- : '{' block '}'
- | returnStatement
- | ifStatement
- | whileStatement
- | breakStatement
- | continueStatement
- | structDeclaration
- | expressionStatement
- ;
-
-
-returnStatement : 'return' expression ';' ;
-
-ifStatement : 'if' '(' expression ')' statement ('else' statement)? ;
-
-whileStatement : 'while' '(' expression ')' statement ;
-
-breakStatement : 'break' ';' ;
-
-continueStatement : 'continue' ';' ;
-
-
-structDeclaration : 'struct' IDENTIFIER '{' block '}' ;
-
-expressionStatement
- : type IDENTIFIER ';'
- | type IDENTIFIER '=' expression ';'
- | IDENTIFIER '=' expression ';'
- | expression
- ;
-
-PRIMTYPE
- : 'int'
- | 'i8'
- | 'i16'
- | 'i32'
- | 'i64'
- | 'u8'
- | 'u16'
- | 'u32'
- | 'flt'
- | 'f32'
- | 'f64'
- | 'bool'
- ;
-
-type
- : PRIMTYPE
- | typeName '?'?
- | typeName nestedArray+
- ;
-
-nestedArray : '?'? '[]'* ;
-
-typeName : IDENTIFIER ;
-
-
-expression : bitWiseExpression ;
-
-bitWiseExpression
- : comparisonExpression ( '&' | '|' | '^' ) comparisonExpression)*
- ;
-
-comparisonExpression
- : shiftExpression (('==' | '!='| '>'| '<'| '>='| '<=') shiftExpression)*
- ;
-
-shiftExpression
- : additiveExpression ( '<<' | '>>>' | '>>' ) additiveExpression)*
- ;
-
-additiveExpression
- : multiplicativeExpression (('+' | '-') multiplicativeExpression)*
- ;
-
-multiplicativeExpression
- : unaryExpression (('*' | '/') unaryExpression)*
- ;
-
-unaryExpression
- : ('-') unaryExpression
- | '!' unaryExpression
- | primaryExpression postAssign
- ;
-
-primaryExpression
- : INTEGER_LITERAL
- | FLOAT_LITERAL
- | '(' expression ')'
- | 'true'
- | 'false'
- | 'null'
- | newExpression
- | IDENTIFIER
- ;
-
-newExpression
- : 'new' IDENTIFIER [ '{' block '}' ]
- | 'new' IDENTIFIER '[' expression ']'
- ;
-
-postAssign : postFix [ '=' expression ] | [ '#' ];
-
-postFix
- : '.' IDENTIFIER postFix
- | '[' expression ']' postFix
- ;
-
-
-IDENTIFIER : NON_DIGIT (NON_DIGIT | DIGIT)* ;
-
-INTEGER_LITERAL
- : [1-9]DIGIT*
- | [0]
- ;
-
-NON_DIGIT: [a-zA-Z_];
-DIGIT: [0-9];
-```