Ejemplo n.º 1
0
def LeftAssign(p, w, left, rbp):
  # type: (TdopParser, word_t, arith_expr_t, int) -> arith_expr_t
  """ Normal binary operator like 1+2 or 2*3, etc. """
  # x += 1, or a[i] += 1

  CheckLhsExpr(left, p.parse_opts.parse_dynamic_arith(), w)
  return arith_expr.BinaryAssign(word_.ArithId(w), left, p.ParseUntil(rbp))
Ejemplo n.º 2
0
def LeftAssign(p, w, left, rbp):
    # type: (TdopParser, word_t, arith_expr_t, int) -> arith_expr_t
    """ Normal binary operator like 1+2 or 2*3, etc. """
    # x += 1, or a[i] += 1
    lhs = ToLValue(left)
    if lhs is None:
        p_die("Can't assign to %r", lhs, word=w)
    return arith_expr.BinaryAssign(word.ArithId(w), lhs, p.ParseUntil(rbp))
Ejemplo n.º 3
0
def LeftAssign(p, w, left, rbp):
    # type: (TdopParser, word_t, arith_expr_t, int) -> arith_expr_t
    """ Normal binary operator like 1+2 or 2*3, etc. """
    # x += 1, or a[i] += 1
    lhs = ToLValue(left)
    if lhs is None:
        # TODO: It would be nice to point at 'left', but osh/word.py doesn't
        # support arbitrary arith_expr_t.
        #p_die("Can't assign to this expression", word=w)
        p_die("Left-hand side of this assignment is invalid", word=w)
    return arith_expr.BinaryAssign(word_.ArithId(w), lhs, p.ParseUntil(rbp))