type InvalidTemplateError … func (e InvalidTemplateError) Error() string { … } // Parse parses the string representation of path template func Parse(tmpl string) (Compiler, error) { … } func tokenize(path string) (tokens []string, verb string) { … } type parser … // topLevelSegments is the target of this parser. func (p *parser) topLevelSegments() ([]segment, error) { … } func (p *parser) segments() ([]segment, error) { … } func (p *parser) segment() (segment, error) { … } func (p *parser) literal() (segment, error) { … } func (p *parser) variable() (segment, error) { … } func (p *parser) fieldPath() (string, error) { … } type termType … const typeIdent … const typeLiteral … const typeEOF … const eof … // accept tries to accept a token in "p". // This function consumes a token and returns it if it matches to the specified "term". // If it doesn't match, the function does not consume any tokens and return an error. func (p *parser) accept(term termType) (string, error) { … } // expectPChars determines if "t" consists of only pchars defined in RFC3986. // // https://www.ietf.org/rfc/rfc3986.txt, P.49 // // pchar = unreserved / pct-encoded / sub-delims / ":" / "@" // unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" // sub-delims = "!" / "$" / "&" / "'" / "(" / ")" // / "*" / "+" / "," / ";" / "=" // pct-encoded = "%" HEXDIG HEXDIG func expectPChars(t string) error { … } // expectIdent determines if "ident" is a valid identifier in .proto schema ([[:alpha:]_][[:alphanum:]_]*). func expectIdent(ident string) error { … } func isHexDigit(r rune) bool { … }