Module: BELParser::Language::Semantics
- Defined in:
- lib/bel_parser/language/semantics.rb,
lib/bel_parser/language/semantics_ast.rb,
lib/bel_parser/language/semantics_match.rb,
lib/bel_parser/language/semantics_result.rb,
lib/bel_parser/language/semantics_warning.rb,
lib/bel_parser/language/semantics_function.rb,
lib/bel_parser/language/semantics_ast_warnings.rb,
lib/bel_parser/language/semantics_type_warning.rb,
lib/bel_parser/language/semantics/non_object_list.rb,
lib/bel_parser/language/semantics/signature_mapping.rb,
lib/bel_parser/language/semantics/function_deprecation.rb,
lib/bel_parser/language/semantics/list_function_subject.rb,
lib/bel_parser/language/semantics/deeply_nested_statement.rb,
lib/bel_parser/language/semantics/multiple_subject_object.rb,
lib/bel_parser/language/semantics/relationship_deprecation.rb,
lib/bel_parser/language/semantics/relationship_not_listable.rb,
lib/bel_parser/language/semantics/non_causal_nested_statement.rb
Overview
Semantics capture BEL version-independent semantics for terms and statements.
Defined Under Namespace
Modules: Builder, SemanticsFunction Classes: DeeplyNestedStatement, DeeplyNestedStatementWarning, FunctionDeprecation, FunctionDeprecationWarning, ListFunctionSubject, ListFunctionSubjectWarning, MultipleSubjectObject, MultipleSubjectObjectWarning, NonCausalNestedStatement, NonCausalNestedStatementWarning, NonObjectList, NonObjectListWarning, RelationshipDeprecation, RelationshipDeprecationWarning, RelationshipNotListable, RelationshipNotMultipleWarning, SemanticASTNode, SemanticAminoAcidOf, SemanticAny, SemanticArgument, SemanticCovalentProteinModificationOf, SemanticEncodingOf, SemanticFunction, SemanticFunctionOf, SemanticHasEncoding, SemanticHasNamespace, SemanticIdentifier, SemanticIsAminoAcidRange, SemanticIsNil, SemanticIsSequencePosition, SemanticMatch, SemanticNamespaceOf, SemanticParameter, SemanticPrefix, SemanticReturnTypeOf, SemanticStatement, SemanticTerm, SemanticValue, SemanticVariadicArguments, SemanticsArgumentLengthWarning, SemanticsInvalidAminoAcidRangeWarning, SemanticsInvalidAminoAcidWarning, SemanticsInvalidEncodingWarning, SemanticsInvalidFunctionWarning, SemanticsInvalidNamespaceWarning, SemanticsInvalidProteinModificationWarning, SemanticsInvalidReturnTypeWarning, SemanticsInvalidSequencePositionWarning, SemanticsMissingEncodingWarning, SemanticsMissingNamespaceWarning, SemanticsNilNodeWarning, SemanticsNotNilNodeWarning, SemanticsResult, SemanticsTypeWarning, SemanticsWarning, SignatureMapping, SignatureMappingSuccess, SignatureMappingWarning, Valid
Class Method Summary collapse
-
.match(input_ast, semantic_ast, spec, match_results = []) ⇒ Object
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize.
- .semantics_functions ⇒ Object
Class Method Details
.match(input_ast, semantic_ast, spec, match_results = []) ⇒ Object
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/bel_parser/language/semantics_ast.rb', line 13 def self.match(input_ast, semantic_ast, spec, match_results = []) res = semantic_ast.match(input_ast, spec) match_results.concat(res) if res.flatten.all?(&:success?) && !semantic_ast.terminal? return match_results if semantic_ast.children.empty? var_test = semantic_ast.children.any? do |x| x.is_a?(SemanticVariadicArguments) end if var_test test_pairs = input_ast .children .zip(semantic_ast.children) .select do |pair| !pair.include?(nil) end test_pairs.each do |(input_child, semantic_child)| if semantic_child.is_a?(SemanticVariadicArguments) input_children = input_ast.children input_arguments = input_children[input_children.index(input_child)..-1] argument_pattern = semantic_child.children.first input_arguments.each do |argument_child| res = semantic_child.match(argument_child, spec) match_results << res if res.all?(&:success?) param_or_term = argument_child.children.first match(param_or_term, argument_pattern, spec, match_results) end end else match(input_child, semantic_child, spec, match_results) end end else semantic_ast .children .zip(input_ast.children) .each do |semantic_child, input_child| match(input_child, semantic_child, spec, match_results) end end end match_results.flatten end |
.semantics_functions ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/bel_parser/language/semantics.rb', line 13 def self.semantics_functions constants.collect do |symbol| const = const_get(symbol) const if const.respond_to?(:include?) && const.include?(SemanticsFunction) end.compact end |