%% optionnal_delimited(opening, X, closing): | v = delimited(opening, X, closing) { v } | v = X { v } (* Redefine the arguments from expression here because we accept * values without parens. *) argument(X): | a = optionnal_delimited(L_PAREN, arguments(X), R_PAREN) { a } | a = X { [ a ] } (** At the opposite of an expression, an instruction does not return anything. *) %public instruction: | expr = expression { let expr = Analyzer.Expression.v expr in Analyzer.Instruction.expression expr } | e = let_assignation { e } | k = keyword args = argument(expression) { let args = List.map args ~f:(Analyzer.Expression.v) in Analyzer.Instruction.call $loc k args } keyword: | k = KEYWORD { k } let_assignation: | assignation variable = variable op = assignation_operator value = expression { let variable = Helper.variable variable and value = Analyzer.Expression.v value in Analyzer.Instruction.assign $loc variable op value } %inline assignation: | | LET | SET {} assignation_operator: | EQUAL { T.Eq' } | INCR { T.Inc } | DECR { T.Decr } | MULT_EQUAL { T.Mult } | DIV_EQUAL { T.Div_assign }