public override IAstNode Constant(Constant constant) { var unparsedNumber = constant.Value as UnparsedNumber; if (unparsedNumber != null) return new Constant(unparsedNumber.Parse()); return base.Constant(constant); }
void Factor(out Expression e) { string name; Expression e1; e = null; if (la.kind == 1) { Ident(out name); e = new Variable(name); if (la.kind == 3) { Get(); Expr(out e1); Expect(4); e = new FunctionCall(name, e1); } } else if (la.kind == 2) { Get(); e = new Constant(int.Parse(t.val), Type.IntegerType); } else if (la.kind == 18) { Get(); Factor(out e1); e = new UnaryOperation(Operator.Neg, e1); } else if (la.kind == 3) { Get(); Expr(out e1); Expect(4); e = e1; } else SynErr(25); }
public void Constant(Constant constant) { if (constant.Value == null) { ILUtil.EmitNull(_il); } else if (constant.Value is DateTime) { ILUtil.EmitConstant(_il, ((DateTime)constant.Value).Ticks); ILUtil.EmitNew(_il, typeof(DateTime).GetConstructor(new[] { typeof(long) })); } else if (constant.Value is TimeSpan) { ILUtil.EmitConstant(_il, ((TimeSpan)constant.Value).Ticks); ILUtil.EmitNew(_il, typeof(TimeSpan).GetConstructor(new[] { typeof(long) })); } else { ILUtil.EmitConstant(_il, constant.Value); } }