Html程序  |  63行  |  1.82 KB

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>t039labels</title>

<!-- ANTLR includes -->
<script type="text/javascript" src="../../lib/antlr3-all.js"></script>
<script type="text/javascript" src="t039labelsLexer.js"></script>
<script type="text/javascript" src="t039labelsParser.js"></script>


<!-- JsUnit include -->
<script type="text/javascript" src="../jsunit/app/jsUnitCore.js"></script>

<!-- Test Code -->
<script type="text/javascript">
    var TLexer = function() {
        TLexer.superclass.constructor.apply(this, arguments);
    };
    org.antlr.lang.extend(TLexer, t039labelsLexer, {
        recover: function(re) {
            /* don't recover, just crash */
            throw re;
        }
    });

    var TParser = function() {
        TParser.superclass.constructor.apply(this, arguments);
    };
    org.antlr.lang.extend(TParser, t039labelsParser, {
        recover: function(re) {
            /* don't recover, just crash */
            throw re;
        }
    });


    function testValid1() {
        var cstream = new org.antlr.runtime.ANTLRStringStream('a, b, c, 1, 2 A FOOBAR GNU1 A BLARZ'),
            lexer = new TLexer(cstream),
            tstream = new org.antlr.runtime.CommonTokenStream(lexer),
            parser = new TParser(tstream);

        var ret = parser.a(),
            ids = ret[0],
            w = ret[1];

        var i, a=[];
        for (i=0; i<ids.length; i++) {
            a.push(ids[i].getText());
        }
        assertArrayEquals(["a", "b", "c", "1", "2", "A"], a);
        assertEquals(w.getText(), "GNU1");
    }
</script>

</head>
<body>
    <h1>t039labels</h1>
</body>
</html>