Ejemplo n.º 1
0
        //http://docs.python.org/ref/numbers.html
        public static NumberLiteral CreatePythonNumber(string name)
        {
            NumberLiteral term = new NumberLiteral(name, TermOptions.EnableQuickParse | TermOptions.SpecialIgnoreCase | TermOptions.NumberAllowStartEndDot);

            //default int types are Integer (32bit) -> LongInteger (BigInt); Try Int64 before BigInt: Better performance?
            term.DefaultIntTypes = new TypeCode[] { TypeCode.Int32, TypeCode.Int64, NumberLiteral.TypeCodeBigInt };
            // term.DefaultFloatType = TypeCode.Double; -- it is default
            //float type is implementation specific, thus try decimal first (higher precision)
            //term.DefaultFloatTypes = new TypeCode[] { TypeCode.Decimal, TypeCode.Double };
            term.AddPrefixFlag("0x", ScanFlags.Hex);
            term.AddPrefixFlag("0", ScanFlags.Octal);
            term.AddSuffixCodes("L", TypeCode.Int64, NumberLiteral.TypeCodeBigInt);
            term.AddSuffixCodes("J", NumberLiteral.TypeCodeImaginary);
            return(term);
        }
Ejemplo n.º 2
0
 //http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf section 9.4.4
 public static NumberLiteral CreateCSharpNumber(string name)
 {
     NumberLiteral term = new NumberLiteral(name, TermOptions.EnableQuickParse | TermOptions.SpecialIgnoreCase);
       term.DefaultIntTypes = new TypeCode[] { TypeCode.Int32, TypeCode.UInt32, TypeCode.Int64, TypeCode.UInt64 };
       term.DefaultFloatType = TypeCode.Double;
       term.AddPrefixFlag("0x", ScanFlags.Hex);
       term.AddSuffixCodes("u", TypeCode.UInt32, TypeCode.UInt64);
       term.AddSuffixCodes("l", TypeCode.Int64, TypeCode.UInt64);
       term.AddSuffixCodes("ul", TypeCode.UInt64);
       term.AddSuffixCodes("f", TypeCode.Single);
     term.AddSuffixCodes("d", TypeCode.Double);
       term.AddSuffixCodes("m", TypeCode.Decimal);
       return term;
 }
Ejemplo n.º 3
0
        //http://www.microsoft.com/downloads/details.aspx?FamilyId=6D50D709-EAA4-44D7-8AF3-E14280403E6E&displaylang=en section 2
        public static NumberLiteral CreateVbNumber(string name)
        {
            NumberLiteral term = new NumberLiteral(name, TermOptions.EnableQuickParse | TermOptions.SpecialIgnoreCase);

            term.DefaultIntTypes = new TypeCode[] { TypeCode.Int32, TypeCode.Int64 };
            //term.DefaultFloatType = TypeCode.Double; it is default
            term.AddPrefixFlag("&H", ScanFlags.Hex);
            term.AddPrefixFlag("&O", ScanFlags.Octal);
            term.AddSuffixCodes("S", TypeCode.Int16);
            term.AddSuffixCodes("I", TypeCode.Int32);
            term.AddSuffixCodes("%", TypeCode.Int32);
            term.AddSuffixCodes("L", TypeCode.Int64);
            term.AddSuffixCodes("&", TypeCode.Int64);
            term.AddSuffixCodes("D", TypeCode.Decimal);
            term.AddSuffixCodes("@", TypeCode.Decimal);
            term.AddSuffixCodes("F", TypeCode.Single);
            term.AddSuffixCodes("!", TypeCode.Single);
            term.AddSuffixCodes("R", TypeCode.Double);
            term.AddSuffixCodes("#", TypeCode.Double);
            term.AddSuffixCodes("US", TypeCode.UInt16);
            term.AddSuffixCodes("UI", TypeCode.UInt32);
            term.AddSuffixCodes("UL", TypeCode.UInt64);
            return(term);
        }
Ejemplo n.º 4
0
        //http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-334.pdf section 9.4.4
        public static NumberLiteral CreateCSharpNumber(string name)
        {
            NumberLiteral term = new NumberLiteral(name, TermOptions.EnableQuickParse | TermOptions.SpecialIgnoreCase);

            term.DefaultIntTypes  = new TypeCode[] { TypeCode.Int32, TypeCode.UInt32, TypeCode.Int64, TypeCode.UInt64 };
            term.DefaultFloatType = TypeCode.Double;
            term.AddPrefixFlag("0x", ScanFlags.Hex);
            term.AddSuffixCodes("u", TypeCode.UInt32, TypeCode.UInt64);
            term.AddSuffixCodes("l", TypeCode.Int64, TypeCode.UInt64);
            term.AddSuffixCodes("ul", TypeCode.UInt64);
            term.AddSuffixCodes("f", TypeCode.Single);
            term.AddSuffixCodes("d", TypeCode.Double);
            term.AddSuffixCodes("m", TypeCode.Decimal);
            return(term);
        }
