aboutsummaryrefslogtreecommitdiffstats
path: root/language-web/src/main/js/index.tsx
blob: 86cb4a65daa92aabf398ac2ea87d1974dee3a44b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { CacheProvider } from '@emotion/react';
import React from 'react';
import { render } from 'react-dom';
import CssBaseline from '@material-ui/core/CssBaseline';
import createCache from 'tss-react/@emotion/cache';

import { App } from './App';
import { RootStore, RootStoreProvider } from './RootStore';
import { ThemeProvider } from './theme/ThemeProvider';

import '../css/index.scss';

const initialValue = `class Family {
  contains Person[] members
}

class Person {
  Person[] children opposite parent
  Person[0..1] parent opposite children
  int age
  TaxStatus taxStatus
}

enum TaxStatus {
  child, student, adult, retired
}

% A child cannot have any dependents.
error invalidTaxStatus(Person p) <->
  taxStatus(p, child), children(p, _q).

unique family.
Family(family).
members(family, anne).
members(family, bob).
members(family, ciri).
children(anne, ciri).
?children(bob, ciri).
default children(ciri, *): false.
taxStatus(anne, adult).
age(anne, 35).
bobAge: 27.
age(bob, bobAge).
!age(ciri, bobAge).

scope Family = 1, Person += 5..10.
`;

const rootStore = new RootStore();
rootStore.editorStore.updateValue(initialValue);

const muiCache = createCache({
  key: 'mui',
  prepend: true,
});

const app = (
  <RootStoreProvider rootStore={rootStore}>
    <CacheProvider value={muiCache}>
      <ThemeProvider>
        <CssBaseline />
        <App />
      </ThemeProvider>
    </CacheProvider>
  </RootStoreProvider>
);

render(app, document.getElementById('app'));