diff --git a/README.md b/README.md index f851255..8ad2b08 100644 --- a/README.md +++ b/README.md @@ -38,16 +38,11 @@ Variable can consist of lower-case letters, numbers, as well as `_`. Multiple variables can be assigned at once by unpacking an array or multi-return function: -``` -DEFINI pair (a, b) VT { REDI (a, b) } -DESIGNA x, y VT INVOCA pair (III, VII) -``` +![Destructuring function](snippets/destructure_fn.png) The number of targets must match the length of the array. This also works with array literals: -``` -DESIGNA a, b, c VT [I, II, III] -``` +![Destructuring array](snippets/destructure_array.png) ## Data types ### NVLLVS @@ -69,12 +64,7 @@ Strings are concatenated with `&`: Double-quoted strings support interpolation with `{expression}`: -``` -DESIGNA nomen VT "Marcus" -DICE("Salve, {nomen}!") // → Salve, Marcus! -DICE("Sum: {III + IV}") // → Sum: VII -DICE("{nomen} has {V} cats") // → Marcus has V cats -``` +![String interpolation](snippets/string_interp.png) Any expression can appear inside `{}`. Values are coerced to strings the same way as with `&` (integers become Roman numerals, booleans become `VERITAS`/`FALSITAS`, etc.). @@ -131,25 +121,15 @@ Individual elements can be accessed by index using square brackets. Indexing is Dicts are key-value maps created with the `TABVLA` keyword and curly braces: -``` -DESIGNA d VT TABVLA {"nomen" VT "Marcus", "aetas" VT XXV} -``` +![Dict creation](snippets/dict_create.png) Keys must be strings or integers. Values are accessed and assigned with square brackets: -``` -DICE(d["nomen"]) // → Marcus -DESIGNA d["aetas"] VT XXVI // update existing key -DESIGNA d["novus"] VT I // insert new key -``` +![Dict access](snippets/dict_access.png) Iterating over a dict with `PER` loops over its keys: -``` -PER k IN d FACE { - DICE(k) -} -``` +![Dict iteration](snippets/dict_per.png) `LONGITVDO(dict)` returns the number of entries. `CLAVES(dict)` returns the keys as an array. diff --git a/snippets/aeternvm.png b/snippets/aeternvm.png new file mode 100644 index 0000000..20f820f Binary files /dev/null and b/snippets/aeternvm.png differ diff --git a/snippets/array_vsqve.png b/snippets/array_vsqve.png index 56e098e..d80dc04 100644 Binary files a/snippets/array_vsqve.png and b/snippets/array_vsqve.png differ diff --git a/snippets/destructure_array.cent b/snippets/destructure_array.cent new file mode 100644 index 0000000..6661f2b --- /dev/null +++ b/snippets/destructure_array.cent @@ -0,0 +1 @@ +DESIGNA a, b, c VT [I, II, III] diff --git a/snippets/destructure_array.png b/snippets/destructure_array.png new file mode 100644 index 0000000..44b3494 Binary files /dev/null and b/snippets/destructure_array.png differ diff --git a/snippets/destructure_fn.cent b/snippets/destructure_fn.cent new file mode 100644 index 0000000..f3027d5 --- /dev/null +++ b/snippets/destructure_fn.cent @@ -0,0 +1,2 @@ +DEFINI pair (a, b) VT { REDI (a, b) } +DESIGNA x, y VT INVOCA pair (III, VII) diff --git a/snippets/destructure_fn.png b/snippets/destructure_fn.png new file mode 100644 index 0000000..987b1e9 Binary files /dev/null and b/snippets/destructure_fn.png differ diff --git a/snippets/dict_access.cent b/snippets/dict_access.cent new file mode 100644 index 0000000..da545cb --- /dev/null +++ b/snippets/dict_access.cent @@ -0,0 +1,3 @@ +DICE(d["nomen"]) +DESIGNA d["aetas"] VT XXVI +DESIGNA d["novus"] VT I diff --git a/snippets/dict_access.png b/snippets/dict_access.png new file mode 100644 index 0000000..0260d47 Binary files /dev/null and b/snippets/dict_access.png differ diff --git a/snippets/dict_create.cent b/snippets/dict_create.cent new file mode 100644 index 0000000..562516b --- /dev/null +++ b/snippets/dict_create.cent @@ -0,0 +1 @@ +DESIGNA d VT TABVLA {"nomen" VT "Marcus", "aetas" VT XXV} diff --git a/snippets/dict_create.png b/snippets/dict_create.png new file mode 100644 index 0000000..876fa81 Binary files /dev/null and b/snippets/dict_create.png differ diff --git a/snippets/dict_per.cent b/snippets/dict_per.cent new file mode 100644 index 0000000..0cf715a --- /dev/null +++ b/snippets/dict_per.cent @@ -0,0 +1,3 @@ +PER k IN d FACE { + DICE(k) +} diff --git a/snippets/dict_per.png b/snippets/dict_per.png new file mode 100644 index 0000000..b54dbbb Binary files /dev/null and b/snippets/dict_per.png differ diff --git a/snippets/donicvm.png b/snippets/donicvm.png index 42afcd3..e85cf58 100644 Binary files a/snippets/donicvm.png and b/snippets/donicvm.png differ diff --git a/snippets/string_interp.cent b/snippets/string_interp.cent new file mode 100644 index 0000000..3c5736a --- /dev/null +++ b/snippets/string_interp.cent @@ -0,0 +1,4 @@ +DESIGNA nomen VT "Marcus" +DICE("Salve, {nomen}!") +DICE("Sum: {III + IV}") +DICE("{nomen} has {V} cats") diff --git a/snippets/string_interp.png b/snippets/string_interp.png new file mode 100644 index 0000000..89669c7 Binary files /dev/null and b/snippets/string_interp.png differ diff --git a/snippets/syntaxes/centvrion.sublime-syntax b/snippets/syntaxes/centvrion.sublime-syntax index d74b0f8..a5cd68d 100644 --- a/snippets/syntaxes/centvrion.sublime-syntax +++ b/snippets/syntaxes/centvrion.sublime-syntax @@ -9,8 +9,8 @@ contexts: main: - include: comments - include: strings - - include: fractions - include: keywords + - include: fractions - include: numerals - include: constants - include: builtins