private static PathSegment parseSegment(Context context, Delimiters delimiters) {
        final char firstCh = context.read();
        switch (firstCh) {
            case '{': {
                final Delimiters variableStopBefore = new Delimiters('}');
                final PathSegment segment = parseVariable(context, variableStopBefore);
                // Consume the end symbol of a variable definition.
                checkArgument(context.read() == '}',
                              "path: %s (invalid variable part at index %s)", context.path(), context.index());
                return segment;
            }
            case '*': {
                final PathSegment segment;
                if (context.peek() == '*') {
                    // Consume the second '*'.
                    context.read();
                    segment = new DeepWildcardPathSegment(context.nextPathVarIndex());
                } else {
                    segment = new WildcardPathSegment(context.nextPathVarIndex(), null);
                }
                // Should 1) no more input or 2) meet a delimiter such as '/', ':' or '}'.
                checkArgument(!context.hasNext() || delimiters.contains(context.peek()),
                              "path: %s (invalid wildcard part at index %s)", context.path(), context.index());
                return segment;
            }
            default: {
                final StringBuilder literalBuilder = new StringBuilder().append(firstCh);
                while (context.hasNext()) {
                    final char c = context.peek();
                    if (delimiters.contains(c)) {
                        break;
                    }
                    literalBuilder.append(context.read());
                }
                return new LiteralPathSegment(literalBuilder.toString());
            }
        }
    }
Parses 'Segment' part.

<p>
Segment  = "*" | "**" | LITERAL | Variable
</p>
grpc/src/main/java/com/linecorp/armeria/server/grpc/HttpJsonTranscodingPathParser.java