B-Lang-org/bsc

Syntax for enum encodings in BH/Classic

Offen

#292 geöffnet am 14.01.2021

 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Haskell (178 Forks)batch import
good first issue

Repository-Metriken

Stars
 (1.108 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 17T 1h) (18 gemergte PRs in 30 T)

Beschreibung

BSV allows the user to specify a custom encoding for the derived Bits of an enum. For example, from bsc.bluetcl/commands/Test.bsv in the testsuite:

typedef enum { Red2 = 1, Yellow2, Blue2 } BarSet deriving(Bits);

This is handled by pEnumTag in Parser/BSV/CVParser.lhs (where it fills in the fields like cos_tag_encoding). In the BH/Classic parser (Parser/Classic/CParser.hs) the function pDataB just fills in integers starting from zero ([0..]).

It might be worth creating a BH/Classic syntax for specifying a custom encoding. (It could perhaps be an attribute, if that's easier.) This is part of the larger issue that BSV was the only supported syntax for a long time, so there are some things that can be specified in that syntax but not in BH/Classic. See, for example, issue #224. I don't personally have a need for custom encodings in BH/Classic, but I thought it was worth recording the difference in the Issues database. (Should we have an open Issue for listing all of the known differences? or perhaps this a good use for the new Discussions area?)

Implementing the syntax should be simple, so I'm tagging this as a "good first issue", but we'd need to decide on the syntax first.

Contributor Guide