I have a fairly complicated grammar. It's > 1000 lines not including comments with 6 shift-reduce conflicts and 4 reduce-reduce conflicts. I'm using %glr-parser because a few states are unreachable unless I use a GLR although only one is valid by the end of the line.
I'm thinking about writing a parser by hand. My two questions are 1) Is it easy to write a (correct) parser that isn't efficient/fast? 2) Will I hate myself because my grammar is very complicated? I could create two bison parsers as another option but IDK how efficient it is versus a hand written parser. For example if you look at the code below I'd do one pass for the variables/functions then another for each function. I'm trying to avoid trees. With bison I know I'll execute the if body before the if but I could just create a char* and printf it later. If I were to write my own I don't know how complicated the line "c = a+b*3+atol(e)" will be. Bison definitely helped me but if I'm trying to be crazy efficient do I want to write a handmade parser (I kind of do) or do I want to write two bison parsers? Many rules will be shared in both like declaring a function can be inside and outside of a function (but an if cannot be outside) int a, b, c; void d() { a=2 b=3 if(rand()> 0.5) { c = a+b*3+atol(e) } else c=9 printf("C: %d\n", c); } string e="5" _______________________________________________ help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison