From 83b7cc03855a9bfa486ef0ec6e1a798834155da1 Mon Sep 17 00:00:00 2001 From: Konstantin Nazarov Date: Thu, 12 Sep 2024 00:12:15 +0100 Subject: [PATCH] Publish a post about compiler error reporting & change links to own git forge --- README.md | 2 +- content/posts/a_fuzzy_laungher_i_use/note.md | 4 +- content/posts/dendrite_and_nix/note.md | 2 +- .../posts/element_x_new_matrix_app/note.md | 2 +- .../note.md | 2 +- .../note.md | 2 +- content/posts/how_and_why_i_use_nixos/note.md | 2 +- .../posts/i_now_host_my_own_videos/note.md | 2 +- .../note.md | 49 +++++++++++++++++++ .../posts/simple_dynamic_language_vm/note.md | 2 +- content/posts/valeri_now_has_a_repl/note.md | 2 +- .../posts/valeri_repl_became_useful/note.md | 2 +- .../virtual_machine_debugging_gdb/note.md | 2 - .../note.md | 2 +- .../note.md | 2 +- .../note.md | 2 +- .../note.md | 2 +- .../note.md | 2 +- .../note.md | 2 +- .../note.md | 2 +- .../yubikey_for_personal_security/note.md | 2 +- 21 files changed, 69 insertions(+), 22 deletions(-) create mode 100644 content/posts/reporting_errors_from_the_compilation_phase/note.md diff --git a/README.md b/README.md index 2e370ea..d1ed20c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # My personal website This is source code for [knazarov.com](https://knazarov.com), my personal website. -It is written mostly in bash, and uses [markdown.awk](https://git.sr.ht/~knazarov/markdown.awk) to convert +It is written mostly in bash, and uses [markdown.awk](https://git.knazarov.com/knazarov/markdown.awk) to convert markdown posts and pages to HTML. The site has very minimal CSS (about 110 lines) that should be enough to display fine in most browsers diff --git a/content/posts/a_fuzzy_laungher_i_use/note.md b/content/posts/a_fuzzy_laungher_i_use/note.md index b86fa62..56d0a63 100644 --- a/content/posts/a_fuzzy_laungher_i_use/note.md +++ b/content/posts/a_fuzzy_laungher_i_use/note.md @@ -3,7 +3,7 @@ X-Note-Id: 19a3f09f-467c-4ba5-ba58-fd954cd931ea Subject: A fuzzy launcher I use for the last 2 years X-Slug: a_fuzzy_launcher_i_use -About 2 years ago, I decided to write [my own launcher](https://git.sr.ht/~knazarov/q.sh). +About 2 years ago, I decided to write [my own launcher](https://git.knazarov.com/knazarov/q.sh). It's been originally for [Yabai](https://github.com/koekeishiya/yabai) WM, which is a tiling WM for the mac. I wrote it because at the time there were no satisfactory replacements to dmenu/rofi that suited my personal needs. Right now I use it with Linux, because it's fully portable. @@ -28,4 +28,4 @@ To be fair, some other people have come to roughly the same idea. See [sway-launcher-desktop](https://github.com/Biont/sway-launcher-desktop) for example. I just don't think that other people went as far as to add prefix commands and extensibility. -If you want to read through the code, you can find it [here](https://git.sr.ht/~knazarov/q.sh). +If you want to read through the code, you can find it [here](https://git.knazarov.com/knazarov/q.sh). diff --git a/content/posts/dendrite_and_nix/note.md b/content/posts/dendrite_and_nix/note.md index 0d1ef74..42b86a2 100644 --- a/content/posts/dendrite_and_nix/note.md +++ b/content/posts/dendrite_and_nix/note.md @@ -21,7 +21,7 @@ all the basic options may be hard for NixOS novices. So if for some reason you c feel free to peruse. Note that nixpkgs tend to evolve, and it may stop working for you if you're reading this a long time after the post has been -made. Hopefully, by that time my Nix configuration will be available at [git.sr.ht/~knazarov](https://git.sr.ht/~knazarov/). +made. Refer to the latest configuration in [git.knazarov.com/knazarov/nixos](https://git.knazarov.com/knazarov/nixos). ``` { config, pkgs, ... }: diff --git a/content/posts/element_x_new_matrix_app/note.md b/content/posts/element_x_new_matrix_app/note.md index 9f32ed9..cd879c5 100644 --- a/content/posts/element_x_new_matrix_app/note.md +++ b/content/posts/element_x_new_matrix_app/note.md @@ -17,7 +17,7 @@ rewrite that has lots of things implemented natively, and which shares those nat The common part now lives in the [Rust SDK](https://github.com/matrix-org/matrix-rust-sdk), that would be a reference implementation of the client from now on. -I've configured the new sliding-sync [on my server](https://git.sr.ht/~knazarov/nixos/tree/master/item/nodes/knazarovcom/configuration.nix) +I've configured the new sliding-sync [on my server](https://git.knazarov.com/knazarov/nixos/src/branch/master/nodes/knazarovcom/configuration.nix) and Element X connected to it without any major issues (except maybe slow initial history sync). The app feels a lot snappier overall. diff --git a/content/posts/error_reporting_and_syntax_objects/note.md b/content/posts/error_reporting_and_syntax_objects/note.md index 7e27222..9549917 100644 --- a/content/posts/error_reporting_and_syntax_objects/note.md +++ b/content/posts/error_reporting_and_syntax_objects/note.md @@ -36,7 +36,7 @@ lexical scope, source code location, or any other custom metadata. You can "pack syntax objects if you want to really fiddle with a low-level representation. Scheme also uses syntax objects for hygienic macro system, but that's out of scope for me right now. -Since I want [Valeri](https://git.sr.ht/~knazarov/valeri) to be friendly, I've taken a stab +Since I want [Valeri](https://git.knazarov.com/knazarov/valeri) to be friendly, I've taken a stab at implementing syntax objects. To play with them in the REPL, you can do as follows: ``` diff --git a/content/posts/first_real_program_compiled_with_valeri/note.md b/content/posts/first_real_program_compiled_with_valeri/note.md index cb502fd..d6efca7 100644 --- a/content/posts/first_real_program_compiled_with_valeri/note.md +++ b/content/posts/first_real_program_compiled_with_valeri/note.md @@ -3,7 +3,7 @@ X-Note-Id: 175bdac4-8655-4b75-8205-f44b7311daa0 Subject: First real program compiled with Valeri X-Slug: first_real_program_compiled_with_valeri -I've reached my first significant milestone with [Valeri](https://git.sr.ht/~knazarov/valeri). +I've reached my first significant milestone with [Valeri](https://git.knazarov.com/knazarov/valeri). It can now compile something useful to bytecode and then execute it in the virtual machine. As an example, I've implemented a simple recursive factorial function: diff --git a/content/posts/how_and_why_i_use_nixos/note.md b/content/posts/how_and_why_i_use_nixos/note.md index c37b152..9b8e280 100644 --- a/content/posts/how_and_why_i_use_nixos/note.md +++ b/content/posts/how_and_why_i_use_nixos/note.md @@ -75,4 +75,4 @@ It reads almost plain English, doesn't it? This is due to most of the existing s And best of all, NixOS has good integration with [sops](https://github.com/getsops/sops) that allows you to store secrets in an encrypted form in a git repository, and easily reference them in the configuration. -If you're interested, my NixOS configuration can be found [here](https://git.sr.ht/~knazarov/nixos). +If you're interested, my NixOS configuration can be found [here](https://git.knazarov.com/knazarov/nixos). diff --git a/content/posts/i_now_host_my_own_videos/note.md b/content/posts/i_now_host_my_own_videos/note.md index c2d2ed8..8152a0e 100644 --- a/content/posts/i_now_host_my_own_videos/note.md +++ b/content/posts/i_now_host_my_own_videos/note.md @@ -6,7 +6,7 @@ X-Slug: i_now_host_my_own_videos Today I've launched a separate server that contains my own PeerTube instance: [videos.knazarov.com](https://videos.knazarov.com). All videos that I produce will be mirrored there, because I care about giving people an alternative to centralized platforms. -If you're curious how this is set up, here's [a link to the configuration repo](https://git.sr.ht/~knazarov/nixos/tree/master/item/nodes/videos/configuration.nix). +If you're curious how this is set up, here's [a link to the configuration repo](https://git.knazarov.com/knazarov/nixos/src/branch/master/nodes/videos/configuration.nix). The most interesting part that's not mentioned in the [official wiki article](https://nixos.wiki/wiki/PeerTube) on NixOS is the security. The way the article does this will keep the world-readable plain-text passwords in the configuration on the filesystem. My approach is to use SOPS and use a principle of minimal access permissions, and as such I've figured out how diff --git a/content/posts/reporting_errors_from_the_compilation_phase/note.md b/content/posts/reporting_errors_from_the_compilation_phase/note.md new file mode 100644 index 0000000..1fa214a --- /dev/null +++ b/content/posts/reporting_errors_from_the_compilation_phase/note.md @@ -0,0 +1,49 @@ +X-Date: 2024-09-11T22:46:56Z +X-Note-Id: 430f7fd9-a6fc-4250-977d-bd15846a4e6a +Subject: Reporting errors from the compilation phase +X-Slug: reporting_errors_from_the_compilation_phase + +Latest changes to [Valeri](https://git.knazarov.com/knazarov/valeri) have introduced +significant improvements to error reporting, not only within the parser, but also +within the compiler. Where previously the compiler will error out with a cryptic +"compilation error", it now explains what went wrong and where. + +As an example, let's input an incorrect expression in the REPL: + +``` +valeri> (let (("x" 1)) x) +:1:8 Syntax error: Binding name must be a symbol +``` + +As you can see, it shows you that the error happened in `` at a specific +location, and that it is because you specified a variable binding that is not a +symbol. + +The same happens when you write the expression to the file, and call the file. +But additionally it will show you the filename: + +``` +./valeri error_report.vli +error_report.vli:1:8 Syntax error: Binding name must be a symbol +``` + +There aren't that many syntax errors that you can make in a real program, because +only special forms get this type of treatment (such as function definitions, conditions, +comparison, etc). But it's already quite a bit better than what you may find in other +Lisp flavors. For example, if you do this in Guile: + +``` +scheme@(guile-user)> (let (("x" 1)) x) +While compiling expression: +Syntax error: +unknown file:1:0: let: bad let in form (let (("x" 1)) x) +``` + +Alright, it is a "bad let", but why? I guess the poor error reporting in this case is +due to the fact that in Scheme a lot of basic operations like "let" are actually "lowered" +to more primitive things such as lambdas. And this lowering is performed by macros, and +not by special-purpose handlers in the compiler. + +I'm sure the error reporing will become 10x harder when I make it to implementing macros. +But as it stands right now, I'm happy with the current implementation for the purpose +of writing simple programs. diff --git a/content/posts/simple_dynamic_language_vm/note.md b/content/posts/simple_dynamic_language_vm/note.md index 8a7c8e6..791c5a2 100644 --- a/content/posts/simple_dynamic_language_vm/note.md +++ b/content/posts/simple_dynamic_language_vm/note.md @@ -89,4 +89,4 @@ So, how fast is this approach? In my preliminary tests, a simple loop from 1 to takes 0.7 seconds to complete. Which is plenty fast, considering that the VM implementation is naive and has never been seriously optimized. -The code for the experimental version can be found [here](https://git.sr.ht/~knazarov/lisp.experimental). +The code for the experimental version can be found [here](https://git.knazarov.com/knazarov/valeri). diff --git a/content/posts/valeri_now_has_a_repl/note.md b/content/posts/valeri_now_has_a_repl/note.md index 27cb4b3..ae80baf 100644 --- a/content/posts/valeri_now_has_a_repl/note.md +++ b/content/posts/valeri_now_has_a_repl/note.md @@ -3,7 +3,7 @@ X-Note-Id: 8bb59a7f-ed5e-4407-b703-d592746e5ca8 Subject: Valeri now has a REPL X-Slug: valeri_now_has_a_repl -If you run [Valeri](https://git.sr.ht/~knazarov/valeri) without any arguments, +If you run [Valeri](https://git.knazarov.com/knazarov/valeri) without any arguments, it now drops you into a REPL, where you can type something like this: ``` diff --git a/content/posts/valeri_repl_became_useful/note.md b/content/posts/valeri_repl_became_useful/note.md index 394668e..4651f18 100644 --- a/content/posts/valeri_repl_became_useful/note.md +++ b/content/posts/valeri_repl_became_useful/note.md @@ -3,7 +3,7 @@ X-Note-Id: b5ba6437-5fe2-4d01-8dc5-3efe8587e728 Subject: Valeri REPL became actually useful (and keeps state) X-Slug: valeri_repl_became_useful -[Valeri](https://git.sr.ht/~knazarov/valeri) REPL has progressed to a state where it can +[Valeri](https://git.knazarov.com/knazarov/valeri) REPL has progressed to a state where it can run multiple sequential statements that can refer to each other's variable and function bindings. A few examples: diff --git a/content/posts/virtual_machine_debugging_gdb/note.md b/content/posts/virtual_machine_debugging_gdb/note.md index 71f0a3e..8bf38cd 100644 --- a/content/posts/virtual_machine_debugging_gdb/note.md +++ b/content/posts/virtual_machine_debugging_gdb/note.md @@ -49,5 +49,3 @@ $3 = " ;; Immediate operations (64-bit signed int) ``` Now, this is much better! We can see that the `cursor` object represents a string, and contains assembly code. The `source prettyprint.py` here is an instruction to GDB to load my pretty-printer. - -The code of the pretty-printer is not yet fully complete, but you can find it here: [prettyprint.py](https://git.sr.ht/~knazarov/lisp.experimental/tree/master/item/prettyprint.py) diff --git a/content/posts/vm_progress_update_arena_asan_gcov/note.md b/content/posts/vm_progress_update_arena_asan_gcov/note.md index 2d4ac18..185995f 100644 --- a/content/posts/vm_progress_update_arena_asan_gcov/note.md +++ b/content/posts/vm_progress_update_arena_asan_gcov/note.md @@ -3,7 +3,7 @@ X-Note-Id: 4c9287dc-53f7-4a1d-8bd8-9edbff143200 Subject: VM progress update: flexible arena, ASAN and gcov X-Slug: vm_progress_update_arena_asan_gcov -This is another post in the series where I talk about what's new in the [virtual machine](https://git.sr.ht/~knazarov/lisp.experimental) +This is another post in the series where I talk about what's new in the [virtual machine](https://git.knazarov.com/knazarov/valeri) I'm working on. Today let's discuss memory allocation. In a typical garbage-collected language, the memory that is allocated for the language objects diff --git a/content/posts/vm_progress_update_arrays_and_function_calls/note.md b/content/posts/vm_progress_update_arrays_and_function_calls/note.md index b777166..d071f6d 100644 --- a/content/posts/vm_progress_update_arrays_and_function_calls/note.md +++ b/content/posts/vm_progress_update_arrays_and_function_calls/note.md @@ -116,4 +116,4 @@ After ironing out the basics, I would probably work on the dynamic linking and i a C FFI. This is needed to give the code executing in the virtual machine ability to call external functions (like filesystem access, network and others). -As usual, the experimental code can be found [here](https://git.sr.ht/~knazarov/lisp.experimental). +As usual, the experimental code can be found [here](https://git.knazarov.com/knazarov/valeri). diff --git a/content/posts/vm_progress_update_data_segment_and_constants/note.md b/content/posts/vm_progress_update_data_segment_and_constants/note.md index 36b3cb1..09427fd 100644 --- a/content/posts/vm_progress_update_data_segment_and_constants/note.md +++ b/content/posts/vm_progress_update_data_segment_and_constants/note.md @@ -3,7 +3,7 @@ X-Note-Id: 3a07c153-0d26-402e-b0b4-626dfdcf38fc Subject: VM progress update: data segment and constants X-Slug: vm_progress_update_data_segment_and_constants -Today I'd like to introduce another addition to the [virtual machine](https://git.sr.ht/~knazarov/lisp.experimental) +Today I'd like to introduce another addition to the [virtual machine](https://git.knazarov.com/knazarov/valeri) I'm working on: the data segment. Let's first take a look at why this is necessary. Here's a piece of assembly code that multiplies 2 by 2: diff --git a/content/posts/vm_progress_update_frozen_data_types/note.md b/content/posts/vm_progress_update_frozen_data_types/note.md index fe90315..96053bb 100644 --- a/content/posts/vm_progress_update_frozen_data_types/note.md +++ b/content/posts/vm_progress_update_frozen_data_types/note.md @@ -81,4 +81,4 @@ also be returned as a "frozen pointer", just with an adjusted offset from the st So far, I've implemented most of the required data structures, but haven't finished the access layer completely, so no transparent load/stores yet. Stay tuned for the updates. -The code for the experimental version can be found [here](https://git.sr.ht/~knazarov/lisp.experimental). +The code for the experimental version can be found [here](https://git.knazarov.com/knazarov/valeri). diff --git a/content/posts/vm_progress_update_simple_garbage_collection/note.md b/content/posts/vm_progress_update_simple_garbage_collection/note.md index 62d034e..bbb09ca 100644 --- a/content/posts/vm_progress_update_simple_garbage_collection/note.md +++ b/content/posts/vm_progress_update_simple_garbage_collection/note.md @@ -65,5 +65,5 @@ The API is in place, so the next step would be to add a few instructions to the that can call memory allocations, and write an inefficient merge sort (the one that would copy sub-ranges). -As usual, the code can be found [here](https://git.sr.ht/~knazarov/lisp.experimental) +As usual, the code can be found [here](https://git.knazarov.com/knazarov/valeri) (note that it's experimental, so don't expect any clarity). diff --git a/content/posts/why_rb_trees_instead_of_hash_tables/note.md b/content/posts/why_rb_trees_instead_of_hash_tables/note.md index 0361bcd..8d9f810 100644 --- a/content/posts/why_rb_trees_instead_of_hash_tables/note.md +++ b/content/posts/why_rb_trees_instead_of_hash_tables/note.md @@ -93,4 +93,4 @@ Resolving this problem took a bit of thinking, but eventually I've formulated th It seems to fit nicely into the whole idea of making the language simple, and doesn't require any custom implementation if you need to use your data structures as keys in dictionaries. Of course, using red-black trees is not without disadvantages: they are slower than hash tables, and would take more memory. But as of now, I feel that this is a good tradeoff to make. -At the time of writing this post, I've finished a simple implementation of a red-black tree in C, and plugged it into the dictionary implementation of my language. As usual, you can find the code [here](https://git.sr.ht/~knazarov/lisp.experimental). +At the time of writing this post, I've finished a simple implementation of a red-black tree in C, and plugged it into the dictionary implementation of my language. As usual, you can find the code [here](https://git.knazarov.com/knazarov/valeri). diff --git a/content/posts/writing_programming_languages_is_fun/note.md b/content/posts/writing_programming_languages_is_fun/note.md index 3b18c5a..bdb131e 100644 --- a/content/posts/writing_programming_languages_is_fun/note.md +++ b/content/posts/writing_programming_languages_is_fun/note.md @@ -42,4 +42,4 @@ If you need a practical guide, take a look at [Crafting Interpreters](https://cr If you look for inspiration, check out this video: [The most beautiful program ever written](https://www.youtube.com/watch?v=OyfBQmvr2Hc) -My own in-progress programming language can be found [here](https://git.sr.ht/~knazarov/lisp.experimental). +My own in-progress programming language can be found [here](https://git.knazarov.com/knazarov/valeri). diff --git a/content/posts/yubikey_for_personal_security/note.md b/content/posts/yubikey_for_personal_security/note.md index 9a9c3fa..ae84439 100644 --- a/content/posts/yubikey_for_personal_security/note.md +++ b/content/posts/yubikey_for_personal_security/note.md @@ -91,7 +91,7 @@ sops file-with-secrets.yaml SOPS has integrations with NixOS (which I care about the most), with Ansible (for provisioning servers), with AWS and other tools. It looks as if [Hashicorp Vault](https://www.hashicorp.com/products/vault) was reduced to a set of simple core principles. -If you're interested, [here are some of my personal passwords](https://git.sr.ht/~knazarov/nixos/tree/master/item/secrets.yaml) +If you're interested, [here are some of my personal passwords](https://git.knazarov.com/knazarov/nixos/src/branch/master/secrets.yaml) stored as a SOPS-encrypted file. It is also possible to use GPG for encrypting the passwords stored with [pass](https://www.passwordstore.org/) because it uses