summaryrefslogtreecommitdiff
path: root/docs/chapter17b/17-grammar.md
diff options
context:
space:
mode:
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.