source: CIVL/examples/languageFeatures/scopeOperators.cvl@ 32410ee

1.23 2.0 main test-branch
Last change on this file since 32410ee was 9f6b224, checked in by Manchun Zheng <zmanchun@…>, 12 years ago

added $scope_parent() method; implemented scope operators (+, ==, <, <=, >, >=).

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@679 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 629 bytes
Line 
1#include <civlc.h>
2
3void main(){
4 $scope s = $here, t = $here;
5 $scope p = $scope_parent(s);
6 $gcomm g = $gcomm_create(p, 5);
7 $gcomm f;
8
9 void foo(){
10 $scope fs = $here;
11 $scope sum = fs + s;// compute the lowest common ancestors of fs and s.
12
13 $assert(s > fs);
14 $assert(sum == s);
15 }
16
17 f = g;
18 g = f;
19 foo();
20 $assert(s == t);
21 $assert(s != p);
22 $assert(s <= p);// s is equal to p or s is strictly a descendant of p.
23 $assert(s < p);// s is strictly a descendant of p
24 $assert(p >= s);// p is equal to s or p is strictly an ancestor of s.
25 $assert(p > s);// p is strictly a ancestor of s.
26}
Note: See TracBrowser for help on using the repository browser.