1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3<head>
4<meta http-equiv="content-type" content="text/html;charset=utf-8" />
5<title>t001lexer</title>
6
7<!-- ANTLR includes -->
8<script type="text/javascript" src="../../lib/antlr3-all.js"></script>
9<script type="text/javascript" src="t001lexer.js"></script>
10
11<!-- JsUnit include -->
12<script type="text/javascript" src="../jsunit/app/jsUnitCore.js"></script>
13
14<!-- Test Code -->
15<script type="text/javascript">
16    function TLexer() {
17        TLexer.superclass.constructor.apply(this, arguments);
18    }
19    org.antlr.lang.extend(TLexer, t001lexer, {
20        reportError: function(e) {
21            throw e;
22        }
23    });
24
25    function testValid() {
26        var stream = new org.antlr.runtime.ANTLRStringStream("0"),
27            lexer = new TLexer(stream),
28            token;
29
30        token = lexer.nextToken();
31        assertEquals(token.getType(), lexer.ZERO);
32
33        token = lexer.nextToken();
34        assertEquals(token.getType(), lexer.EOF);
35    }
36
37    function testMalformedInput() {
38        var stream = new org.antlr.runtime.ANTLRStringStream('1'),
39            lexer = new TLexer(stream),
40            token;
41
42        try {
43            token = lexer.nextToken();
44            fail("nextToken should have thrown a noviableatl on bad token.");
45        } catch(e) {
46            assert(e instanceof org.antlr.runtime.MismatchedTokenException);
47            assertEquals(e.expecting, '0');
48            assertEquals(e.getUnexpectedType(), '1');
49        }
50    }
51</script>
52
53</head>
54<body>
55    <h1>t001lexer</h1>
56</body>
57</html>
58