|
2 | 2 | title = "december adventure 2025" |
3 | 3 | author = ["Nilay Kumar"] |
4 | 4 | date = 2025-12-08T00:00:00-05:00 |
5 | | -lastmod = 2025-12-21T17:46:28-05:00 |
| 5 | +lastmod = 2025-12-21T21:44:29-05:00 |
6 | 6 | tags = ["december-adventure", "code", "japanese", "chinese", "calligraphy", "photography"] |
7 | 7 | draft = false |
8 | 8 | progress = "in-progress" |
@@ -832,6 +832,9 @@ come back to this soon. |
832 | 832 |
|
833 | 833 | ## december 21 {#december-21} |
834 | 834 |
|
| 835 | + |
| 836 | +### sublabels and the return stack {#sublabels-and-the-return-stack} |
| 837 | + |
835 | 838 | Let's return to the `uxntal` code snippet for printing hex that we were looking at |
836 | 839 | on day 19: |
837 | 840 |
|
@@ -863,10 +866,30 @@ Very very clever: thanks to `d_m` on `irc` for helping me understand some of thi |
863 | 866 | was confused at first because I couldn't see how the print (`#18 DEO`) was getting |
864 | 867 | called 4 times, which would be necessary for printing the nibbles of a short. |
865 | 868 | What I hadn't understood is that the jumps to the sublabels here do more than |
866 | | -just move the program counter -- they also modify the working stack. In other |
| 869 | +just move the program counter -- they also modify the return stack. In other |
867 | 870 | words, `JMP2r` is not a simple `return`-from-`@subroutine`, the way I had been |
868 | 871 | conceptualizing it. |
869 | 872 |
|
| 873 | + |
| 874 | +### tree-sitter grammar for uxntal {#tree-sitter-grammar-for-uxntal} |
| 875 | + |
| 876 | +Small note here for myself: the tree-sitter grammar that I've been using (found |
| 877 | +[here](https://github.com/tree-sitter-grammars/tree-sitter-uxntal)) seems to be unfamiliar with the syntax of the anonymous label `?{ }`. The |
| 878 | +syntax tree for `?{ !print-hex-digit }`, for example, yields: |
| 879 | + |
| 880 | +```nil |
| 881 | +(rune |
| 882 | + rune_start: (rune_char immediate: ?) |
| 883 | + (ERROR {) |
| 884 | + (rune_char immediate: !) |
| 885 | + (identifier)) |
| 886 | + (ERROR }) |
| 887 | +``` |
| 888 | + |
| 889 | +Things are getting busy as the end of December approaches, so I don't know if |
| 890 | +I'll be able to get to it... but it would be great to learn enough about |
| 891 | +tree-sitter grammars to submit a patch. |
| 892 | + |
870 | 893 | --- |
871 | 894 |
|
872 | 895 | Down here I'm collecting the little project ideas that tend to pop into |
|
0 commit comments