port method

Parser<Port> port()

A complete port.

Implementation

Parser<Port> port() => [
      // First try to match a compass port to avoid parsing a compass point as an id
      (ref1(token, ':') & ref0(compassPt)).map((result) => CompassPort(result[1])),
      (ref1(token, ':') & ref0(id) & (ref1(token, ':') & ref0(compassPt)).optional())
          .map((result) => IdPort(result[1], result[2]?[1])),
    ].toChoiceParser();