Ejemplo n.º 5
0
        //Note - this is incomplete implementation; need to add functionality to NumberTerminal class to support type detection based
        // on exponent symbol.
        // From R6RS:
        //  ... representations of number objects may be written with an exponent marker that indicates the desired precision
        // of the inexact representation. The letters s, f, d, and l specify the use of short, single, double, and long precision, respectively.
        public static NumberLiteral CreateSchemeNumber(string name)
        {
            NumberLiteral term = new NumberLiteral(name, TermOptions.EnableQuickParse | TermOptions.SpecialIgnoreCase);

            term.DefaultIntTypes  = new TypeCode[] { TypeCode.Int32, TypeCode.Int64, NumberLiteral.TypeCodeBigInt };
            term.DefaultFloatType = TypeCode.Double; // it is default
            term.ExponentSymbols  = "sfdl";
            term.AddPrefixFlag("#b", ScanFlags.Binary);
            term.AddPrefixFlag("#o", ScanFlags.Octal);
            term.AddPrefixFlag("#x", ScanFlags.Hex);
            term.AddPrefixFlag("#d", ScanFlags.None);
            term.AddPrefixFlag("#i", ScanFlags.None); // inexact prefix, has no effect
            term.AddPrefixFlag("#e", ScanFlags.None); // exact prefix, has no effect
            term.AddSuffixCodes("J", NumberLiteral.TypeCodeImaginary);
            return(term);
        }
Ejemplo n.º 6
0
 //http://www.microsoft.com/downloads/details.aspx?FamilyId=6D50D709-EAA4-44D7-8AF3-E14280403E6E&displaylang=en section 2
 public static NumberLiteral CreateVbNumber(string name)
 {
     NumberLiteral term = new NumberLiteral(name, TermOptions.EnableQuickParse | TermOptions.SpecialIgnoreCase);
       term.DefaultIntTypes = new TypeCode[] { TypeCode.Int32, TypeCode.Int64 };
       //term.DefaultFloatType = TypeCode.Double; it is default
       term.AddPrefixFlag("&H", ScanFlags.Hex);
       term.AddPrefixFlag("&O", ScanFlags.Octal);
       term.AddSuffixCodes("S", TypeCode.Int16);
       term.AddSuffixCodes("I", TypeCode.Int32);
       term.AddSuffixCodes("%", TypeCode.Int32);
       term.AddSuffixCodes("L", TypeCode.Int64);
       term.AddSuffixCodes("&", TypeCode.Int64);
       term.AddSuffixCodes("D", TypeCode.Decimal);
       term.AddSuffixCodes("@", TypeCode.Decimal);
       term.AddSuffixCodes("F", TypeCode.Single);
       term.AddSuffixCodes("!", TypeCode.Single);
       term.AddSuffixCodes("R", TypeCode.Double);
       term.AddSuffixCodes("#", TypeCode.Double);
       term.AddSuffixCodes("US", TypeCode.UInt16);
       term.AddSuffixCodes("UI", TypeCode.UInt32);
       term.AddSuffixCodes("UL", TypeCode.UInt64);
       return term;
 }
Ejemplo n.º 7
0
 //Note - this is incomplete implementation; need to add functionality to NumberTerminal class to support type detection based
 // on exponent symbol.
 // From R6RS:
 //  ... representations of number objects may be written with an exponent marker that indicates the desired precision
 // of the inexact representation. The letters s, f, d, and l specify the use of short, single, double, and long precision, respectively.
 public static NumberLiteral CreateSchemeNumber(string name)
 {
     NumberLiteral term = new NumberLiteral(name, TermOptions.EnableQuickParse | TermOptions.SpecialIgnoreCase);
       term.DefaultIntTypes = new TypeCode[] { TypeCode.Int32, TypeCode.Int64, NumberLiteral.TypeCodeBigInt };
       term.DefaultFloatType = TypeCode.Double; // it is default
       term.ExponentSymbols = "sfdl";
       term.AddPrefixFlag("#b", ScanFlags.Binary);
       term.AddPrefixFlag("#o", ScanFlags.Octal);
       term.AddPrefixFlag("#x", ScanFlags.Hex);
       term.AddPrefixFlag("#d", ScanFlags.None);
       term.AddPrefixFlag("#i", ScanFlags.None); // inexact prefix, has no effect
       term.AddPrefixFlag("#e", ScanFlags.None); // exact prefix, has no effect
       term.AddSuffixCodes("J", NumberLiteral.TypeCodeImaginary);
       return term;
 }
Ejemplo n.º 8
0
 //http://docs.python.org/ref/numbers.html
 public static NumberLiteral CreatePythonNumber(string name)
 {
     NumberLiteral term = new NumberLiteral(name, TermOptions.EnableQuickParse | TermOptions.SpecialIgnoreCase | TermOptions.NumberAllowStartEndDot);
       //default int types are Integer (32bit) -> LongInteger (BigInt); Try Int64 before BigInt: Better performance?
       term.DefaultIntTypes = new TypeCode[] { TypeCode.Int32, TypeCode.Int64, NumberLiteral.TypeCodeBigInt };
       // term.DefaultFloatType = TypeCode.Double; -- it is default
       //float type is implementation specific, thus try decimal first (higher precision)
       //term.DefaultFloatTypes = new TypeCode[] { TypeCode.Decimal, TypeCode.Double };
       term.AddPrefixFlag("0x", ScanFlags.Hex);
       term.AddPrefixFlag("0", ScanFlags.Octal);
       term.AddSuffixCodes("L", TypeCode.Int64, NumberLiteral.TypeCodeBigInt);
       term.AddSuffixCodes("J", NumberLiteral.TypeCodeImaginary);
       return term;
 }