Hi Hans, Evan, Zartaj, thank you for all the helpful comments! I made some minor clean ups, but I don't feel confident enough to upstream them. I played around with semicolons rules as you advised, and I could see some effect: I ended up having more conflicts :-) I think the problem is too big for me to address it further at the moment.
Bye Christoph Am 02.02.21 um 11:36 schrieb Evan Lavelle: > I don't know how familiar you are with this, so apologies if I'm stating > the obvious. > > General observations: > > 1 - start by writing a skeleton with no actions; this makes it easier to > find conflicts. When you're done, add the actions > > 2 - this is *way*, *way* too verbose. You don't need tokens for ';', > '{', '}', etc - just write them explicitly in the description; this > makes it much easier to read. Get rid of all the $<str>$. Move all the > common body actions out to routines at the bottom of the file, etc. > yyGetParser->SetCurrentCombine("") is just noise. > > 3 - if you have an optional ';' in your description, try not to repeat > the body twice, once with a ';', and once without: > > MethodDeclaration > : MethodHeader jp_SEMICOL > | MethodHeader MethodBody > | MethodHeader MethodBody jp_SEMICOL > > this is asking for conflicts, and is too verbose. Try (4) for the > conflicts, and/or this to reduce verbosity: > > MethodDeclaration > : MethodHeader jp_SEMICOL > | MethodHeader MethodBody opt_semicolon > > See also ConstructorDeclaration, etc. > > 4 - I think your fundamental problem is that your semicolon handling is > too complicated; I'm surprised that you only have 4 conflicts. Statement > terminators are always difficult. My procedure is to move this to the > top level, as far as possible. I can't easily explain why, but this does > seem to make it much easier to write without conflicts (and to handle > error recovery). If you're lucky, you end up with something like this, > with no other terminators in your description: > > statement > : statement_a ';' > | statement_b ';' > | statement_c ';' > | /* empty */ ';' > | ... > ; > > 5 - turn the counter examples into real source code that demonstrates > the problem - that makes it much easier for us to see the issue, and may > make the resolution clearer. > -- Als wär es nix, leb' ich von [IT] und mach' nur, was ich lieb' Lebe wie im Paradies, womit hab' ich das verdient? Die Wahrheit ist: Hab' ich nicht, ich bin nur reicher beschenkt Als jemand in einem armen Land mit dem gleichen Talent [frei nach Tua von Die Orsons - Oioioiropa]