Пример #1
0
    it('Match the character that is at the current index', function () {
        let l = new LL1Lexer('abcd');

        l.match('a');

        expect(l.index).toBe(1);
        expect(l.char).toBe('b');
    });
Пример #2
0
    it('No match throws an exception', function () {
        let l = new LL1Lexer('abcd');

        expect(function () {
            l.match('c');
        }).toThrow(new Exception('Expecting "c"; found "a"'));
    });
Пример #3
0
    it('Create a token', function () {
        let l = new LL1Lexer('abcd'),
            t = l.createToken(LL1Lexer.EOF_TYPE, '');

        expect(t.toString()).toEqual('<"", "<EOF>">');
    });
Пример #4
0
 expect(function () {
     l.match('c');
 }).toThrow(new Exception('Expecting "c"; found "a"'));