Class: Pione::PNML::Perspective

Inherits:
Object
  • Object
show all
Defined in:
lib/pione/pnml/pione-model.rb

Overview

Perspective is a meta class for PIONE's concepts overlayed in PNML.

Constant Summary collapse

TRANSFORMER_OPT =
{package_name: "", editor: "", tag: "", filename: ""}

Class Method Summary collapse

Class Method Details

.case_transition?(env, node) ⇒ Boolean

Return true if the node is a transition with keyword "case".

Parameters:

Returns:

  • (Boolean)

    true if the node is a transition with keyword "case"



304
305
306
# File 'lib/pione/pnml/pione-model.rb', line 304

def case_transition?(env, node)
  match_transition_parser?(env, node, :case_transition)
end

.constraint_transition?(env, node) ⇒ Boolean

Return true if the node is a transition with keyword "constraint".

Parameters:

Returns:

  • (Boolean)

    true if the node is a transition with keyword "constraint"



328
329
330
# File 'lib/pione/pnml/pione-model.rb', line 328

def constraint_transition?(env, node)
  match_transition_parser?(env, node, :constraint_transition)
end

.data_modifier(env, node) ⇒ String

Return the modifier of node name.

Parameters:

Returns:

  • (String)

    modifier or nil



228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/pione/pnml/pione-model.rb', line 228

def data_modifier(env, node)
  if node.kind_of?(Place) and not(node.name.nil?)
    begin
      parsed = Parser.new.data_place.parse(node.name)
      if parsed.kind_of?(Hash)
        return parsed[:modifier].to_s
      end
    rescue Parslet::ParseFailed
      begin
        parsed = Parser.new.empty_place.parse(node.name)
        if parsed.kind_of?(Hash)
          return parsed[:modifier].to_s
        end
      rescue Parslet::ParseFailed
      end
    end
  end
  return nil
end

.data_place?(env, node) ⇒ Boolean

Return true if the node is a data place.

Parameters:

Returns:

  • (Boolean)

    true if the node is a data place



64
65
66
# File 'lib/pione/pnml/pione-model.rb', line 64

def data_place?(env, node)
  match_place_parser_with_type?(env, node, :data_place, :expr, Lang::TypeDataExpr)
end

.else_transition?(env, node) ⇒ Boolean

Return true if the node is a transition with keyword "else".

Parameters:

Returns:

  • (Boolean)

    true if the node is a transition with keyword "else"



292
293
294
# File 'lib/pione/pnml/pione-model.rb', line 292

def else_transition?(env, node)
  match_transition_parser?(env, node, :else_transition)
end

.empty?(env, node) ⇒ Boolean

Return true if the node is empty.

Parameters:

Returns:

  • (Boolean)

    true if the node is empty



16
17
18
# File 'lib/pione/pnml/pione-model.rb', line 16

def empty?(env, node)
  empty_place?(env, node) or empty_transition?(env, node)
end

.empty_place?(env, node) ⇒ Boolean

Return true if the node is an empty place.

Parameters:

Returns:

  • (Boolean)

    true if the node is an empty place



28
29
30
# File 'lib/pione/pnml/pione-model.rb', line 28

def empty_place?(env, node)
  match_place_parser?(env, node, :empty_place)
end

.empty_transition?(env, node) ⇒ Boolean

Return true if the node is an empty transition.

Parameters:

Returns:

  • (Boolean)

    true if the node is an empty transition



40
41
42
# File 'lib/pione/pnml/pione-model.rb', line 40

def empty_transition?(env, node)
  match_transition_parser?(env, node, :empty_transition)
end

.eval_param_sentence(env, node) ⇒ Object

Evaluate the node as a parameter sentence.

Parameters:

Returns:

  • (Object)

    evaluated result



132
133
134
# File 'lib/pione/pnml/pione-model.rb', line 132

def eval_param_sentence(env, node)
  eval_transition(env, node, :param_sentence, :param_sentence)
end

.expr_place?(env, node) ⇒ Boolean

Return true if the node is an expression place.

Parameters:

Returns:

  • (Boolean)

    true if the node is an exression place



52
53
54
# File 'lib/pione/pnml/pione-model.rb', line 52

def expr_place?(env, node)
  match_place_parser?(env, node, :expr_place)
end

.external_rule_transition?(env, node) ⇒ Boolean

Return ture if the node is an external rule.

Parameters:

Returns:

  • (Boolean)

    true if the node is an external rule



216
217
218
# File 'lib/pione/pnml/pione-model.rb', line 216

def external_rule_transition?(env, node)
  match_transition_parser?(env, node, :external_rule_transition)
end

.feature_place?(env, node) ⇒ Boolean

Return true if the node is a feature place.

Parameters:

Returns:

  • (Boolean)

    true if the node is a feature place



156
157
158
# File 'lib/pione/pnml/pione-model.rb', line 156

def feature_place?(env, node)
  match_place_parser_with_type?(env, node, :expr_place, :expr, Lang::TypeFeature)
