summaryrefslogtreecommitdiff
path: root/docs/chapter17b/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-04 13:30:41 -0700
commit3476d99690805b3ebe69219b326e5e1b64ebd0a4 (patch)
treecb05c136d87603d292c44ac4e5df38d8136f1872 /docs/chapter17b/17-grammar.md
parent9a5ca20d2537179f3a8e01762c8db6b52a4db2d9 (diff)
downloadSimple-linear-chapter17b.tar.gz
Simple-linear-chapter17b.zip
Chapter 17b: Syntax Sugarlinear-chapter17b
Diffstat (limited to 'docs/chapter17b/17-grammar.md')
-rw-r--r--docs/chapter17b/17-grammar.md22
1 files changed, 22 insertions, 0 deletions
diff --git a/docs/chapter17b/17-grammar.md b/docs/chapter17b/17-grammar.md
new file mode 100644
index 00000000..9a70f323
--- /dev/null
+++ b/docs/chapter17b/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.