summaryrefslogtreecommitdiff
path: root/chapter17b/docs/17-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 /chapter17b/docs/17-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 'chapter17b/docs/17-grammar.md')
-rw-r--r--chapter17b/docs/17-grammar.md22
1 files changed, 22 insertions, 0 deletions
diff --git a/chapter17b/docs/17-grammar.md b/chapter17b/docs/17-grammar.md
new file mode 100644
index 00000000..9a70f323
--- /dev/null
+++ b/chapter17b/docs/17-grammar.md
@@ -0,0 +1,22 @@
+# Chapter 17b grammar additions
+
+Start with [Chapter 17a's declaration syntax](../../chapter17a/docs/17-grammar.md).
+This chapter adds inference, assignment shortcuts, conditional expressions, and
+`for` loops. Access and binding permissions keep the same meaning.
+
+```text
+inferredDeclaration = ("var" | "val") ("!" | "~")? identifier "=" assignment
+assignment = expression (assignmentOperator assignment)?
+assignmentOperator = "=" | "+=" | "-=" | "*=" | "/=" | "&=" | "|=" | "^="
+ | "<<=" | ">>=" | ">>>="
+expression = bitwise ("?" assignment (":" assignment)?)?
+prefixUpdate = ("++" | "--") identifier
+postfixUpdate = lvalue ("++" | "--")
+forStatement = "for" "(" declarationOrExpression? ";" assignment? ";"
+ assignment? ")" statement
+```
+
+Declarations can contain several comma-separated names. `var` permits
+reassignment and `val` fixes the binding; both retain the initializer's reference
+permissions. Postfix updates also support fields and array elements. Prefix
+updates currently support local names. See the README for evaluation order.