| 50017 | return key; |
| 50018 | }, |
| 50019 | number = function number() { |
| 50020 | |
| 50021 | // Parse a number value. |
| 50022 | |
| 50023 | var number, |
| 50024 | sign = '', |
| 50025 | string = '', |
| 50026 | base = 10; |
| 50027 | |
| 50028 | if (ch === '-' || ch === '+') { |
| 50029 | sign = ch; |
| 50030 | next(ch); |
| 50031 | } |
| 50032 | |
| 50033 | // support for Infinity (could tweak to allow other words): |
| 50034 | if (ch === 'I') { |
| 50035 | number = word(); |
| 50036 | if (typeof number !== 'number' || isNaN(number)) { |
| 50037 | error('Unexpected word for number'); |
| 50038 | } |
| 50039 | return sign === '-' ? -number : number; |
| 50040 | } |
| 50041 | |
| 50042 | // support for NaN |
| 50043 | if (ch === 'N') { |
| 50044 | number = word(); |
| 50045 | if (!isNaN(number)) { |
| 50046 | error('expected word to be NaN'); |
| 50047 | } |
| 50048 | // ignore sign as -NaN also is NaN |
| 50049 | return number; |
| 50050 | } |
| 50051 | |
| 50052 | if (ch === '0') { |
| 50053 | string += ch; |
| 50054 | next(); |
| 50055 | if (ch === 'x' || ch === 'X') { |
| 50056 | string += ch; |
| 50057 | next(); |
| 50058 | base = 16; |
| 50059 | } else if (ch >= '0' && ch <= '9') { |
| 50060 | error('Octal literal'); |
| 50061 | } |
| 50062 | } |
| 50063 | |
| 50064 | switch (base) { |
| 50065 | case 10: |
| 50066 | while (ch >= '0' && ch <= '9') { |
| 50067 | string += ch; |
| 50068 | next(); |
| 50069 | } |
| 50070 | if (ch === '.') { |
| 50071 | string += '.'; |
| 50072 | while (next() && ch >= '0' && ch <= '9') { |
| 50073 | string += ch; |
| 50074 | } |
| 50075 | } |
| 50076 | if (ch === 'e' || ch === 'E') { |