Hi all. A bit of a crystal newb here. I’ve ported a Java pratt parser to crystal (GitHub - gundy818/pratt: Pratt parser implementation in Crystal), and the token type is declared as an enum (as it was in java). But I’d like the token type to be re-definable by a user of this library, so that when using it to parse an arbitrary language you have the ability to redefine the token types. I tried to subclass the enum (enum NewType < Pratt::TokenType::Type), but that wasn’t allowed.
My first thought was to convert the enum to a class, but enum seems to fit well. I’m wondering what would be the best approach to this in crystal?
Thanks for any help! I’m really loving crystal, and am starting to use it for everything. I’m very open to suggestions to improve other parts of the above code too. My porting method was to rename the .java files to .cr and fix errors until it compiled. So it’s still very ‘java-y’.
Thanks!