diff options
Diffstat (limited to 'lib/qparser/qsp_instruction.mly')
| -rw-r--r-- | lib/qparser/qsp_instruction.mly | 22 | 
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/qparser/qsp_instruction.mly b/lib/qparser/qsp_instruction.mly index bc1ca37..fe8a51a 100644 --- a/lib/qparser/qsp_instruction.mly +++ b/lib/qparser/qsp_instruction.mly @@ -4,6 +4,8 @@ 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 ] } @@ -16,44 +18,47 @@ argument(X):  %public inline_action:      | a = onliner(ACT)        { let loc, label, statements, _, _ = a in  +        let label = Helper.v label 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 loc, expr, statements, loc_s, _body = a in           let elifs = []          and else_ = Option.to_list else_opt in          Analyzer.Instruction.if_              loc  -            (loc_s, expression, statements)  +            (loc_s, Helper.v expr, statements)               ~elifs              ~else_        }      | a = onliner(IF)        else_= preceded(ELSE, inline_action) -      { let loc, expression, statements, loc_s, _body = a in  +      { let loc, expr, statements, loc_s, _body = a in           let elifs = []          and else_ = [ else_ ] in +          Analyzer.Instruction.if_              loc  -            (loc_s, expression, statements)  +            (loc_s, Helper.v expr, statements)               ~elifs              ~else_        }  single_instruction:      | expr = expression      {  +        let expr = Helper.v expr in          Analyzer.Instruction.expression expr      }      | e = let_assignation   { e }      | k = keyword -      arg = argument(expression) +      args = argument(expression)      { -        Analyzer.Instruction.call $loc k arg +        let args = List.map args ~f:(Helper.v) in +        Analyzer.Instruction.call $loc k args      }  keyword: -    (*| STAR k = KEYWORD { "*" ^ k }*)      | k = KEYWORD  { k }  let_assignation: @@ -62,6 +67,9 @@ let_assignation:        op = assignation_operator        value = expression       {  +        let variable = Helper.variable variable +        and value = Helper.v value in +          Analyzer.Instruction.assign $loc variable op value      }  | 
