PistonDevelopers / dyon

A rusty dynamically typed scripting language
Apache License 2.0
1.78k stars 55 forks source link

Support optional sub rules in meta data converter syntax #353

Open bvssvni opened 8 years ago

bvssvni commented 8 years ago

I'm prototyping a proof assistant written in Dyon and discovered a weakness in the meta converter language:

  tactic := [name: str, forced: opt[bool]] =>
    {
      op:"tactic",
      name: name,
      forced: if forced == none() { false } else { unwrap(forced) },
      args: []
    };
  tactic_args := [name: str, forced: opt[bool], args <- args:"args"] =>
    {
      op:"tactic",
      name: name,
      forced: if forced == none() { false } else { unwrap(forced) },
      args: args
    };

Here I need two rules for tactics, one that has no arguments and one with arguments. I would like to have one rule for both cases.

Perhaps there is a way to make sub rules optional?

bvssvni commented 8 years ago

Could use the syntax args: opt <- args:"args".

This works well with Dyon syntax since opt defaults to opt[any].