MCPcopy Index your code
hub / github.com/endbasic/endbasic / find_syntax

Method find_syntax

core/src/callable.rs:673–686  ·  view source on GitHub ↗

Finds the syntax definition that matches the given argument count. Returns an error if no syntax matches, and panics if multiple syntaxes match (which would indicate an ambiguous callable definition).

(&self, nargs: usize)

Source from the content-addressed store, hash-verified

671 /// Returns an error if no syntax matches, and panics if multiple syntaxes match (which would
672 /// indicate an ambiguous callable definition).
673 pub(crate) fn find_syntax(&self, nargs: usize) -> Option<&CallableSyntax> {
674 let mut matches = self.syntaxes.iter().filter(|s| s.expected_nargs().contains(&nargs));
675 let syntax = matches.next();
676 match syntax {
677 Some(syntax) => {
678 debug_assert!(matches.next().is_none(), "Ambiguous syntax definitions");
679 if cfg!(debug_assertions) {
680 self.debug_assert_function_seps(syntax);
681 }
682 Some(syntax)
683 }
684 None => None,
685 }
686 }
687
688 /// Gets the callable's category as a collection of lines. The first line is the title of the
689 /// category, and any extra lines are additional information for it.

Callers 2

define_new_argsFunction · 0.80
compile_argsFunction · 0.80

Calls 4

iterMethod · 0.80
expected_nargsMethod · 0.80
nextMethod · 0.45

Tested by

no test coverage detected