Hacker News new | ask | show | jobs
by mcluck 1210 days ago
Great project!

I'm curious about the set of available parser annotations. I went through the list but I didn't see anything which allows for optional elements. One example would be dangling commas. Did I miss it or are there plans to support such constructs?

1 comments

We support optional elements by wrapping them in `Option<T>` (other annotations are applied to the contents of the option)! So you can define

  struct ... {
    ...
    #[rust_sitter::leaf(text = ",")
    _dangling_comma: Option<()>
  }
Perfect, thanks!