| 619 | |
| 620 | static class Parser implements IParser{ |
| 621 | public Expr parse(C context, Object frm) { |
| 622 | ISeq form = (ISeq) frm; |
| 623 | if(RT.length(form) != 3) |
| 624 | throw new IllegalArgumentException("Malformed assignment, expecting (set! target val)"); |
| 625 | Expr target = analyze(C.EXPRESSION, RT.second(form)); |
| 626 | if(!(target instanceof AssignableExpr)) |
| 627 | throw new IllegalArgumentException("Invalid assignment target"); |
| 628 | return new AssignExpr((AssignableExpr) target, analyze(C.EXPRESSION, RT.third(form))); |
| 629 | } |
| 630 | } |
| 631 | } |
| 632 | |