Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| creating:start [2025/03/24 19:28] – Wrote Getting Started blurb and linked to syntax parsing page ahelwer | creating:start [2025/08/29 17:21] (current) – Added note about TLA+ Foundation support ahelwer | ||
|---|---|---|---|
| Line 19: | Line 19: | ||
| And, if you reach the edge of those capabilities - well, you're well-placed to extend TLC to handle it! | And, if you reach the edge of those capabilities - well, you're well-placed to extend TLC to handle it! | ||
| - | ===== Getting Started | + | This guide was written with the generous support of the [[https:// |
| + | |||
| + | ===== Table of Contents ===== | ||
| + | |||
| + | - [[creating: | ||
| + | - [[creating: | ||
| + | - [[creating: | ||
| + | - [[creating: | ||
| + | - [[creating: | ||
| + | - [[creating: | ||
| + | - [[creating: | ||
| + | - [[creating: | ||
| + | - [[creating: | ||
| + | - [[creating: | ||
| + | |||
| + | ===== Overview | ||
| This tutorial uses Java. | This tutorial uses Java. | ||
| There are two good reasons for this: | There are two good reasons for this: | ||
| - At time of writing, [[codebase: | - At time of writing, [[codebase: | ||
| - | - The high-quality free online textbook [[https:// | + | - The high-quality free online textbook |
| You will need to install the [[https:// | You will need to install the [[https:// | ||
| - | While all code artifacts can be produced entirely by reading this tutorial, if you get out of sync you can find working implementations in [[https:// | + | This tutorial requires Java 21 or higher, for the Java 17 [[https:// |
| + | While all code artifacts can be produced entirely by reading this tutorial, if you get out of sync you can find working implementations in [[https:// | ||
| The tutorial has you construct the TLA⁺ tools from the bottom up. | The tutorial has you construct the TLA⁺ tools from the bottom up. | ||
| Line 34: | Line 50: | ||
| A minimal subset of the TLA⁺ language is used; users are encouraged to extend their tools to handle additional TLA⁺ syntax as desired. | A minimal subset of the TLA⁺ language is used; users are encouraged to extend their tools to handle additional TLA⁺ syntax as desired. | ||
| - | To begin the tutorial, start at page [[creating:syntax|Parsing | + | ===== The Language ===== |
| + | |||
| + | TLA⁺ is a large, complicated, | ||
| + | This is assisted by [[https:// | ||
| + | This tutorial only uses a minimal subset of TLA⁺ syntax, enough to handle [[https:// | ||
| + | While that may seem limiting, this tutorial tries to focus on the difficult & interesting parts of bringing TLA⁺ to life instead of more mundane drudgework like handling all hundred-some user-definable operator symbols. | ||
| + | You are encouraged to extend this minimal core as you wish; language tooling is best developed incrementally! | ||
| + | Slowly filling in the details of this rough language sketch has a satisfying meditative aspect. | ||
| + | |||
| + | Here is what our minimal language subset includes: | ||
| + | * Whole natural numbers like '' | ||
| + | * Boolean values '' | ||
| + | * Finite set literals, like '' | ||
| + | * Parentheses for expression grouping | ||
| + | * '' | ||
| + | * Single-line comments like '' | ||
| + | * The '' | ||
| + | * Some infix operators: '' | ||
| + | * The variable-priming suffix operator | ||
| + | * Quantification over sets with '' | ||
| + | * Function construction and application, | ||
| + | * Named operator definitions like '' | ||
| + | * Declaration of '' | ||
| + | * Vertically-aligned conjunction & disjunction lists | ||
| + | |||
| + | Notably, we do not use the familiar '' | ||
| + | Files simply consist of a series of unit-level TLA⁺ definitions. | ||
| + | We also do not leave room for a separate model configuration file; all '' | ||
| + | |||
| + | As outlined above, you are free to add missing features (or even your own invented features!) as you wish. | ||
| + | Each chapter ends with a set of challenges that often involve adding these missing features. | ||
| + | |||
| + | ===== Getting Started ===== | ||
| + | |||
| + | Read part I (the first three chapters) of free online textbook // | ||
| + | We will be closely following the material in this book, modifying it to our uses. | ||
| + | The first two chapters are a nice introduction and overview of language implementation generally. | ||
| + | Chapter three specifies a toy language called Lox, to be used as an object of study for the remainder of the book. | ||
| + | Our minimal TLA⁺ subset has some similarity to Lox with regard to expressions involving integers and booleans, but also differences - you can skip the section on closures (unless you want to implement higher-order operator parameters yourself) and the section on classes. | ||
| + | What's important is that it's similar enough for all the fundamentals to still apply! | ||
| + | |||
| + | Code snippets are shown often in this tutorial. | ||
| + | When a snippet is similar to code given in the book with the exception of a few lines, the differing lines will be highlighted. | ||
| + | For example: | ||
| + | <code java [highlight_lines_extra=" | ||
| + | private char advance() { | ||
| + | column++; | ||
| + | return source.charAt(current++); | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | Highlighting is also used to identify //new// code being added to a large section of code given previously, with line numbers and surrounding lines included for context. | ||
| + | For example: | ||
| + | <code java [enable_line_numbers=" | ||
| + | case ' | ||
| + | column = 0; | ||
| + | line++; | ||
| + | break; | ||
| + | </ | ||
| + | |||
| + | Sometimes the code given here is so different from that provided by the book that highlighting is simply ommitted to reduce visual noise. | ||
| + | A parenthetical will specify the meaning of highlighted code when ambiguous. | ||
| + | |||
| + | To begin the tutorial, start at page [[creating:scanning|Scanning | ||
| + | |||
| + | [[creating: | ||