end

.feature_transition?(env, node) ⇒ Boolean

Return true if the node is a feature transition.

Parameters:

Returns:

  • (Boolean)

    true if the node is a feature transition



168
169
170
# File 'lib/pione/pnml/pione-model.rb', line 168

def feature_transition?(env, node)
  match_place_parser?(env, node, :feature_sentence)
end

.if_transition?(env, node) ⇒ Boolean

Return true if the node is a transition with keyword "if".

Parameters:

Returns:

  • (Boolean)

    true if the node is a transition with keyword "if"



268
269
270
# File 'lib/pione/pnml/pione-model.rb', line 268

def if_transition?(env, node)
  match_transition_parser?(env, node, :if_transition)
end

.internal_rule_transition?(env, node) ⇒ Boolean

Return ture if the node is an internal rule.

Parameters:

Returns:

  • (Boolean)

    true if the node is an internal rule



204
205
206
# File 'lib/pione/pnml/pione-model.rb', line 204

def internal_rule_transition?(env, node)
  match_transition_parser?(env, node, :internal_rule_transition)
end

.keyword_transition?(env, node) ⇒ Boolean

Return true if the node is a transition with keyword.

Parameters:

Returns:

  • (Boolean)

    true if the node is a transition with keyword



256
257
258
# File 'lib/pione/pnml/pione-model.rb', line 256

def keyword_transition?(env, node)
  match_transition_parser?(env, node, :keyword_transition)
end

.net_input_data_place?(env, node) ⇒ Boolean

Return true if the node is a net input data place.

Parameters:

Returns:

  • (Boolean)

    true if the node is a net input data place



76
77
78
79
80
81
82
# File 'lib/pione/pnml/pione-model.rb', line 76

def net_input_data_place?(env, node)
  if data_place?(env, node)
    return net_input_data_symbol?(data_modifier(env, node))
  else
    return false
  end
end

.net_output_data_place?(env, node) ⇒ Boolean

Return true if the node is a net output data place.

Parameters:

Returns:

  • (Boolean)

    true if the node is a net output data place



92
93
94
95
96
97
98
# File 'lib/pione/pnml/pione-model.rb', line 92

def net_output_data_place?(env, node)
  if data_place?(env, node)
    return net_output_data_symbol?(data_modifier(env, node))
  else
    return false
  end
end

.param_place?(env, node) ⇒ Boolean

Return true if the node is a parameter.

Parameters:

Returns:

  • (Boolean)

    true if the node is a parameter



108
109
110
# File 'lib/pione/pnml/pione-model.rb', line 108

def param_place?(env, node)
  match_place_parser_with_type?(env, node, :expr_place, :expr, Lang::TypeParameterSet)
end

.param_transition?(env, node) ⇒ Boolean

Return true if the node is a parameter sentence transition.

Parameters:

Returns:

  • (Boolean)

    true if the node is a parameter sentence transition



120
121
122
# File 'lib/pione/pnml/pione-model.rb', line 120

def param_transition?(env, node)
  match_transition_parser?(env, node, :param_sentence)
end

.rule_transition?(env, node) ⇒ Boolean

Return true if the node is a rule.

Parameters:

Returns:

  • (Boolean)

    true if the node is a rule.



192
193
194
# File 'lib/pione/pnml/pione-model.rb', line 192

def rule_transition?(env, node)
  match_transition_parser?(env, node, :rule_transition)
end

.then_transition?(env, node) ⇒ Boolean

Return true if the node is a transition with keyword "then".

Parameters:

Returns:

  • (Boolean)

    true if the node is a transition with keyword "then"



280
281
282
# File 'lib/pione/pnml/pione-model.rb', line 280

def then_transition?(env, node)
  match_transition_parser?(env, node, :then_transition)
end

.ticket_place?(env, node) ⇒ Boolean

Return true if the node is a ticket place.

Parameters:

Returns:

  • (Boolean)

    true if the node is a ticket place



144
145
146
# File 'lib/pione/pnml/pione-model.rb', line 144

def ticket_place?(env, node)
  match_place_parser_with_type?(env, node, :expr_place, :expr, Lang::TypeTicketExpr)
end

.variable_binding_transition?(env, node) ⇒ Boolean

Return true if the node is a variable binding transition.

Parameters:

Returns:

  • (Boolean)

    true if the node is a variable binding transition



180
181
182
# File 'lib/pione/pnml/pione-model.rb', line 180

def variable_binding_transition?(env, node)
  match_transition_parser?(env, node, :variable_binding_sentence)
end

.when_transition?(env, node) ⇒ Boolean

Return true if the node is a transition with keyword "when".

Parameters:

Returns:

  • (Boolean)

    true if the node is a transition with keyword "when"



316
317
318
# File 'lib/pione/pnml/pione-model.rb', line 316

def when_transition?(env, node)
  match_transition_parser?(env, node, :when_transition)
end