forked from xmf-xmodeler/Mosaic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOrgML.xmf
47 lines (41 loc) · 1.23 KB
/
OrgML.xmf
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
parserImport XOCL;
context Root
@Package MEMO
@Bind ATT = "ATT" end
@Bind BOOL = "BOOL" end
@Bind CLASS = "CLASS" end
@Bind CONST = "CONST" end
@Bind INFO = "INFO" end
@Bind INT = "INT" end
@Bind MODEL = "MODEL" end
@Bind OBJ = "OBJ" end
@Bind PATH = "PATH" end
@Bind SLOT = "SLOT" end
@Bind STR = "STR" end
@Operation argString(arg)
@Case arg of
Seq{t | rest} when t = PATH do formats("~{::~;~S~}",Seq{rest}) end
Seq{t,v} when t = CONST do formats("~S",Seq{v}) end
else arg.toString()
end
end
@Operation display(ast,out,indent)
@Case ast of
Seq{type | rest} do
format(out, "~V~S ~{,~;~S~}~%",Seq{indent,type,rest->select(x | isArg(x))->collect(x | argString(x))});
@For element in rest->reject(x | isArg(x)) do
display(element,out,indent + 2)
end
end
else format(out, "~V~S~%",Seq{indent,ast})
end
end
@Operation isArg(x)
@Case x of
Seq{t | rest} when t = PATH do true end
Seq{t | rest} when t = CONST do true end
Seq{t | rest} do false end
else true
end
end
end