diff options
Diffstat (limited to 'lib/qsp_instruction.mly')
-rw-r--r-- | lib/qsp_instruction.mly | 104 |
1 files changed, 0 insertions, 104 deletions
diff --git a/lib/qsp_instruction.mly b/lib/qsp_instruction.mly deleted file mode 100644 index 564e154..0000000 --- a/lib/qsp_instruction.mly +++ /dev/null @@ -1,104 +0,0 @@ -%% - -optionnal_delimited(opening, X, closing): - | v = delimited(opening, X, closing) { v } - | v = X { v } - -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: - | s = single_instruction { s } - -(** Action like act or if in a single line *) -%public inline_action: - | a = onliner(ACT) - { let loc, label, statements, _, _ = a in - Analyzer.Instruction.act loc ~label statements - } - | a = onliner(IF) - else_opt = preceded(ELSE, instruction)? - { let loc, expression, statements, loc_s, _body = a in - let elifs = [] - and else_ = Option.to_list else_opt in - Analyzer.Instruction.if_ - loc - (loc_s, expression, statements) - ~elifs - ~else_ - } - | a = onliner(IF) - else_= preceded(ELSE, inline_action) - { let loc, expression, statements, loc_s, _body = a in - let elifs = [] - and else_ = [ else_ ] in - Analyzer.Instruction.if_ - loc - (loc_s, expression, statements) - ~elifs - ~else_ - } -single_instruction: - | expr = expression - { - Analyzer.Instruction.expression expr - } - | e = let_assignation { e } - | k = keyword - arg = argument(expression) - { - Analyzer.Instruction.call $loc k arg - } - -keyword: - | STAR k = KEYWORD { "*" ^ k } - | k = KEYWORD { k } - -let_assignation: - | assignation - variable = variable - op = assignation_operator - value = expression - { - 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 } - -inline_instruction: - | hd = inline_instruction - tl = single_instruction - AMPERSAND+ - { tl :: hd } - | - { [] } - -final_inline_instruction: - | hd = inline_instruction - tl = instruction - | hd = inline_instruction - tl = inline_action - { tl :: hd } - | hd = inline_instruction - COMMENT - { (Analyzer.Instruction.comment $loc) :: hd } - | hd = inline_instruction - { hd } - -onliner(TOKEN): - | TOKEN - e = expression - COLUMN - s = rev (final_inline_instruction) - { $loc, e, s, $loc(s), None } |