#compilers — Public Fediverse posts
Live and recent posts from across the Fediverse tagged #compilers, aggregated by home.social.
-
RISC-V: They Should Have Known Better https://lobste.rs/s/pu3yzg #assembly #compilers
https://dmitry.gr/?r=06.%20Thoughts&proj=12.%20RV -
RISC-V: They Should Have Known Better https://lobste.rs/s/pu3yzg #assembly #compilers
https://dmitry.gr/?r=06.%20Thoughts&proj=12.%20RV -
RISC-V: They Should Have Known Better
https://fed.brid.gy/r/https://dmitry.gr/?r=06.%20Thoughts&proj=12.%20RV
-
Cylic trait implementations: motivation https://lobste.rs/s/zq9czz #compilers #plt #rust
https://smallcultfollowing.com/babysteps/blog/2026/08/10/cyclic-trait-solving/ -
Cylic trait implementations: motivation https://lobste.rs/s/zq9czz #compilers #plt #rust
https://smallcultfollowing.com/babysteps/blog/2026/08/10/cyclic-trait-solving/ -
Making a game on a custom bytecode VM in 7 days and 3kB via @abnv https://lobste.rs/s/he9kpd #compilers #games
https://laurent.le-brun.eu/blog/making-a-game-on-a-custom-bytecode-vm-in-7-days-and-3kb -
Making a game on a custom bytecode VM in 7 days and 3kB via @abnv https://lobste.rs/s/he9kpd #compilers #games
https://laurent.le-brun.eu/blog/making-a-game-on-a-custom-bytecode-vm-in-7-days-and-3kb -
A wild #blog post appears!
I discuss a new #research publication: an empirical evaluation of the #OpenBSD -fret-clean flag. We examine the history of the mitigation, measure its costs, and deliberate whether or not it is worth keeping.
Worth the read if you like security and/or compilers.
https://briancallahan.net/blog/20260811.html
#freebsd #netbsd #dragonflybsd #bsd #linux #unix #solaris #illumos #compiler #compilers #llvm #gcc #rop #cybersecurity #cybersec #cyber #security #infosec #informationsecurity
-
A wild #blog post appears!
I discuss a new #research publication: an empirical evaluation of the #OpenBSD -fret-clean flag. We examine the history of the mitigation, measure its costs, and deliberate whether or not it is worth keeping.
Worth the read if you like security and/or compilers.
https://briancallahan.net/blog/20260811.html
#freebsd #netbsd #dragonflybsd #bsd #linux #unix #solaris #illumos #compiler #compilers #llvm #gcc #rop #cybersecurity #cybersec #cyber #security #infosec #informationsecurity
-
REpsych: Psychological warfare in reverse engineering https://lobste.rs/s/ufvii3 #compilers
https://github.com/xoreaxeaxeax/repsych -
REpsych: Psychological warfare in reverse engineering https://lobste.rs/s/ufvii3 #compilers
https://github.com/xoreaxeaxeax/repsych -
Make compiler change
#Fuzix NS8070 kernel breaks
Add debug - fixes it
Revert compiler change - fixes it
Review changes about ten times - no bug
Diff asm sources - no apparent bug in the differencesSpend ages wading through an instruction trace. Turns out the compiler change made the code shorter, moved a table lower in memory and triggered an existing unrelated bug in the NS8070 asm for the memory management.
Arghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
-
Make compiler change
#Fuzix NS8070 kernel breaks
Add debug - fixes it
Revert compiler change - fixes it
Review changes about ten times - no bug
Diff asm sources - no apparent bug in the differencesSpend ages wading through an instruction trace. Turns out the compiler change made the code shorter, moved a table lower in memory and triggered an existing unrelated bug in the NS8070 asm for the memory management.
Arghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
-
schrodingers-toctou: The binary you run is not the program you wrote https://lobste.rs/s/bmnusu #c #compilers #security
https://github.com/xoreaxeaxeax/schrodingers-toctou -
schrodingers-toctou: The binary you run is not the program you wrote https://lobste.rs/s/bmnusu #c #compilers #security
https://github.com/xoreaxeaxeax/schrodingers-toctou -
schrodingers-toctou: The binary you run is not the program you wrote
https://fed.brid.gy/r/https://github.com/xoreaxeaxeax/schrodingers-toctou
-
Sovereign Tech Fellowship for Rust maintenance (June-July 2026 report) via @bd103 https://lobste.rs/s/0zr9wr #compilers #devops #performance #rust
https://kobzol.github.io/rust/2026/08/03/stf-june-july-2026.html -
Sovereign Tech Fellowship for Rust maintenance (June-July 2026 report) via @bd103 https://lobste.rs/s/0zr9wr #compilers #devops #performance #rust
https://kobzol.github.io/rust/2026/08/03/stf-june-july-2026.html -
How Compiler Explorer Runs on AWS in 2026 https://lobste.rs/s/1eie3y #compilers #devops #vibecoding
https://xania.org/202608/how-compiler-explorer-runs-on-aws -
How Compiler Explorer Runs on AWS in 2026 https://lobste.rs/s/1eie3y #compilers #devops #vibecoding
https://xania.org/202608/how-compiler-explorer-runs-on-aws -
Debuginfo is expensive to compile, right? What if we generated it on-demand, when a debugger asks for it? You probably only care about the debuginfo for particular functions; we could skip generating >90% of the debuginfo an executable would normally contain. And such a workflow is perfectly possible for local development and debugging. We just need a way to communicate between a debugger like GDB and the compiler.
-
Debuginfo is expensive to compile, right? What if we generated it on-demand, when a debugger asks for it? You probably only care about the debuginfo for particular functions; we could skip generating >90% of the debuginfo an executable would normally contain. And such a workflow is perfectly possible for local development and debugging. We just need a way to communicate between a debugger like GDB and the compiler.
-
designing a query system via @fanf https://lobste.rs/s/awdorz #compilers #rust
https://bal-e.org/speed/krabby/2026/query-system-design/ -
designing a query system via @fanf https://lobste.rs/s/awdorz #compilers #rust
https://bal-e.org/speed/krabby/2026/query-system-design/ -
Японский язык
учебники словари курсы, аудио, тесты, учебная литература Japanese textbooks dictionaries courses, audio, tests, Японська мова підручники словники курси, аудіо, тести, навчальна література 日本教科書 辞書 コース、オーディオ、テスト、#教科書 🇯🇵
t.me/scilib_yura15cbx/777Пруст Марсель Marcel Proust
исследования badania дослідження research recherche 🦯🌂
t.me/scilib_yura15cbx/776Пруст Марсель Marcel Proust
тексты Texte des textes texts тексти κείμενα teksty
t.me/scilib_yura15cbx/775Пруст Марсель Marcel Proust
аудиокниги аудіокниги audiobooks livres audio Hörbücher
#Пруст Марсель #Marcel Proust
#аудиокниги #аудіокниги #audiobooks #livres #audio #Hörbücher
t.me/scilib_yura15cbx/774Немецкая философия
книги на немецком языке
#German philosophy, books in german, Німецька філософія, книги німецькою мовою, #Deutsche Philosophie, Bücher auf deutsch
t.me/scilib_yura15cbx/773Аудиокниги на немецком языке
Belletristik auf Deutsch, Hörbücher, fiction in #German, #audiobooks, художня література німецькою, #аудіокниги
t.me/scilib_yura15cbx/772Литература на немецком языке
немецкий язык, художественная литература #Література німецькою мовою, німецька мова, художня література, #Literature in #German German language, fiction Literatur in deutscher Sprache #Deutsche Sprache, #Belletristik 🇩🇪
t.me/scilib_yura15cbx/771Антуан де Сен-Экзюпери - Маленький принц - 1943 (20 языков) 🌹
t.me/scilib_yura15cbx/770Корейский язык
Korean Корейську мову 한국인 🇰🇷
t.me/scilib_yura15cbx/769Литература на финском языке
#Финляндия, финская литература, финский язык #Literature in Finnish Finland, Finnish literature, #Finnish language Література фінською мовою #Фінляндія, фінська література, фінська мова Suomenkielistä kirjallisuutta Suomi, suomalainen kirjallisuus, suomen kieli 🇫🇮
t.me/scilib_yura15cbx/768Литература на шведском языке.
Швеция, шведский язык Література шведською мовою. #Швеція, шведська мова. Literature in Swedish. #Sweden, #Swedish. Litteratur på svenska, #Sverige, svenska. 🇸🇪
t.me/scilib_yura15cbx/767Литература на японском языке
японский язык, #Япония, японская художественная литература. Literature in Japanese. #Japanese language, #Japan, Japanese fiction. Література японською мовою. японська мова, #Японія, японська художня література. 日本語の文学。 日本語、日本、日本のフィクション ⛩
t.me/scilib_yura15cbx/766James Joyce - Finnegans Wake
t.me/scilib_yura15cbx/765James Joyce - Ulysses
t.me/scilib_yura15cbx/764James Joyce Джеймс Джойс
#James Joyce #Джеймс Джойс
t.me/scilib_yura15cbx/763Нейронные сети, нейросети, нейросетевое программирование
Neuranets, neural network programming
Нейронні мережі, нейромережі, нейромережеве програмування 🕸
t.me/scilib_yura15cbx/762Big Data, Data Mining, Machine Learning
Большие данные, анализ данных, машинное обучение
Великі дані, аналіз даних, машинне навчання 👩💻
t.me/scilib_yura15cbx/761D, Dart, Go, Groovy, Rust
t.me/scilib_yura15cbx/759R статпакет 📊
t.me/scilib_yura15cbx/756Web, HTML, CSS, XML, JavaScript, PHP, Angular
#Web, #HTML, #CSS, #XML, #JavaScript, #PHP, #Angular
t.me/scilib_yura15cbx/753Алгоритмы, Компиляторы, Олимпиадные задачи, Криптография
Algorithms, Compilers, Olympiad problems, Cryptography
Алгоритми, Компілятори, Олімпіадні завдання, Криптографія 🫡
#Алгоритмы, #Компиляторы, #Олимпиадныезадачи, #Криптография
#Algorithms, #Compilers, #Olympiad problems, #Cryptography
#Алгоритми, #Компілятори, #Олімпіаднізавдання, #Криптографія
t.me/scilib_yura15cbx/752Архитектура ЭВМ, Операционные системы
Архітектура ЕОМ, Операційні системи Computer architecture, Operating systems 💻
#АрхитектураЭВМ, #Операционныесистемы
#АрхітектураЕОМ, #Операційнісистеми #Computer architecture, #Operating systems
t.me/scilib_yura15cbx/751Игры, Графика, Звук, DirectX, OpenGL, Unity, Lua
Ігри, Графіка, Звук, Games, Graphics, Sound 👾
#Игры, #Графика, #Звук, #DirectX, #OpenGL, #Unity, #Lua
#Ігри, #Графіка, #Звук, #Games, #Graphics, #Sound
t.me/scilib_yura15cbx/749Микроконтроллеры, Arduino, Raspberry Pi, AVR, PIC, USB
microcontrollers Мікроконтроллери
#Микроконтроллеры, #Arduino, #Raspberry #Pi, #AVR, #PIC, #USB
#microcontrollers #Мікроконтроллери
t.me/scilib_yura15cbx/748Теория, Проектирование, Качество кода, Паттерны, UML
Theory, Design, Code Quality, Patterns, UML
Теорія, Проектування, Якість коду, Паттерни, UML
#Теория, #Проектирование, #Качествокода, #Паттерны, #UML
#Theory, #Design, #Code Quality, #Patterns, #UML
#Теорія, #Проектування, #Якістькоду, #Паттерни, #UML
t.me/scilib_yura15cbx/746Технологии, библиотеки, фреймворки
Технології, бібліотеки, фреймворки
Technologies, libraries, frameworks
#Технологии, #библиотеки, #фреймворки
#Технології, #бібліотеки, #фреймворки
#Technologies, #libraries, #frameworks
t.me/scilib_yura15cbx/745Функциональное программирование
Functional programming
Функціональне програмування
t.me/scilib_yura15cbx/744Библиотека программиста
Бібліотека програміста Programmer's Library
программирование технологии програмування технології IT technology programming 🧑💻
t.me/scilib_yura15cbx/743 -
Японский язык
учебники словари курсы, аудио, тесты, учебная литература Japanese textbooks dictionaries courses, audio, tests, Японська мова підручники словники курси, аудіо, тести, навчальна література 日本教科書 辞書 コース、オーディオ、テスト、#教科書 🇯🇵
t.me/scilib_yura15cbx/777Пруст Марсель Marcel Proust
исследования badania дослідження research recherche 🦯🌂
t.me/scilib_yura15cbx/776Пруст Марсель Marcel Proust
тексты Texte des textes texts тексти κείμενα teksty
t.me/scilib_yura15cbx/775Пруст Марсель Marcel Proust
аудиокниги аудіокниги audiobooks livres audio Hörbücher
#Пруст Марсель #Marcel Proust
#аудиокниги #аудіокниги #audiobooks #livres #audio #Hörbücher
t.me/scilib_yura15cbx/774Немецкая философия
книги на немецком языке
#German philosophy, books in german, Німецька філософія, книги німецькою мовою, #Deutsche Philosophie, Bücher auf deutsch
t.me/scilib_yura15cbx/773Аудиокниги на немецком языке
Belletristik auf Deutsch, Hörbücher, fiction in #German, #audiobooks, художня література німецькою, #аудіокниги
t.me/scilib_yura15cbx/772Литература на немецком языке
немецкий язык, художественная литература #Література німецькою мовою, німецька мова, художня література, #Literature in #German German language, fiction Literatur in deutscher Sprache #Deutsche Sprache, #Belletristik 🇩🇪
t.me/scilib_yura15cbx/771Антуан де Сен-Экзюпери - Маленький принц - 1943 (20 языков) 🌹
t.me/scilib_yura15cbx/770Корейский язык
Korean Корейську мову 한국인 🇰🇷
t.me/scilib_yura15cbx/769Литература на финском языке
#Финляндия, финская литература, финский язык #Literature in Finnish Finland, Finnish literature, #Finnish language Література фінською мовою #Фінляндія, фінська література, фінська мова Suomenkielistä kirjallisuutta Suomi, suomalainen kirjallisuus, suomen kieli 🇫🇮
t.me/scilib_yura15cbx/768Литература на шведском языке.
Швеция, шведский язык Література шведською мовою. #Швеція, шведська мова. Literature in Swedish. #Sweden, #Swedish. Litteratur på svenska, #Sverige, svenska. 🇸🇪
t.me/scilib_yura15cbx/767Литература на японском языке
японский язык, #Япония, японская художественная литература. Literature in Japanese. #Japanese language, #Japan, Japanese fiction. Література японською мовою. японська мова, #Японія, японська художня література. 日本語の文学。 日本語、日本、日本のフィクション ⛩
t.me/scilib_yura15cbx/766James Joyce - Finnegans Wake
t.me/scilib_yura15cbx/765James Joyce - Ulysses
t.me/scilib_yura15cbx/764James Joyce Джеймс Джойс
#James Joyce #Джеймс Джойс
t.me/scilib_yura15cbx/763Нейронные сети, нейросети, нейросетевое программирование
Neuranets, neural network programming
Нейронні мережі, нейромережі, нейромережеве програмування 🕸
t.me/scilib_yura15cbx/762Big Data, Data Mining, Machine Learning
Большие данные, анализ данных, машинное обучение
Великі дані, аналіз даних, машинне навчання 👩💻
t.me/scilib_yura15cbx/761D, Dart, Go, Groovy, Rust
t.me/scilib_yura15cbx/759R статпакет 📊
t.me/scilib_yura15cbx/756Web, HTML, CSS, XML, JavaScript, PHP, Angular
#Web, #HTML, #CSS, #XML, #JavaScript, #PHP, #Angular
t.me/scilib_yura15cbx/753Алгоритмы, Компиляторы, Олимпиадные задачи, Криптография
Algorithms, Compilers, Olympiad problems, Cryptography
Алгоритми, Компілятори, Олімпіадні завдання, Криптографія 🫡
#Алгоритмы, #Компиляторы, #Олимпиадныезадачи, #Криптография
#Algorithms, #Compilers, #Olympiad problems, #Cryptography
#Алгоритми, #Компілятори, #Олімпіаднізавдання, #Криптографія
t.me/scilib_yura15cbx/752Архитектура ЭВМ, Операционные системы
Архітектура ЕОМ, Операційні системи Computer architecture, Operating systems 💻
#АрхитектураЭВМ, #Операционныесистемы
#АрхітектураЕОМ, #Операційнісистеми #Computer architecture, #Operating systems
t.me/scilib_yura15cbx/751Игры, Графика, Звук, DirectX, OpenGL, Unity, Lua
Ігри, Графіка, Звук, Games, Graphics, Sound 👾
#Игры, #Графика, #Звук, #DirectX, #OpenGL, #Unity, #Lua
#Ігри, #Графіка, #Звук, #Games, #Graphics, #Sound
t.me/scilib_yura15cbx/749Микроконтроллеры, Arduino, Raspberry Pi, AVR, PIC, USB
microcontrollers Мікроконтроллери
#Микроконтроллеры, #Arduino, #Raspberry #Pi, #AVR, #PIC, #USB
#microcontrollers #Мікроконтроллери
t.me/scilib_yura15cbx/748Теория, Проектирование, Качество кода, Паттерны, UML
Theory, Design, Code Quality, Patterns, UML
Теорія, Проектування, Якість коду, Паттерни, UML
#Теория, #Проектирование, #Качествокода, #Паттерны, #UML
#Theory, #Design, #Code Quality, #Patterns, #UML
#Теорія, #Проектування, #Якістькоду, #Паттерни, #UML
t.me/scilib_yura15cbx/746Технологии, библиотеки, фреймворки
Технології, бібліотеки, фреймворки
Technologies, libraries, frameworks
#Технологии, #библиотеки, #фреймворки
#Технології, #бібліотеки, #фреймворки
#Technologies, #libraries, #frameworks
t.me/scilib_yura15cbx/745Функциональное программирование
Functional programming
Функціональне програмування
t.me/scilib_yura15cbx/744Библиотека программиста
Бібліотека програміста Programmer's Library
программирование технологии програмування технології IT technology programming 🧑💻
t.me/scilib_yura15cbx/743 -
harlan: language for GPU computing https://lobste.rs/s/guwuzx #compilers #lisp
https://github.com/eholk/harlan/ -
harlan: language for GPU computing https://lobste.rs/s/guwuzx #compilers #lisp
https://github.com/eholk/harlan/ -
Over the last eight months, I've been designing a query system for my very-very-WIP Rust compiler, Krabby. I'm ecstatic to announce that the design phase is (pretty much) complete! Today I'm publishing a 6500-word essay about it, covering all the fun/cursed/evil features I wanted, and how I plan to achieve them. In October, at EuroRust 2026, you'll get to see it in action. I can't express just how excited I am -- but I'm going to take a nap first.
If you have any questions or comments, don't be afraid to reach out!
-
Over the last eight months, I've been designing a query system for my very-very-WIP Rust compiler, Krabby. I'm ecstatic to announce that the design phase is (pretty much) complete! Today I'm publishing a 6500-word essay about it, covering all the fun/cursed/evil features I wanted, and how I plan to achieve them. In October, at EuroRust 2026, you'll get to see it in action. I can't express just how excited I am -- but I'm going to take a nap first.
If you have any questions or comments, don't be afraid to reach out!
-
One of my favorite computer code talkers is lauriewired.
I had no idea someone wrote an operating system with "zero privacy ... on purpose".
-
One of my favorite computer code talkers is lauriewired.
I had no idea someone wrote an operating system with "zero privacy ... on purpose".
-
How to speed up the Rust compiler in July 2026 https://lobste.rs/s/ycsivx #compilers #performance #rust
https://nnethercote.github.io/2026/07/31/how-to-speed-up-the-rust-compiler-in-july-2026.html -
How to speed up the Rust compiler in July 2026 https://lobste.rs/s/ycsivx #compilers #performance #rust
https://nnethercote.github.io/2026/07/31/how-to-speed-up-the-rust-compiler-in-july-2026.html -
How to speed up the Rust compiler in July 2026
-
A question about a factorial operator https://lobste.rs/s/itp1nm #ask #compilers
-
A question about a factorial operator https://lobste.rs/s/itp1nm #ask #compilers
-
A question about a factorial operator
https://fed.brid.gy/r/https://lobste.rs/s/itp1nm/question_about_factorial_operator
-
“C++26: Reducing Undefined Behaviour”, Sandor Dargo (https://www.sandordargo.com/blog/2026/07/29/cpp26-reduces-undefined-behaviour).
Via Lobsters: https://lobste.rs/s/xinbkz/c_26_reducing_undefined_behaviour
#UndefinedBehavior #CPP #CPlusPlus #Programming #PLDI #Compilers
-
“C++26: Reducing Undefined Behaviour”, Sandor Dargo (https://www.sandordargo.com/blog/2026/07/29/cpp26-reduces-undefined-behaviour).
Via Lobsters: https://lobste.rs/s/xinbkz/c_26_reducing_undefined_behaviour
#UndefinedBehavior #CPP #CPlusPlus #Programming #PLDI #Compilers
-
Sigh... I guess I need to ask this now
So #rust programmers, how does one do errors in lossless parsing?
Context
I'm working on the new nu parser for nushell. The current strategy is to have a giant vector of so called
NodeIds which in turn refer other indices within that vector, and ultimately build a parse "tree" using thoseNodeId(variants in theAstNodemay contain other metadata too)Now, we just created a dummy
NodeIdfor errors and pushed them and continued to parse on our way. We want to have error-resilient parsing, so that we can cover more errors at other locations. If something's badly borked, well, we just barf.So this worked well for us devs, because it kept things simple easy, but this is not how I'd really like to build the parse tree. There are multiple problems.
Right off the bat, we lose all the type information in one big ball of
AstNodeenum vector. So even though there are some places where you know that anAstNodewould be of a particular kind, you simply cannot do anything about it except explicitly match and check (we want to avoid unsafe memory reinterprets).As an aside, most of the enum is empty, but due to some variants, the entire enum becomes 48 bytes, so we waste a lot of memory on basically nothing.
My solution to this was to use bumpalo to do allocations and store references, and let go of the vector altogether and build an actual parse tree (like, a node with children, which have further children, and so on)
This is basically doing the vector, but not wasting space on the emptiness of the enums, not lose the types at runtime to the enum, and not have to do hacky index-chasing (which effectively act like pointers now). Instead, we use actual references, which we know will be valid till the end of the arena lifetime (three cheers for bumpalo!)
The Problem
As mentioned before, we had
NodeIdfor errors as well, and those had a dummy span. Now, with the existence of a concrete parse tree, we have... no such thing. So we lose out on the ease of creating an error and attaching it wherever we want. In order to do things the earlier way, we have to make everything into anResult<insert_type_here, Error>which is very, very bad, because with that comes the indirect habit of using?to bubble upwards, which is a problem because we want to find as big of a parsed expression with as small of an error context (we basically want to minimize how much we weren't able to parse, because that's what any good parser should do)Right now, I don't really have any concrete ideas to attach errors to the nodes in the parse tree. So finally
Questions
- How does one do it? I'm looking for suggestions, although I don't really have anything concrete in my mind
- Would this actually lead to better performance? I expect it to be both faster and cheaper resource-wise. I'd argue yes, but I have no idea since it's a massive rewrite and doesn't even compile yet (:
Code snippets
// NOTE(bumpalo_rewrite): This becomes the root of the AST // TODO(bumpalo_rewrite): Change to the generic enum that block may contain #[derive(Debug, Clone)] pub struct Block<'a> { pub span_start: usize, pub span_end: usize, pub nodes: Vec<BlockEntities<'a>>, } // TODO(bumpalo_rewrite): Fill with all the possible BlockEntities // NOTE(bumpalo_rewrite): See Parser::block() for the entity types #[derive(Debug, Clone)] pub enum BlockEntities<'a> { Def(&'a Def<'a>), Let(&'a Let<'a>), While(&'a While<'a>), For(&'a For<'a>), Loop(&'a Loop<'a>), Return(&'a Return<'a>), Continue(&'a Continue), Break(&'a Break), Alias(&'a Alias), Extern(&'a Extern), PipelineOrExprOrAssign(PipelineOrExprOrAssign<'a>), Statement(PipelineOrExprOrAssign<'a>), }This is kind of what it is like right now. The function that parses a block:
else if self.is_keyword(b"while") { match self.while_statement(arena) { Some(while_) => { code_body.push(BlockEntities::While(while_)); } None => {} }; }has cases like these, where the error context is lost (ignore using
Optioninstead ofResult, I'm prototyping nullSo really, how do I preserve the error contexts?
Git Repo
Here. You'd want to mostly look through the diff between this commit and the previous one in
src/parser.rsAny help is appreciated because I'm close to losing my mind lol XD
#programming #parsing #rust #errortolerance #compilers #parsers
-
Sigh... I guess I need to ask this now
So #rust programmers, how does one do errors in lossless parsing?
Context
I'm working on the new nu parser for nushell. The current strategy is to have a giant vector of so called
NodeIds which in turn refer other indices within that vector, and ultimately build a parse "tree" using thoseNodeId(variants in theAstNodemay contain other metadata too)Now, we just created a dummy
NodeIdfor errors and pushed them and continued to parse on our way. We want to have error-resilient parsing, so that we can cover more errors at other locations. If something's badly borked, well, we just barf.So this worked well for us devs, because it kept things simple easy, but this is not how I'd really like to build the parse tree. There are multiple problems.
Right off the bat, we lose all the type information in one big ball of
AstNodeenum vector. So even though there are some places where you know that anAstNodewould be of a particular kind, you simply cannot do anything about it except explicitly match and check (we want to avoid unsafe memory reinterprets).As an aside, most of the enum is empty, but due to some variants, the entire enum becomes 48 bytes, so we waste a lot of memory on basically nothing.
My solution to this was to use bumpalo to do allocations and store references, and let go of the vector altogether and build an actual parse tree (like, a node with children, which have further children, and so on)
This is basically doing the vector, but not wasting space on the emptiness of the enums, not lose the types at runtime to the enum, and not have to do hacky index-chasing (which effectively act like pointers now). Instead, we use actual references, which we know will be valid till the end of the arena lifetime (three cheers for bumpalo!)
The Problem
As mentioned before, we had
NodeIdfor errors as well, and those had a dummy span. Now, with the existence of a concrete parse tree, we have... no such thing. So we lose out on the ease of creating an error and attaching it wherever we want. In order to do things the earlier way, we have to make everything into anResult<insert_type_here, Error>which is very, very bad, because with that comes the indirect habit of using?to bubble upwards, which is a problem because we want to find as big of a parsed expression with as small of an error context (we basically want to minimize how much we weren't able to parse, because that's what any good parser should do)Right now, I don't really have any concrete ideas to attach errors to the nodes in the parse tree. So finally
Questions
- How does one do it? I'm looking for suggestions, although I don't really have anything concrete in my mind
- Would this actually lead to better performance? I expect it to be both faster and cheaper resource-wise. I'd argue yes, but I have no idea since it's a massive rewrite and doesn't even compile yet (:
Code snippets
// NOTE(bumpalo_rewrite): This becomes the root of the AST // TODO(bumpalo_rewrite): Change to the generic enum that block may contain #[derive(Debug, Clone)] pub struct Block<'a> { pub span_start: usize, pub span_end: usize, pub nodes: Vec<BlockEntities<'a>>, } // TODO(bumpalo_rewrite): Fill with all the possible BlockEntities // NOTE(bumpalo_rewrite): See Parser::block() for the entity types #[derive(Debug, Clone)] pub enum BlockEntities<'a> { Def(&'a Def<'a>), Let(&'a Let<'a>), While(&'a While<'a>), For(&'a For<'a>), Loop(&'a Loop<'a>), Return(&'a Return<'a>), Continue(&'a Continue), Break(&'a Break), Alias(&'a Alias), Extern(&'a Extern), PipelineOrExprOrAssign(PipelineOrExprOrAssign<'a>), Statement(PipelineOrExprOrAssign<'a>), }This is kind of what it is like right now. The function that parses a block:
else if self.is_keyword(b"while") { match self.while_statement(arena) { Some(while_) => { code_body.push(BlockEntities::While(while_)); } None => {} }; }has cases like these, where the error context is lost (ignore using
Optioninstead ofResult, I'm prototyping nullSo really, how do I preserve the error contexts?
Git Repo
Here. You'd want to mostly look through the diff between this commit and the previous one in
src/parser.rsAny help is appreciated because I'm close to losing my mind lol XD
#programming #parsing #rust #errortolerance #compilers #parsers
-
LLVM toolchain coming to OpenBSD/sparc64 https://www.undeadly.org/cgi?action=article;sid=20260730130302 #openbsd #llvm #clang #sparc64 #development #compilers #libresoftware #freesoftware
-
LLVM toolchain coming to OpenBSD/sparc64 https://www.undeadly.org/cgi?action=article;sid=20260730130302 #openbsd #llvm #clang #sparc64 #development #compilers #libresoftware #freesoftware
-
Our next #JCON2026 session is live: 'Never Trust a Monkey: The Chasm, the #Craft, and the #Chain of #AI Assisted Code' with Baruch Sadogursky
We’re in the midst of another abstraction leap.
Just like #compilers #cloud and #containers before it, …Grab your coffee and hit play: https://youtu.be/PUMlajRE-2s
-
Overengineered calculator: Zig + QBE https://lobste.rs/s/ozules #compilers #zig
https://tomekw.com/overengineered-calculator-zig-qbe/ -
Overengineered calculator: #Zig + #QBE
-
Proof types in Dart: Using final classes as computational witnesses https://lobste.rs/s/wdo7aj #compilers #security
https://modulovalue.com/blog/proof-types-in-dart/ -
Why Rocq is better than Lean for program verification https://lobste.rs/s/vnh6b2 #compilers #formalmethods #ml #plt
https://joomy.korkutblech.com/posts/2026-07-28-why-rocq-is-better.html -
Inside Zig's Incremental Compilation by @mlugg https://lobste.rs/s/rmzzdb #compilers #performance #zig
https://mlugg.co.uk/posts/incremental-compilation-internals/