janriemer, to rust

for

https://rust-for-linux.com/coccinelle-for-rust

"Coccinelle is a tool for automatic program matching and transformation that was originally developed for making large scale changes to the Linux kernel source (ie, C code)."

- GritQL is a language for searching, , and modifying code.

https://docs.grit.io/

- A tool for code structural search, lint and rewriting. Written in :ferris:

https://ast-grep.github.io/

janriemer, to rust

Many people say that #Rust is very hard to #prototype with or to #refactor. This couldn't be further from the truth! It is the exact opposite!

Let me share with you one of the most profound experiences I had with #RustLang on a casual sunday - a thread 🧵

I'm currently rewriting my #transpiler from #nom to #chumsky and until now everything has turned out great so far, until I've hit the following road block:
Implementing parsers by using #parser functions that have indirect #recursion.

1/11

janriemer, to rust

The #Rust #parser combinator experience:

  1. Writing multiple parser combinator functions ✅
  2. The most "higher up" parser fails ❌
  3. Investigate reason 🔍
  4. Find out it's a whitespace char that has been parsed too eagerly 💡
  5. Fix eagerly parsed whitespace 🔧
  6. All tests pass ✅
  7. Rinse and repeat ➰

In all seriousness: 95% of errors I have are due to me parsing whitespace too eagerly (this is good!).

I'm using #chumsky, btw (beautifully designed parser combinator crate!).

#RustLang

janriemer, to rust

Currently in the process of rewriting my from v4.2 to v1.0.0-alpha.6 🤓

It is a lot of fun so far, but I have to say these type signatures are wild!😄

I'm still struggling with it far more than I'd like, but I guess it is just a matter of time until intuition kicks in and it will become more and more natural.

Exciting project ahead!🙂

I'm even able to parse string literals with escape sequences - something I haven't even achieved with nom!

janriemer,

Sometimes, in order to stay flexible and fit, you need to do some (type) gymnastics 🤸

Slowly getting the hang of combinator 🤓

One concept (among others!) I haven't learned yet, but will run into, is in chumsky. I know, there are good docs on it - it's just something I haven't gotten to yet.

All in all, I'm very happy with chumsky so far. Kudos to its maintainers! 🙂 🎩

janriemer,
shuttle, to rust
@shuttle@mastodon.online avatar

What are some underappreciated crates you think more people should know about?

janriemer,

@shuttle

Parsing crates:

chumsky | A library for humans with powerful error recovery

https://crates.io/crates/chumsky

winnow | making a breeze

https://crates.io/crates/winnow


Crates in the ecosystem:

pollster | an incredibly minimal async executor for that lets you block a thread until a future completes

https://crates.io/crates/pollster

smol | A small and fast async runtime

https://crates.io/crates/smol

dpom, to rust
@dpom@fosstodon.org avatar

What a great introduction to parsing in #rust:

https://andreabergia.com/blog/2024/01/playing-with-nom-and-parser-combinators/

It introduces the concept of parser combinators and the nom library, in a simple and clear way, in like 10 minutes. Just enough to get you fired up.

janriemer,

@dpom Great article! Thank you for sharing. ❤️

If you want to go really deep into #parsing and #grammars (without being Rust-specific), I can highly recommend Strumenta

https://tomassetti.me/

It is such a treasure trove of articles deeply explaining all there is to parsing and grammars. I absolutely love it!💖

See e.g. this one

A #Guide to Parsing: Algorithms and Terminology

https://tomassetti.me/guide-parsing-algorithms-terminology/

Urgh, it is just so good!🥰

#Parser #Algorithms #Grammar

fenarinarsa, to bluesky
@fenarinarsa@shelter.moe avatar

Bluesky just removed their login wall, now posts and profiles can be accessed freely.
Any user can disable this for their account (it's still reachable with 3rd party apps through federation but it adds friction).

For example:
https://bsky.app/profile/fenarinarsa.com

alcea,
@alcea@urusai.social avatar

@fenarinarsa

*dusts off *

Maybe I'll have to write that now ..

Whats that ?
Uhhh.
Do I seem like matter to me 😺

golmac, to random
@golmac@zirk.us avatar

Hi all. I've gotten some positive feedback on my accessible "story mode" for Repeat the Ending, but I could use maybe two more testers. If you dislike playing parser games but would consider "reading" one, get in touch. Details:

https://intfiction.org/t/repeat-the-ending-story-mode/65475

jsbarretto, to random
@jsbarretto@social.coop avatar

Ah, yes, thank you Rust.

janriemer,

@jsbarretto are so fascinating, aren't they!? At first you think: "Hm...what should be so special about a parser?", but then you go down the rabbit hole and you'll probably never return to the surface. 😄

Regarding error recovery: You probably already know the following article, by matklad, but just in case you don't:

Resilient LL Parsing Tutorial
https://matklad.github.io/2023/05/21/resilient-ll-parsing-tutorial.html

Probably one of the best tutorials I've read in a long time.

golmac, to random
@golmac@zirk.us avatar

Since a few reviewers have mentioned Repeat the Ending in their reviews of B.J. Best's LAKE Adventure, I decided to have a look.

https://golmac.org/lake-adventure-these-textual-delights-have-textual-ends/

avp, to random
@avp@fosstodon.org avatar
avp, to guix
@avp@fosstodon.org avatar

Guile-INI got updated to version 0.5.4 in GNU Guix:
https://git.savannah.gnu.org/cgit/guix.git/commit/?id=8aad7210ea06992ee3f36ca7f57678240949e063

Thanks to Fabio Natali for the reporting the logging issue that I fixed in the release and the patch that updates Guile-INI in Guix.

janriemer, to random

Left Recursion in Parsing Expression Grammars:

https://arxiv.org/pdf/1207.0443v1.pdf

"A frequently missed feature of PEGs is left , which is commonly used in Context-Free Grammars () to encode left-associative operations. We present a simple conservative extension to the semantics of that gives useful meaning to direct and indirect left-recursive rules, and show that our extensions make it easy to express left-recursive idioms from CFGs in PEGs, with similar results."

janriemer, to rust

Uh, ohhh... I think it's time for me to migrate away from #nom v4.2 😮

Yeah, I know, I've procrastinated on this a lot. This will probably be a lot of work and "slow me down" for a bit. 😪 On the upside, though: I can correct all my mistakes along the way (like having spans).

I'll probably migrate to #chumsky, but #winnow also looks really nice. 🙂

chumsky:
https://github.com/zesterer/chumsky

winnow:
https://github.com/winnow-rs/winnow

#Rust #RustLang #selecuery #Migration #OpenSource #Refactoring #Parser #Compiler

toxi, (edited ) to typescript
@toxi@mastodon.thi.ng avatar

— Building a toy Lisp language and interpreter using the S-expression parser from https://thi.ng/sexpr and polymorphic multiple dispatch functions via https://thi.ng/defmulti. A small language like this can be useful for DSL purposes, user programming or for just learning about interpreters. The entire setup is highly customizable (incl. support for different kinds of S-expressions, see package readme).

Even this tiny example includes the following features: variadic math ops, ability to define new symbols/variables & functions, lexical scoping, numeric & string values...

Some example invocations are included at the end...

Source code:
https://github.com/thi-ng/umbrella/blob/develop/packages/sexpr/README.md#interpreter

(Update: Minor code simplifications, updated images)

folkerschamel, to python
@folkerschamel@mastodon.social avatar

for fans:
where does this error come from?


In my opinion, one of the great things about is that it's simple and straightforward - you don't get unexpected surprises. But there are a few exceptions, as this example shows.😉

cazabon,

@folkerschamel

Oops, so I am :)

