fictiveworks / CalyxSharp

Generative text processing for C# and Unity applications
Other
0 stars 0 forks source link

Missing grammar overload for constructing weighted rules #34

Closed maetl closed 1 year ago

maetl commented 1 year ago

Expected

The following declaration should construct a weighted branch production.

G.Rule("bonus", new Dictionary<string, int>() {
  "+1": 4,
  "+2": 2,
  "+3": 1
});

Actual

Code won’t compile, Calyx.Grammar.Rule doesn’t support a Dictionary<string, int> being passed in as the production.

Should be an extremely simple fix, I’ll hopefully have time to look into all this later in the week.

maetl commented 1 year ago

The syntax I posted in the expected behaviour above might be wrong (I always get mixed up with C# dict literals), but the integration tests in #35 have examples of the syntax that does work. Also needs to be tested in Unity.

bentorkington commented 1 year ago

No that's definitely the correct syntax. Sorry for missing these, I think I confused myself by only basing my changes on the unit tests of another branch type and didn't write with my mind on the actual API

maetl commented 1 year ago

@bentorkington All good, and thank you for the code comments about common integer types and C# versions, that saved me a lot of time and avoided going down a rabbit hole.