1 using System;
2 using System.Lex;
3 using System.Numerics.Multiprecision;
4
5 namespace BigNumCalc
6 {
7 public BigValue* ParseBigFloat(const Token& token)
8 {
9 BigFloat value(ToUtf8(token.match.ToString()));
10 return new BigFloatValue(value);
11 }
12
13 public BigValue* ParseBigRational(const Token& token)
14 {
15 long n = token.match.end - token.match.begin;
16 #assert(n >= 2 && *token.match.begin == '[' && *(token.match.end - 1) == ']');
17 string s = ToUtf8(token.match.ToString());
18 BigRational value(s.Substring(1, s.Length() - 2));
19 return new BigRationalValue(value);
20 }
21
22 public BigValue* ParseBigInteger(const Token& token)
23 {
24 BigInt value(ToUtf8(token.match.ToString()));
25 return new BigIntValue(value);
26 }
27 }