It does look buggy to me, but I am really not the one to ask about the nitty-gritty details of the .

janriemer, to rust

winnow - Making parsing a breeze (by epage and contributors):

https://github.com/winnow-rs/winnow

winnow is a parser combinator library written in Rust that started as a fork of #nom.

Not sure yet, if I should migrate from nom 4.* to #winnow or #chumsky. I really do like the good error recovery and parsing capabilities for PEGs of chumsky.🥰

#Rust #RustLang #Parser #CrateTip

hywan, to random
@hywan@fosstodon.org avatar

Parsing time stamps faster with SIMD instructions, https://lemire.me/blog/2023/07/01/parsing-time-stamps-faster-with-simd-instructions/.

A short article, almost a note, to explain how to parse time stamps with SIMD. 10x less instructions, 5.8x faster, than strptime.

itnewsbot, to random
@itnewsbot@schleuss.online avatar

Pratt Parsing for Algebraic Expressions - Parsing algebraic expressions is always a pain. If you need to compute, say, 2+4*2... - https://hackaday.com/2023/07/03/pratt-parsing-for-algebraic-expressions/

janriemer, to ai

Forest: Structural Code Editing with Multiple Cursors:

https://arxiv.org/abs/2210.11124

"In this work, we present Forest, a structural code editor that aims to bridge the gap between the interactiveness of code editors and the expressiveness of refactoring scripts."

Better than every #AI out there, if you ask me.

Also, #Forest is a very suitable name for this. 🌲

#CodeEditor #DevTools #Refactoring #StructuralEditing #AST #Parser

vivdunstan, to gaming
@vivdunstan@mastodon.scot avatar

I have several works in progress, that I'm in various stages of developing. Suddenly had great idea last night for one of them, reframing the opening and overall structure. Making frantic notes now before I totally forget it all. Typing into comments in my source code. Feeling invigorated. Hoping that my allows me enough good time to complete this and the others satisfactorily.

vivdunstan, to gaming
@vivdunstan@mastodon.scot avatar

Browsing the IFDB database and just stumbled again across my own list of my top 10 personal favourite interactive fiction . The list is arranged in chronological order, from 1983 to 2017. Some predictable titles in there but also some less familiar ones. I include comments about each one. https://ifdb.org/viewlist?id=fplmp7feqc2spqwj

hywan, to rust
@hywan@fosstodon.org avatar

I’m starting a new project to learn about linkers. It’s called ˋweld`, and it lives here https://github.com/Hywan/weld.

I do this on my free time; understand very sporadically.

This toot is a thread to show progress or to ask help.

hywan,
@hywan@fosstodon.org avatar

Before leaving the elf64, I wanted to write some tests. Fortunately for me, parsers written with nom are really easy to test, they are just functions!

https://github.com/Hywan/weld/compare/13be3d2917f945cd347e9394c07853ac692f32de...9e6d55e2e137df3786b257228c7e35042520c0a7

When tests are easy to write, it's a pleasure to test everything.

With this test session, I've been able to fix one panic when reading a string in a data segment with an out-of-range offset.

hywan,
@hywan@fosstodon.org avatar

The weld-parser crate wasn't happy with its name. Now, we must refer to it as weld-object. This crate has ambitions for its life!, like supporting Elf32, MachO, COFF, and more object formats, look at this little cheeky!

https://github.com/Hywan/weld/commit/7556abeb5d80f015e92634d8b9a6c1494e815b9e

  • All
  • Subscribed
  • Moderated
  • Favorites
  • megavids
  • thenastyranch
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • ngwrru68w68
  • provamag3
  • magazineikmin
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • anitta
  • Leos
  • tester
  • JUstTest
  • All magazines