# All files / src/parser maybe-assignment.js

100% Statements 6/6
100% Branches 4/4
100% Functions 1/1
100% Lines 6/6

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    26x
    26x

    149x
    149x
    26x

    123x

     // @flow
    import memoryStore from "./memory-store";
    import expression from "./expression";
    import type Context from "./context";
    import type { NodeType } from "../flow/types";

    // It is easier to parse assignment this way as we need to maintain a valid type
    // through out the right-hand side of the expression
    function maybeAssignment(ctx: Context): NodeType {
      const nextValue = ctx.stream.peek().value;
      if (nextValue === "[" || nextValue === ".") {
        return memoryStore(ctx);
      }
      return expression(ctx);
    }

    export default maybeAssignment;