diff options
author | 2021-10-31 19:41:24 +0100 | |
---|---|---|
committer | 2021-10-31 19:41:24 +0100 | |
commit | 7918d78948de7f349f9948837caf76f2a514c96c (patch) | |
tree | 0f7c24a9e0046dffd719d6a66be4a1f73b7fa4c7 /language-web/src/main/js/index.tsx | |
parent | Merge pull request #7 from golej-marci/language-to-store (diff) | |
parent | chore: bump dependency versions (diff) | |
download | refinery-7918d78948de7f349f9948837caf76f2a514c96c.tar.gz refinery-7918d78948de7f349f9948837caf76f2a514c96c.tar.zst refinery-7918d78948de7f349f9948837caf76f2a514c96c.zip |
Merge pull request #8 from kris7t/cm6
Switch to CodeMirror 6 editor and WebSocket-based transport for Xtext
Diffstat (limited to 'language-web/src/main/js/index.tsx')
-rw-r--r-- | language-web/src/main/js/index.tsx | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/language-web/src/main/js/index.tsx b/language-web/src/main/js/index.tsx index 80c70f23..dfecde37 100644 --- a/language-web/src/main/js/index.tsx +++ b/language-web/src/main/js/index.tsx | |||
@@ -9,23 +9,34 @@ import { ThemeProvider } from './theme/ThemeProvider'; | |||
9 | import '../css/index.scss'; | 9 | import '../css/index.scss'; |
10 | 10 | ||
11 | const initialValue = `class Family { | 11 | const initialValue = `class Family { |
12 | contains Person[] members | 12 | contains Person[] members |
13 | } | 13 | } |
14 | 14 | ||
15 | class Person { | 15 | class Person { |
16 | Person[] children opposite parent | 16 | Person[] children opposite parent |
17 | Person[0..1] parent opposite children | 17 | Person[0..1] parent opposite children |
18 | int age | 18 | int age |
19 | TaxStatus taxStatus | 19 | TaxStatus taxStatus |
20 | } | 20 | } |
21 | 21 | ||
22 | enum TaxStatus { | 22 | enum TaxStatus { |
23 | child, student, adult, retired | 23 | child, student, adult, retired |
24 | } | 24 | } |
25 | 25 | ||
26 | % A child cannot have any dependents. | 26 | % A child cannot have any dependents. |
27 | error invalidTaxStatus(Person p) <-> | 27 | pred invalidTaxStatus(Person p) <-> |
28 | taxStatus(p, child), children(p, _q). | 28 | taxStatus(p, child), |
29 | children(p, _q) | ||
30 | ; taxStatus(p, retired), | ||
31 | parent(p, q), | ||
32 | !taxStatus(q, retired). | ||
33 | |||
34 | direct rule createChild(p): | ||
35 | children(p, newPerson) = unknown, | ||
36 | equals(newPerson, newPerson) = unknown | ||
37 | ~> new q, | ||
38 | children(p, q) = true, | ||
39 | taxStatus(q, child) = true. | ||
29 | 40 | ||
30 | unique family. | 41 | unique family. |
31 | Family(family). | 42 | Family(family). |
@@ -44,8 +55,7 @@ age(bob, bobAge). | |||
44 | scope Family = 1, Person += 5..10. | 55 | scope Family = 1, Person += 5..10. |
45 | `; | 56 | `; |
46 | 57 | ||
47 | const rootStore = new RootStore(); | 58 | const rootStore = new RootStore(initialValue); |
48 | rootStore.editorStore.updateValue(initialValue); | ||
49 | 59 | ||
50 | const app = ( | 60 | const app = ( |
51 | <RootStoreProvider rootStore={rootStore}> | 61 | <RootStoreProvider rootStore={rootStore}> |