public UstNode VisitNumericLiteral([NotNull] ECMAScriptParser.NumericLiteralContext context) { if (context.DecimalLiteral() != null) { double value; double.TryParse(context.GetText(), out value); return(new FloatLiteral(value, context.GetTextSpan(), FileNode)); } else if (context.HexIntegerLiteral() != null) { long value; context.GetText().TryConvertToInt64(16, out value); return(new IntLiteral(value, context.GetTextSpan(), FileNode)); } else { long value; context.GetText().TryConvertToInt64(8, out value); return(new IntLiteral(value, context.GetTextSpan(), FileNode)); } }
public override Node VisitNumericLiteral(ECMAScriptParser.NumericLiteralContext context) { if (context.DecimalLiteral() == null) { throw new NotImplementedException( GenerateErrorMessage(context, "only decimal numbers are supported.")); } double v; try { v = double.Parse(context.DecimalLiteral().Symbol.Text, CultureInfo.InvariantCulture); } catch (Exception e) { e.Data.Add("Position", GenerateErrorLocationMessage(context)); throw; } return(new NumericLiteral(context, v)); }