Esempio n. 1
0
        private double _ReadNumber()
        {
            var expo = new char[] { 'E', 'e' };

            Utl.Assert(_CurrentIsDigit());
            var first = Current;

            _SaveAndNext();
            if (first == '0' && (Current == 'X' || Current == 'x'))
            {
                expo = new char[] { 'P', 'p' };
                _SaveAndNext();
            }
            for (; ;)
            {
                if (Current == expo[0] || Current == expo[1])
                {
                    _SaveAndNext();
                    if (Current == '+' || Current == '-')
                    {
                        _SaveAndNext();
                    }
                }
                if (_CurrentIsXDigit() || Current == '.')
                {
                    _SaveAndNext();
                }
                else
                {
                    break;
                }
            }

            double ret;
            var    str = _GetSavedString();

            if (O_Str2Decimal(str, out ret))
            {
                return(ret);
            }
            else
            {
                _Error("malformed number: " + str);
                return(0.0);
            }
        }
Esempio n. 2
0
 public Token GetLookAhead()
 {
     Utl.Assert(LookAhead == null);
     LookAhead = _Lex();
     return(LookAhead);
 }