| 63 | } |
| 64 | |
| 65 | function isNumber(ch, stream){ |
| 66 | // hex |
| 67 | if ( ch === '0' && 'x' == stream.peek().toLowerCase() ) { |
| 68 | stream.eat('x'); |
| 69 | stream.eatWhile(tests.hex); |
| 70 | return true; |
| 71 | } |
| 72 | |
| 73 | // leading sign |
| 74 | if ( ch == '+' || ch == '-' ) { |
| 75 | stream.eat(tests.sign); |
| 76 | ch = stream.next(); |
| 77 | } |
| 78 | |
| 79 | if ( tests.digit.test(ch) ) { |
| 80 | stream.eat(ch); |
| 81 | stream.eatWhile(tests.digit); |
| 82 | |
| 83 | if ( '.' == stream.peek() ) { |
| 84 | stream.eat('.'); |
| 85 | stream.eatWhile(tests.digit); |
| 86 | } |
| 87 | |
| 88 | if ( 'e' == stream.peek().toLowerCase() ) { |
| 89 | stream.eat(tests.exponent); |
| 90 | stream.eat(tests.sign); |
| 91 | stream.eatWhile(tests.digit); |
| 92 | } |
| 93 | |
| 94 | return true; |
| 95 | } |
| 96 | |
| 97 | return false; |
| 98 | } |
| 99 | |
| 100 | return { |
| 101 | startState: function () { |