• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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>t031emptyAlt</title>
6
7<!-- ANTLR includes -->
8<script type="text/javascript" src="../../lib/antlr3-all.js"></script>
9<script type="text/javascript" src="t031emptyAltLexer.js"></script>
10<script type="text/javascript" src="t031emptyAltParser.js"></script>
11
12
13<!-- JsUnit include -->
14<script type="text/javascript" src="../jsunit/app/jsUnitCore.js"></script>
15
16<!-- Test Code -->
17<script type="text/javascript">
18    var TParser = function() {
19        this.cond = true;
20        TParser.superclass.constructor.apply(this, arguments);
21    }
22    org.antlr.lang.extend(TParser, t031emptyAltParser, {
23        emitErrorMessage: function() { /* don't report errors */ },
24        recover: function(re) {
25            /* don't recover, just crash */
26            throw re;
27        }
28    });
29
30
31    function testValid1() {
32        var cstream = new org.antlr.runtime.ANTLRStringStream("foo"),
33            lexer = new t031emptyAltLexer(cstream),
34            tstream = new org.antlr.runtime.CommonTokenStream(lexer),
35            parser = new TParser(tstream);
36
37        parser.cond = false;
38        parser.r();
39    }
40
41    function testValid2() {
42        var cstream = new org.antlr.runtime.ANTLRStringStream("foo  jfef9jfe88d"),
43            lexer = new t031emptyAltLexer(cstream),
44            tstream = new org.antlr.runtime.CommonTokenStream(lexer),
45            parser = new TParser(tstream);
46
47        parser.cond = true;
48        parser.r();
49    }
50
51    function testInvalid1() {
52        var cstream = new org.antlr.runtime.ANTLRStringStream("foo bar"),
53            lexer = new t031emptyAltLexer(cstream),
54            tstream = new org.antlr.runtime.CommonTokenStream(lexer),
55            parser = new TParser(tstream);
56
57        try {
58            parser.cond = false;
59            parser.r();
60            fail("shouldn't reach here");
61        } catch(e) {}
62    }
63</script>
64
65</head>
66<body>
67    <h1>t031emptyAlt</h1>
68</body>
69</html>
70