Module: BELParser::Language::Semantics::Builder

Defined in:
lib/bel_parser/language/semantics_ast.rb

Overview

Builder contains methods to build semantic AST nodes. A convenient Builder.build method allows you to use these methods within a block scope.

see Builder.build

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build(&block) ⇒ Object

Raises:

  • (ArgumentError)


69
70
71
72
73
74
# File 'lib/bel_parser/language/semantics_ast.rb', line 69

def self.build(&block)
  raise ArgumentError, 'expecting block' unless block_given?

  builder = _builder_class.new
  builder.instance_eval(&block)
end

Instance Method Details

#amino_acid_of(*amino_acids, **properties) ⇒ Object



153
154
155
# File 'lib/bel_parser/language/semantics_ast.rb', line 153

def amino_acid_of(*amino_acids, **properties)
  SemanticAminoAcidOf.new(amino_acids, **properties)
end

#any(**properties) ⇒ Object



116
117
118
# File 'lib/bel_parser/language/semantics_ast.rb', line 116

def any(**properties)
  SemanticAny.new(**properties)
end

#argument(param_or_term, **properties) ⇒ Object



91
92
93
94
95
96
97
98
# File 'lib/bel_parser/language/semantics_ast.rb', line 91

def argument(param_or_term, **properties)
  cls = param_or_term.class
  if cls != SemanticParameter && cls != SemanticTerm
    raise ArgumentError, 'expected SemanticParameter or SemanticTerm'
  end

  SemanticArgument.new([param_or_term], **properties)
end

#covalent_protein_modification_of(*mod_types, **properties) ⇒ Object



149
150
151
# File 'lib/bel_parser/language/semantics_ast.rb', line 149

def covalent_protein_modification_of(*mod_types, **properties)
  SemanticCovalentProteinModificationOf.new(mod_types, **properties)
end

#encoding_of(*encoding_types, **properties) ⇒ Object



145
146
147
# File 'lib/bel_parser/language/semantics_ast.rb', line 145

def encoding_of(*encoding_types, **properties)
  SemanticEncodingOf.new(encoding_types, **properties)
end

#function(identifier, **properties) ⇒ Object



87
88
89
# File 'lib/bel_parser/language/semantics_ast.rb', line 87

def function(identifier, **properties)
  SemanticFunction.new([identifier], **properties)
end

#function_of(*functions, **properties) ⇒ Object



133
134
135
# File 'lib/bel_parser/language/semantics_ast.rb', line 133

def function_of(*functions, **properties)
  SemanticFunctionOf.new(functions, **properties)
end

#has_encoding(**properties) ⇒ Object



129
130
131
# File 'lib/bel_parser/language/semantics_ast.rb', line 129

def has_encoding(**properties)
  SemanticHasEncoding.new(**properties)
end

#has_namespace(**properties) ⇒ Object



125
126
127
# File 'lib/bel_parser/language/semantics_ast.rb', line 125

def has_namespace(**properties)
  SemanticHasNamespace.new(**properties)
end

#identifier(*value_patterns, **properties) ⇒ Object



104
105
106
# File 'lib/bel_parser/language/semantics_ast.rb', line 104

def identifier(*value_patterns, **properties)
  SemanticIdentifier.new(value_patterns, **properties)
end

#is_amino_acid_range_pattern(**properties) ⇒ Object



157
158
159
# File 'lib/bel_parser/language/semantics_ast.rb', line 157

def is_amino_acid_range_pattern(**properties)
  SemanticIsAminoAcidRange.new(**properties)
end

#is_nil(**properties) ⇒ Object

rubocop:disable Style/PredicateName



121
122
123
# File 'lib/bel_parser/language/semantics_ast.rb', line 121

def is_nil(**properties)
  SemanticIsNil.new(**properties)
end

#is_sequence_position(**properties) ⇒ Object



161
162
163
# File 'lib/bel_parser/language/semantics_ast.rb', line 161

def is_sequence_position(**properties)
  SemanticIsSequencePosition.new(**properties)
end

#namespace_of(*namespaces, **properties) ⇒ Object



141
142
143
# File 'lib/bel_parser/language/semantics_ast.rb', line 141

def namespace_of(*namespaces, **properties)
  SemanticNamespaceOf.new(namespaces, **properties)
end

#parameter(prefix, value, **properties) ⇒ Object



100
101
102
# File 'lib/bel_parser/language/semantics_ast.rb', line 100

def parameter(prefix, value, **properties)
  SemanticParameter.new([prefix, value], **properties)
end

#prefix(*prefix_patterns, **properties) ⇒ Object



108
109
110
# File 'lib/bel_parser/language/semantics_ast.rb', line 108

def prefix(*prefix_patterns, **properties)
  SemanticPrefix.new(prefix_patterns, **properties)
end

#return_type_of(*return_types, **properties) ⇒ Object



137
138
139
# File 'lib/bel_parser/language/semantics_ast.rb', line 137

def return_type_of(*return_types, **properties)
  SemanticReturnTypeOf.new(return_types, **properties)
end

#term(function, *arguments, **properties) ⇒ Object



83
84
85
# File 'lib/bel_parser/language/semantics_ast.rb', line 83

def term(function, *arguments, **properties)
  SemanticTerm.new([function, *arguments], **properties)
end

#value(*value_patterns, **properties) ⇒ Object



112
113
114
# File 'lib/bel_parser/language/semantics_ast.rb', line 112

def value(*value_patterns, **properties)
  SemanticValue.new(value_patterns, **properties)
end

#variadic_arguments(*params_or_terms, **properties) ⇒ Object



165
166
167
# File 'lib/bel_parser/language/semantics_ast.rb', line 165

def variadic_arguments(*params_or_terms, **properties)
  SemanticVariadicArguments.new(params_or_terms, **properties)
end