summaryrefslogtreecommitdiff
path: root/chapter10/docs/10-grammar.md
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-09-29 12:34:58 -0700
committerCliff Click <cliffc@acm.org>2026-09-29 12:34:58 -0700
commit6347fa6dc2ee8d3060f2f0db21f03f11d374b0bc (patch)
tree6da4371d0ac6a0e17cfc31dad2275f1331ab3edb /chapter10/docs/10-grammar.md
parent41be002e89358649da46c33c8245aa786afdad6a (diff)
downloadSimple-6347fa6dc2ee8d3060f2f0db21f03f11d374b0bc.tar.gz
Simple-6347fa6dc2ee8d3060f2f0db21f03f11d374b0bc.zip
Squashed commit of the following:
commit 3ba6686fc991998a0a420709dfb0012bbddf77ab Author: Cliff Click <cliffc@acm.org> Date: Tue Sep 29 12:21:46 2026 -0700 Backport lazy memory splits to ch10, split into ch10a and b commit fa7d56f72455828826d0ab7e1c142ca814e6e2aa Author: Cliff Click <cliffc@acm.org> Date: Tue Sep 29 10:10:53 2026 -0700 Reverse edges commit e1bba17ff54400a34ede0eaacad863420d021119 Author: Cliff Click <cliffc@acm.org> Date: Tue Sep 29 09:44:41 2026 -0700 Split ch10 Basic memory introduction in 10a, then precise aliases in 10b.
Diffstat (limited to 'chapter10/docs/10-grammar.md')
-rw-r--r--chapter10/docs/10-grammar.md125
1 files changed, 0 insertions, 125 deletions
diff --git a/chapter10/docs/10-grammar.md b/chapter10/docs/10-grammar.md
deleted file mode 100644
index b76531d5..00000000
--- a/chapter10/docs/10-grammar.md
+++ /dev/null
@@ -1,125 +0,0 @@
-# Grammar for Chapter 10
-
-```antlrv4
-grammar SimpleLanguage;
-
-program
- : statement+ EOF
- ;
-
-statement
- : returnStatement
- | structDeclaration
- | declStatement
- | blockStatment
- | expressionStatement
- | ifStatement
- | whileStatement
- | breakStatement
- | continueStatment
- ;
-
-field
- : 'int' IDENTIFIER ';'
- ;
-
-fields
- : field+
- ;
-
-structDeclaration
- : 'struct' IDENTIFIER '{' fields '}'
- ;
-
-whileStatement
- : 'while' '(' expression ')' statement
- ;
-
-breakStatement
- : 'break' ';'
- ;
-
-continueStatement
- : 'continue' ';'
- ;
-
-ifStatement
- : 'if' '(' expression ')' statement ('else' statement)?
- ;
-
-
-expressionStatement
- : IDENTIFIER '=' expression ';'
- | fieldExpression '=' expression ';'
- ;
-
-blockStatement
- : '{' statement+ '}'
- ;
-
-structName
- : IDENTIFIER
- ;
-
-declStatement
- : 'int' IDENTIFIER '=' expression ';'
- | structName ('?')? IDENTIFIER '=' expression ';'
- ;
-
-returnStatement
- : 'return' expression ';'
- ;
-
-expression
- : comparisonExpression
- ;
-
-comparisonExpression
- : additiveExpression (('==' | '!='| '>'| '<'| '>='| '<=') additiveExpression)*
- ;
-
-additiveExpression
- : multiplicativeExpression (('+' | '-') multiplicativeExpression)*
- ;
-
-multiplicativeExpression
- : unaryExpression (('*' | '/') unaryExpression)*
- ;
-
-unaryExpression
- : ('-') unaryExpression
- | '!' unaryExpression
- | primaryExpression
- ;
-
-newExpression
- : 'new' IDENTIFIER
- ;
-
-fieldExpression
- : primaryExpresson '.' IDENTIFIER
- ;
-
-primaryExpression
- : IDENTIFIER
- | INTEGER_LITERAL
- | 'true'
- | 'false'
- | 'null'
- | newExpression
- | '(' expression ')'
- | fieldExpression
- ;
-
-INTEGER_LITERAL
- : [1-9][0-9]*
- | [0]
- ;
-
-IDENTIFIER
- : NON_DIGIT (NON_DIGIT | DIGIT)*
- ;
-
-NON_DIGIT: [a-zA-Z_];
-DEC_DIGIT: [0-9];
-```