* Scheme numbers are complicated unfortunately. * Checks if we're looking at a number, which might be possibly a fraction. * Also checks that it is not part of a longer identifier. Returns true/false accordingly.
(ch, stream)
| 35 | * Also checks that it is not part of a longer identifier. Returns true/false accordingly. |
| 36 | */ |
| 37 | function isNumber(ch, stream){ |
| 38 | if (!stream.eatWhile(/[0-9]/)) { |
| 39 | if (stream.eat(/\//)) stream.eatWhile(/[0-9]/); |
| 40 | if (stream.eol() || !(/[a-zA-Z\-\_\/]/.test(stream.peek()))) return true; |
| 41 | stream.backUp(stream.current().length - 1); // undo all the eating |
| 42 | } |
| 43 | return false; |
| 44 | } |
| 45 | |
| 46 | return { |
| 47 | startState: function () { |