You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/syntax.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,9 +41,9 @@ Literals can be:
41
41
42
42
***Integers:**`123`, `0x123`, `-0b00101`, `true`, `false`. There is no octal syntax. Literal numbers have no optional leading plus.
43
43
***Floats:**`1.0`, `-1.3f`, `2f`. Again, no leading plus.
44
-
***Strings:**`"The quick brown fox\njumped over the lazy dog"`. The control characters for strings are `\0`, `\n`, `\r`, `\\`, and `\"`.
44
+
***Strings:**`"The quick brown fox\njumped over the lazy dog"`. The control characters for strings are `\0`, `\n`, `\r`, `\\`, and `\"`.
45
45
46
-
Source text files for `truth`**must** be encoded in UTF-8. `truth` handles the conversion between the Shift-JIS encoding used in the binary files and the UTF-8 encoding used in source text. (in the future, you may even be able to configure which encoding is used in the binary files... but source text will always be UTF-8!)
46
+
Source text files for `truth`**must** be encoded in UTF-8. `truth` handles the conversion between the Shift-JIS encoding used in the binary files and the UTF-8 encoding used in source text. (in the future, you may even be able to configure which encoding is used in the binary files... but source text will always be UTF-8!)
47
47
48
48
### Variables
49
49
@@ -139,12 +139,12 @@ Other things present in expressions:
139
139
140
140
* The **ternary operator** `a ? b : c`. Right associative, [the way it should be](https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/#operators).
141
141
* **Unary negation** `-x`.
142
-
* **Special functions** `sin(x)` and `cos(x)`.
142
+
* **Special functions** `sin(x)` and `cos(x)`. Some languages support `acos`, `asin`, `tan`, and `sqrt`.
143
143
* **Logical right shift `>>>`**.
144
144
* All ints in truth are signed so `>>` is an arithmetic right shift (sign-extended) for consistency.
145
145
`>>>` is provided as a separate operator for doing logical right shifts (zero-extended).
146
146
* **Explicit casts** `_S` (float to int) and `_f` (int to float): `I0 = _S(F0);`
147
-
* That example is identical to `I0 = $F0`, but `_S` is also more generally usable in larger expressions where it may introduce a temporary
147
+
* That example is identical to `I0 = $F0`, but `_S` is also more generally usable in larger expressions where it may introduce a temporary
148
148
149
149
### Assignments
150
150
@@ -217,7 +217,7 @@ times(I2 = I0) {
217
217
```
218
218
219
219
#### About conditions
220
-
220
+
221
221
In the desugared form of `times()` above, you'll notice that there is a `while (--var)`. This `--var` is not an expression!
222
222
223
223
Basically, a **condition** can either be an expression `<expr>` or a predecrement operation `--<var>`. The latter compiles to a special kind of jump available in ANM and early ECL that decrements a variable and jumps if it is nonzero. (*every single `while` loop in vanilla ANM files uses this form of jump,* so the ability to decompile it seemed... kind of important!)
@@ -290,7 +290,7 @@ Notice that, unlike conditional blocks, *the conditional jump has no braces*; it
290
290
```C
291
291
// this compiles to a single instruction in anm
292
292
if (I0 != 0) goto else_label;
293
-
293
+
294
294
// this typically compiles to more than one instruction
295
295
if (I0 != 0) {
296
296
goto else_label;
@@ -317,7 +317,7 @@ However, this is generally obsolete. Normally, the only reason the game ever us
0 commit comments