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

Method registerInfix

pkg/dsl/parser/parser.go:842–854  ·  view source on GitHub ↗

registerInfix safely registers a parsing function for an infix token type in the parser's infixParseFunc map. It takes a token type and an infix parsing function as arguments, and stores the function in the map under the given token type key.

(tokenType token.Type, fn infixParseFn)

Source from the content-addressed store, hash-verified

840// It takes a token type and an infix parsing function as arguments, and stores the function in the map
841// under the given token type key.
842func (p *Parser) registerInfix(tokenType token.Type, fn infixParseFn) {
843 if fn == nil {
844 p.duplicationError(fmt.Sprintf("registerInfix: nil function for token type %s", tokenType))
845 return
846 }
847
848 if _, exists := p.infixParseFunc[tokenType]; exists {
849 p.duplicationError(fmt.Sprintf("registerInfix: token type %s already registered", tokenType))
850 return
851 }
852
853 p.infixParseFunc[tokenType] = fn
854}
855
856// duplicationError adds an error message to the parser's error list indicating that a duplication was found.
857// It takes a key string as an argument that is used to identify the source of the duplication in the input.

Callers 1

NewParserFunction · 0.80

Calls 1

duplicationErrorMethod · 0.95

Tested by

no test coverage detected