summaryrefslogtreecommitdiff
path: root/chapter10a/docs/10-grammar.md
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-10-03 14:03:48 -0700
committerCliff Click <cliffc@acm.org>2026-10-03 14:03:48 -0700
commit22df891893d30e9906d0b14fc3ae5d8e67d500b2 (patch)
tree2bda142f92febc8b26f1cabd4bb0c46d1864f34b /chapter10a/docs/10-grammar.md
parentc3958e34c0de21df52e57e47e4f47ffe6464f138 (diff)
downloadSimple-22df891893d30e9906d0b14fc3ae5d8e67d500b2.tar.gz
Simple-22df891893d30e9906d0b14fc3ae5d8e67d500b2.zip
Chapter renumber, and split ch 17
Renumber chapters 10a, 10b, 11, 12, 13, 14 -> 10, 11, 13, 12, [11,14]. Split ch 17 into a 17a and 17b; shuffle around im/mutable syntax to be consistent, and present it more slowly. THe new immutable syntax is pushed through all later chapters
Diffstat (limited to 'chapter10a/docs/10-grammar.md')
-rw-r--r--chapter10a/docs/10-grammar.md125
1 files changed, 0 insertions, 125 deletions
diff --git a/chapter10a/docs/10-grammar.md b/chapter10a/docs/10-grammar.md
deleted file mode 100644
index 5b9b680e..00000000
--- a/chapter10a/docs/10-grammar.md
+++ /dev/null
@@ -1,125 +0,0 @@
-# Grammar for Chapter 10a
-
-```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];
-```