Conversation
|
@fpottier: Thanks! I believe that the changes go in the right direction of making the grammar more readable. I have looked at the PR and believe that it is generally correct, but not done a thorough review yet. I have some comments and remarks (some not specifically about this PR and for you, but about parser changes and for all of us). In no particular order (and cc @trefis, @let-def, @nojb):
|
|
Re. mnemonics, here would be an idea: have separated-list operators be of the form
Examples: I think having the separation mode right before the arguments in that order vocalizes reasonably well: "before clauses, bars"; "after expressions, semicolons"; "between types, stars". Of course mixfix syntax for parametrized rules would be nicer :-' |
Revealing slip of the pen? :-) |
|
@xavierleroy: Argh. Edited. (I know it was a joke but let's counter-joke by replying seriously.) There is a delicate balance to find between conciseness through abstraction and the complexity budget for human comprehension, so factorization through higher-order rules must be evaluated frankly. (The current diff of the PR, starting with a not-short addition of subtly different generic rules with long-and-systematic names and long-and-comprehensive comments, does give a bit of an impression of "Our robot overlords have taken control of the parser today", hence the suggestion to move these parts further down in the grammar.) |
|
It was half joke, half Freudian observation... But, yes, I support the removal of |
|
@gasche: thanks for your comments. No, there is no currently way in Menhir of giving the type of a non-terminal symbol (although that would make sense). Using multiple Checking that parser changes preserve the ASTs sounds like a very good idea. Which code base to you intend to use to do this? Regarding left-recursive vs. right-recursive lists, this can be important in order to avoid conflicts, and can also influence error reporting; I am not sure yet which of the two styles is preferable. Regarding using rules inline, instead of systematically giving auxiliary names, I can see the temptation, but auxiliary symbols are actually quite useful, as they give a single point where a change can be applied (either a change that actually affects the language, or an internal change that affects the grammar but not the language). Regarding your proposed mnemonics for lists, I agree that shorter names would be nice. Using 0-1-2 sounds good. I am less happy about |
|
My first proposal had I'll send a separate PR for ASTs testing. |
|
check-typo is complaining because you went overlength in two places: These need to be fixed, and otherwise I think the PR can be merged. (It doesn't have a Changes entry, |
|
Fixed the long lines. |
|
There is a conflict in |
|
(I went ahead and fixed the conflict.) |
so as to indicate that they are left-recursive. (We reserve [list] for right-recursive lists, as in the Menhir standard library.)
Use it to eliminate [simple_labeled_expr_list].
…uction. The use of [expr_comma_list] seemed to be a mistake.
of a generic definition.
Update the definition of [expr_semi_list] so that this is no longer necessary. This is prettier and saves 4 states.
This saves two states.
This PR introduces a number of generic definitions (mostly lists) in the parser and uses them to simplify some existing definitions. There should be no change in functionality. (Only one commit introduces a change by fixing a mistake in an error-handling production. The change is unlikely to be observed by anyone.)
There are probably more stylistic changes to come, but I am exposing this already.