| 2505 | static Keyword formKey = Keyword.intern("form"); |
| 2506 | |
| 2507 | public Expr parse(C context, Object form){ |
| 2508 | int argCount = RT.count(form) - 1; |
| 2509 | if(argCount != 1){ |
| 2510 | IPersistentMap exData = new PersistentArrayMap(new Object[]{formKey, form}); |
| 2511 | throw new ExceptionInfo("Wrong number of args (" + |
| 2512 | argCount + |
| 2513 | ") passed to quote", |
| 2514 | exData); |
| 2515 | } |
| 2516 | Object v = RT.second(form); |
| 2517 | |
| 2518 | if(v == null) |
| 2519 | return NIL_EXPR; |
| 2520 | else if(v == Boolean.TRUE) |
| 2521 | return TRUE_EXPR; |
| 2522 | else if(v == Boolean.FALSE) |
| 2523 | return FALSE_EXPR; |
| 2524 | if(v instanceof Number) |
| 2525 | return NumberExpr.parse((Number)v); |
| 2526 | else if(v instanceof String) |
| 2527 | return new StringExpr((String) v); |
| 2528 | else if(v instanceof IPersistentCollection |
| 2529 | && (((IPersistentCollection) v).count() == 0) |
| 2530 | && (!(v instanceof IObj) || ((IObj) v).meta() == null)) |
| 2531 | return new EmptyExpr(v); |
| 2532 | else |
| 2533 | return new ConstantExpr(v); |
| 2534 | } |
| 2535 | } |
| 2536 | } |
| 2537 | |