Support for inlined type annotations for inherited attributes#5
Support for inlined type annotations for inherited attributes#5klwuco wants to merge 3 commits intolorchrob:masterfrom
Conversation
| (* The definition of the variable is local to the rule. *) | ||
| (* This is merely an artifact from parsing, and is meant to be syntax sugar that wil | ||
| be translated to the appropriate regular ProdRule and TypeAnnotation after parsing. *) | ||
| | InlinedTypeProdRule of string * (string * il_type) list * prod_rule_rhs list * Lexing.position |
There was a problem hiding this comment.
Instead of adding another constructor for InlinedTypeProdRule, just change the type of the ProdRule constructor to ProdRule of string * (string * il_type) list * prod_rule_rhs list * Lexing.position. Then later you do not need to add all the cases of | InlinedTypeProdRule _ -> assert false. In most cases we do not need the extra type information, so we can do something like this
| InlinedTypeProdRule (nt, ias, rhss, _) ->
let ias = List.map fst ias in
...
<original code here>
But this way, the type information is there when it is needed in desugarLocalVars.ml
There was a problem hiding this comment.
Note: When updating ProdRule, we are essentially requiring type annotations. So at parse time, we will not support LHS of the form <nt>(ia) ::= ... without the type annotation, so that rule will have to be removed.
| ast | ||
| in | ||
|
|
||
| (* Desugar local variables *) |
There was a problem hiding this comment.
Just curious -- why did you put it here in the pipeline rather than directly before the desugar_attributes step?
Allow inherited attributes to inline type annotations inside the production rule.