MCPcopy Create free account
hub / github.com/Permify/permify / registerPrefix

Method registerPrefix

pkg/dsl/parser/parser.go:825–837  ·  view source on GitHub ↗

registerPrefix safely registers a parsing function for a prefix token type in the parser's prefixParseFns map. It takes a token type and a prefix parsing function as arguments, and stores the function in the map under the given token type key.

(tokenType token.Type, fn prefixParseFn)

Source from the content-addressed store, hash-verified

823// It takes a token type and a prefix parsing function as arguments, and stores the function in the map
824// under the given token type key.
825func (p *Parser) registerPrefix(tokenType token.Type, fn prefixParseFn) {
826 if fn == nil {
827 p.duplicationError(fmt.Sprintf("registerPrefix: nil function for token type %s", tokenType))
828 return
829 }
830
831 if _, exists := p.prefixParseFns[tokenType]; exists {
832 p.duplicationError(fmt.Sprintf("registerPrefix: token type %s already registered", tokenType))
833 return
834 }
835
836 p.prefixParseFns[tokenType] = fn
837}
838
839// registerInfix safely registers a parsing function for an infix token type in the parser's infixParseFunc map.
840// It takes a token type and an infix parsing function as arguments, and stores the function in the map

Callers 1

NewParserFunction · 0.80

Calls 1

duplicationErrorMethod · 0.95

Tested by

no test coverage detected