@{
|
|
println(x) { print(x, "\n"); }
|
|
|
|
treeCopy(x) {
|
|
l = {};
|
|
k = _keys(x);
|
|
if (k == null) {
|
|
return clone(x);
|
|
} else {
|
|
for (i in k) {
|
|
l[k[i]] = clone(treeCopy(x[k[i]]));
|
|
}
|
|
return clone(l);
|
|
}
|
|
}
|
|
|
|
getId(x) { { identifier: x, __proto__: C_id }; }
|
|
|
|
getEnum(x) { { attributeL: null, expression: null, name: getId(x), __proto__: C_enum }; }
|
|
|
|
getComma() { { text: ",", comment: { text : " ", __proto__: Comment }, __proto__: Token }; }
|
|
|
|
getComment(x) { { text : x, __proto__: Comment }; }
|
|
|
|
// adding the element e at the end of the list l
|
|
append(s, e) {
|
|
s[length(s)] = e;
|
|
}
|
|
|
|
// If g then we add a filter on the application of the function f to each element of seq
|
|
map(f, seq, g) {
|
|
out = {};
|
|
if (g) {
|
|
for (i in seq) {
|
|
e = seq[i];
|
|
if (g(e)) { e = f(e); }
|
|
append(out, e);
|
|
}
|
|
} else {
|
|
for (i in seq) {
|
|
append(out, f(seq[i]));
|
|
}
|
|
}
|
|
out;
|
|
}
|
|
|
|
notToken(x) { x.__proto__ != Token }
|
|
|
|
// Select element e of s if the the result of the application of f on e is true
|
|
select(f, s) {
|
|
out = {};
|
|
for (i in s) {
|
|
e = s[i];
|
|
if (f(e)) { append(out, e); }
|
|
}
|
|
out;
|
|
}
|
|
|
|
// Select element e of s if the the result of the application of f on e is false
|
|
reject(f, s) {
|
|
out = {};
|
|
for (i in s) {
|
|
e = s[i];
|
|
if (!f(e)) { append(out, e); }
|
|
}
|
|
out;
|
|
}
|
|
|
|
// Get the last element of s
|
|
last(s) {
|
|
s[length(s)-1];
|
|
}
|
|
|
|
nil;
|
|
}
|