aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/frontend/src/index.tsx
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2022-11-19 21:39:00 +0100
committerLibravatar Kristóf Marussy <kristof@marussy.com>2022-11-22 16:40:03 +0100
commit3aa4a2b58221a3e83b17d0c04c9a6e9c41e5500c (patch)
tree1e25f513e3b34b2ea29dbcc6cc3795e5927a1362 /subprojects/frontend/src/index.tsx
parentfeat(language): numeric expressions (diff)
downloadrefinery-3aa4a2b58221a3e83b17d0c04c9a6e9c41e5500c.tar.gz
refinery-3aa4a2b58221a3e83b17d0c04c9a6e9c41e5500c.tar.zst
refinery-3aa4a2b58221a3e83b17d0c04c9a6e9c41e5500c.zip
refactor: separate primitive types from nodes
Diffstat (limited to 'subprojects/frontend/src/index.tsx')
-rw-r--r--subprojects/frontend/src/index.tsx21
1 files changed, 8 insertions, 13 deletions
diff --git a/subprojects/frontend/src/index.tsx b/subprojects/frontend/src/index.tsx
index b42b8062..0165d7c1 100644
--- a/subprojects/frontend/src/index.tsx
+++ b/subprojects/frontend/src/index.tsx
@@ -10,27 +10,24 @@ const initialValue = `class Family {
10} 10}
11 11
12class Person { 12class Person {
13 Person[] children opposite parent 13 refers Person[] children opposite parent
14 Person[0..1] parent opposite children 14 refers Person[0..1] parent opposite children
15 int age 15 int age
16 TaxStatus taxStatus 16 refers TaxStatus taxStatus
17} 17}
18 18
19enum TaxStatus { 19enum TaxStatus {
20 child, student, adult, retired 20 child, student, adult, retired
21} 21}
22 22
23int ageDifference(Person p, Person q) =
24 children(p, q), age(p, pAge), age(q, qAge) -> qAge - pAge.
25
26error invalidAgeDifference(Person p, Person q) <->
27 children(p, q), ageDifference(p, q) <= 0.
28
29% A child cannot have any dependents. 23% A child cannot have any dependents.
30pred invalidTaxStatus(Person p) <-> 24pred invalidTaxStatus(Person p) <->
31 taxStatus(p, child), 25 taxStatus(p, child),
32 children(p, _q) 26 children(p, _q)
33; 27;
28 parent(p, q),
29 age(q) < age(p)
30;
34 taxStatus(p, retired), 31 taxStatus(p, retired),
35 parent(p, q), 32 parent(p, q),
36 !taxStatus(q, retired). 33 !taxStatus(q, retired).
@@ -44,10 +41,8 @@ children(anne, ciri).
44?children(bob, ciri). 41?children(bob, ciri).
45default children(ciri, *): false. 42default children(ciri, *): false.
46taxStatus(anne, adult). 43taxStatus(anne, adult).
47age(anne, 35). 44age(bob) in 21..35.
48bobAge: 27. 45age(ciri) = 10.
49age(bob, bobAge).
50!age(ciri, bobAge).
51 46
52scope Family = 1, Person += 5..10. 47scope Family = 1, Person += 5..10.
53`; 48`;