From 22df891893d30e9906d0b14fc3ae5d8e67d500b2 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Sat, 3 Oct 2026 14:03:48 -0700 Subject: 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 --- chapter17b/docs/17-grammar.md | 22 ++++++++++++++++++++++ chapter17b/docs/Makefile | 12 ++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 chapter17b/docs/17-grammar.md create mode 100644 chapter17b/docs/Makefile (limited to 'chapter17b/docs') 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. diff --git a/chapter17b/docs/Makefile b/chapter17b/docs/Makefile new file mode 100644 index 00000000..12659b8f --- /dev/null +++ b/chapter17b/docs/Makefile @@ -0,0 +1,12 @@ +GV := $(wildcard *.gv) +SVG := $(patsubst %.gv,%.svg,$(GV)) + +.PHONY: all +all: $(SVG) + +%.svg: %.gv + dot -Tsvg $< > $@ + +.PHONY: clean +clean: + @rm -f $(SVG) -- cgit v1.2.3