Hi there!
First of all, thank you Per for Bitwise, it is an amazing project to follow and I learned a lot already. Keep up the good work!
I have a style-related question.
While creating my solution for day 2-3, I found that I have a lot of enum redundancy (especially for operators) between type.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 | // In the lexer, I have an enum for every token possible, operator included
typedef enum TokenType {
TOKENTYPE_ADD,
TOKENTYPE_MIN,
TOKENTYPE_MUL,
//... you get the point
} TokenType;
//In my expression parser, I have a very similar structure for Operator Expression
typedef enum OpExprType {
OPEXPRTYPE_ADD,
OPEXPRTYPE_MIN,
OPEXPRTYPE_MUL,
//...
} OpExprType;
|
I almost have a direct mapping between TokenType and OpExprType and it feels really redundant. It's not the first time I find this kind of structure, I was wondering if it is just the way it is, or if there are some technique to simplify that.
Thank you for you time!