Discussion
Loading...

Post

  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
Joshua Barretto
@jsbarretto@social.coop  ·  activity timestamp 5 days ago

The combinator pattern is extremely cool case study #5371:

Here's an entirely automatically generated railroad syntax diagram for the JSON parser example that comes with my parser combinator library Chumsky (https://github.com/zesterer/chumsky/).

This works for arbitrary parsers, with no additional work needed on the part of parser authors.

If you've written a parser with Chumsky, you'll be able to call just a single function to get a similar diagram for your grammar. #rustlang #plt #compilerdev

GitHub

GitHub - zesterer/chumsky: Write expressive, high-performance parsers with ease.

Write expressive, high-performance parsers with ease. - zesterer/chumsky
An image of a railroad syntax diagram. It contains a single self-recursive definition, a JSON value. The diagram consists of a series of branching lines which fan out into many different paths, some which loop back on themselves, and then finally coalesce into a single end path on the right of the image. Several of the paths contain labels such as character that appear in the JSON grammar.
An image of a railroad syntax diagram. It contains a single self-recursive definition, a JSON value. The diagram consists of a series of branching lines which fan out into many different paths, some which loop back on themselves, and then finally coalesce into a single end path on the right of the image. Several of the paths contain labels such as character that appear in the JSON grammar.
An image of a railroad syntax diagram. It contains a single self-recursive definition, a JSON value. The diagram consists of a series of branching lines which fan out into many different paths, some which loop back on themselves, and then finally coalesce into a single end path on the right of the image. Several of the paths contain labels such as character that appear in the JSON grammar.
  • Copy link
  • Flag this post
  • Block
Epic Eric :thinkhappy:
@epiceric@mastodon.xyz replied  ·  activity timestamp 4 days ago

@jsbarretto Awesome! I was just looking for a new parser, I'll definitely check out Chumsky now.

  • Copy link
  • Flag this comment
  • Block
Joshua Barretto
@jsbarretto@social.coop replied  ·  activity timestamp 4 days ago

@epiceric I hope it does what you're looking for!

  • Copy link
  • Flag this comment
  • Block
Celes 🌙
@celestia@tech.lgbt replied  ·  activity timestamp 5 days ago

@jsbarretto I'm being nitpick-y but why is there an "any" loop labeled as filtered on the "\u branch? does that have some special meaning or is it just a simplified version? hammyeyes

  • Copy link
  • Flag this comment
  • Block
Joshua Barretto
@jsbarretto@social.coop replied  ·  activity timestamp 5 days ago

This is all really, really experimental and is currently cobbled together with hot glue and prayers, but with some work that should change.

Thanks also to @lukaslueg for creating the excellent `railroad` crate, it works exactly as advertised!

  • Copy link
  • Flag this comment
  • Block
Log in

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.0-rc.3.21 no JS en
Automatic federation enabled
  • Explore
  • About
  • Members
  • Code of Conduct
Home
Login