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
69
70
71
72
|
module static-semantics/webdsl-expand
imports
static-semantics/entities/annotations
static-semantics/types/built-ins
static-semantics/webdsl
static-semantics/webdsl-actions
static-semantics/webdsl-types
static-semantics/webdsl-ui
rules // unimplemented
defOk(_, ExpandTemplateCall(_, _)) :- try { false } | warning $[This definition is not yet implemented].
defOk(_, ExpandTemplateDefinition(_, _, _)) :- try { false } | warning $[This definition is not yet implemented].
stmtOk(_, _, StatementExpandLocal(_, _, _), _) :- try { false } | warning $[This statement is not yet implemented].
typeOfExp(_, exp@ExpExpandLocal(_, _, _)) = UNTYPED() :- try { false } | warning $[Typing of expression [exp] is not yet implemented].
rules
templateElementOk(s, _, s_pha, DeriveNoFromNoFor(p, body)) :-
deriveStringOk(p),
deriveBodyOk(s, s_pha, body),
false | error $[Cannot derive for non-entity types, use syntax "derive <pagetype> from <var> { ... }"].
templateElementOk(, _, s_pha, Derive(, , props, body)) :- { }
deriveStringOk(p),
t == typeOfExp(s, exp),
typeCompatible(t, entity(s)) | error $[Cannot derive for non-entity types] @exp,
derivePropertiesOk(s, t, p, props),
deriveBodyOk(s, s_pha, body).
: string
deriveStringOk(_) :- false | error $[Can only derive "viewPage", "createPage" or "editPage"].
deriveStringOk("viewPage").
deriveStringOk("viewRows").
deriveStringOk("createPage").
deriveStringOk("editPage").
deriveStringOk("editRows").
deriveStringOk("editRowsInline").
derivePropertiesOk maps derivePropertyOk(*, *, *, list(*))
: scope * TYPE * string * DeriveProperty
derivePropertyOk(_, _, _, _) :- try { false } | warning $[This element is not yet supported].
derivePropertyOk(s, , _, DeriveDefault()) :- { t }
t_ent == ENTITY(entityName, _),
t == typeOfProperty(s, t_ent, prop) | error $[Entity [entityName] has no property [prop]], // correct error message for tests
isMutableProperty(t_ent, prop) | error $[Property [prop] is not mutable].
derivePropertyOk(s, , "viewPage", DeriveDefault()) :- { t }
t_ent == ENTITY(entityName, _),
t == typeOfProperty(s, t_ent, prop) | error $[Entity [entityName] has no property [prop]]. // correct error message for tests
derivePropertyOk(s, , "viewRows", DeriveDefault()) :- { t }
t_ent == ENTITY(entityName, _),
t == typeOfProperty(s, t_ent, prop) | error $[Entity [entityName] has no property [prop]]. // correct error message for tests
: scope * scope * DeriveBody
deriveBodyOk(s, s_pha, DeriveBody(elements)) :- deriveBodyElementsOk(s, s_pha, elements).
deriveBodyElementsOk maps deriveBodyElementOk(*, *, list(*))
: scope * scope * DeriveBodyElement
deriveBodyElementOk(_, _, _) :- try { false } | warning $[This element is not yet supported].
rules
defOk(, DeriveCrud()) :- { }
t == typeOfSort(s, SimpleSort(ent)) | error $[The entity [ent] does not exist],
typeCompatible(t, entity(s)) | error $[The entity [ent] does not exist].
|