Skip to content

Commit cb99eee

Browse files
jurgenvinjuDavyLandman
authored andcommitted
changed pico checker to use a block function for example. also reformatted a switch and changed list to tuple syntax for better efficiency
1 parent b96ff23 commit cb99eee

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/examples/pico/Checker.rsc

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ str prettyAType(strType()) = "str";
2727
// ---- Collect definitions, uses and requirements -----------------------
2828

2929
void collect(current: (Program) `begin <Declarations decls> <{Statement ";"}* body> end`, Collector c){
30-
c.enterScope(current);
30+
c.scope(current, () {
3131
collect(decls, body, c);
32-
c.leaveScope(current);
32+
});
3333
}
3434

3535
void collect(current: (Declarations) `declare <{Declaration ","}* decls> ;`, Collector c){
@@ -71,15 +71,18 @@ void collect(current: (Statement) `while <Expression cond> do <{Statement ";"}*
7171

7272
void collect(current: (Expression) `<Expression lhs> + <Expression rhs>`, Collector c){
7373
c.calculate("addition", current, [lhs, rhs],
74-
AType (Solver s) { switch([s.getType(lhs), s.getType(rhs)]){
75-
case [intType(), intType()]: return intType();
76-
case [strType(), strType()]: return strType();
77-
default: {
74+
AType (Solver s) {
75+
switch(<s.getType(lhs), s.getType(rhs)>){
76+
case <intType(), intType()>:
77+
return intType();
78+
case <strType(), strType()>:
79+
return strType();
80+
default: {
7881
s.report(error(current, "Operator `+` cannot be applied to %t and %t", lhs, rhs));
7982
return intType();
80-
}
81-
}
82-
});
83+
}
84+
}
85+
});
8386
collect(lhs, rhs, c);
8487
}
8588

0 commit comments

Comments
 (0)