File size: 2,000 Bytes
597ee18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
System.register(["./isWhitespace"], function (exports_1, context_1) {
    "use strict";
    var isWhitespace_1;
    var __moduleName = context_1 && context_1.id;
    function CharacterBuffer(characters) {
        this.characters = characters;
        this.current = 0;
        this.end = this.characters.length;
    }
    exports_1("CharacterBuffer", CharacterBuffer);
    return {
        setters: [
            function (isWhitespace_1_1) {
                isWhitespace_1 = isWhitespace_1_1;
            }
        ],
        execute: function () {
            CharacterBuffer.prototype.skipAtMostOneLeadingNewline = function () {
                if (this.characters[this.current] === '\n')
                    this.current++;
            };
            CharacterBuffer.prototype.skipLeadingWhitespace = function () {
                while (isWhitespace_1.isWhitespace(this.characters[this.current])) {
                    if (++this.current === this.end)
                        return;
                }
            };
            CharacterBuffer.prototype.skipLeadingNonWhitespace = function () {
                while (!isWhitespace_1.isWhitespace(this.characters[this.current])) {
                    if (++this.current === this.end)
                        return;
                }
            };
            CharacterBuffer.prototype.takeRemaining = function () {
                return this.characters.substring(this.current);
            };
            CharacterBuffer.prototype.takeLeadingWhitespace = function () {
                var start = this.current;
                this.skipLeadingWhitespace();
                if (start === this.current)
                    return "";
                return this.characters.substring(start, this.current - start);
            };
            Object.defineProperty(CharacterBuffer.prototype, 'length', {
                get: function () {
                    return this.end - this.current;
                }
            });
        }
    };
});