Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "VIATRA2/Examples/VTCL/GraphPattern"

< VIATRA2‎ | Examples‎ | VTCL
(Pattern Matching Semantics)
(Pattern Matching Semantics)
Line 2: Line 2:
  
 
=== Pattern Matching Semantics ===
 
=== Pattern Matching Semantics ===
 +
 +
'''NOTE: The shareable keyword and thus noninjective matches will be available from VIATRA R4 (expected by the end of June, 2009).
 +
This description serves as a documentation of the new features.'''
 +
 +
Patterns may be composed in VTCL a complex way by using the '''find''' construct.
 +
Moreover, the injectivity of pattern matching can be further controlled by using the new '''shareable''' keyword as follows:
 +
* '''Injective pattern matching (default)''': the default behavior of the pattern matcher is that two local pattern variables cannot be bound to the same value (i.e. element in the model space). Pattern variable assignments (in the form of '''A=B''') can enforce that the two variables take the same value during pattern matching.
 +
* '''Shareable (or non-injective) pattern matching''': the injectivity condition is not checked for local pattern variables (thus two variables may be bound to the same value) unless a non-injectvity  constraint (in the form of '''A =/= B''') is prescribed explicitly for a pair of variables.
 +
 +
The following examples highlight the semantic corner cases using of pattern composition and injective pattern matching.
  
 
<source lang="text">
 
<source lang="text">
 
pattern parentPattern1(X, Y, Z) = {
 
pattern parentPattern1(X, Y, Z) = {
 +
 
}
 
}
  
sharedvar pattern parentPattern2(X, Y, Z) = {
+
shareable pattern parentPattern2(X, Y, Z) = {
 
}
 
}
  
 
pattern childPattern1(A, B) = {
 
pattern childPattern1(A, B) = {
 +
  state(A);
 +
  state.transition(T, A, B);
 +
  state(B);
 
}
 
}
  
sharedvar pattern childPattern2(A, B) = {
+
shareable pattern childPattern2(A, B) = {
 +
  state(A);
 +
  state.transition(T, A, B);
 +
  state(B);
 +
}
  
 +
// Equivalent with childPattern1: A != B
 +
pattern childPattern1A(A, B) = {
 +
  find childPattern2(A, B);
 
}
 
}
 +
 
</source>
 
</source>

Revision as of 09:45, 25 May 2009

Overview: Graph patterns

Pattern Matching Semantics

NOTE: The shareable keyword and thus noninjective matches will be available from VIATRA R4 (expected by the end of June, 2009). This description serves as a documentation of the new features.

Patterns may be composed in VTCL a complex way by using the find construct. Moreover, the injectivity of pattern matching can be further controlled by using the new shareable keyword as follows:

  • Injective pattern matching (default): the default behavior of the pattern matcher is that two local pattern variables cannot be bound to the same value (i.e. element in the model space). Pattern variable assignments (in the form of A=B) can enforce that the two variables take the same value during pattern matching.
  • Shareable (or non-injective) pattern matching: the injectivity condition is not checked for local pattern variables (thus two variables may be bound to the same value) unless a non-injectvity constraint (in the form of A =/= B) is prescribed explicitly for a pair of variables.

The following examples highlight the semantic corner cases using of pattern composition and injective pattern matching.

pattern parentPattern1(X, Y, Z) = {
 
}
 
shareable pattern parentPattern2(X, Y, Z) = {
}
 
pattern childPattern1(A, B) = {
  state(A);
  state.transition(T, A, B);
  state(B);
}
 
shareable pattern childPattern2(A, B) = {
  state(A);
  state.transition(T, A, B);
  state(B);
}
 
// Equivalent with childPattern1: A != B
pattern childPattern1A(A, B) = {
  find childPattern2(A, B);
}

Back to the top