xref: /aosp_15_r20/external/antlr/runtime/JavaScript/tests/functional/t013parser.html (revision 16467b971bd3e2009fad32dd79016f2c7e421deb)
1*16467b97STreehugger Robot<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2*16467b97STreehugger Robot<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3*16467b97STreehugger Robot<head>
4*16467b97STreehugger Robot<meta http-equiv="content-type" content="text/html;charset=utf-8" />
5*16467b97STreehugger Robot<title>t013parser</title>
6*16467b97STreehugger Robot
7*16467b97STreehugger Robot<!-- ANTLR includes -->
8*16467b97STreehugger Robot<script type="text/javascript" src="../../lib/antlr3-all.js"></script>
9*16467b97STreehugger Robot<script type="text/javascript" src="t013parserLexer.js"></script>
10*16467b97STreehugger Robot<script type="text/javascript" src="t013parserParser.js"></script>
11*16467b97STreehugger Robot
12*16467b97STreehugger Robot<!-- JsUnit include -->
13*16467b97STreehugger Robot<script type="text/javascript" src="../jsunit/app/jsUnitCore.js"></script>
14*16467b97STreehugger Robot
15*16467b97STreehugger Robot<!-- Test Code -->
16*16467b97STreehugger Robot<script type="text/javascript">
17*16467b97STreehugger Robot    function testValid() {
18*16467b97STreehugger Robot        var cstream = new org.antlr.runtime.ANTLRStringStream("foobar"),
19*16467b97STreehugger Robot            lexer = new t013parserLexer(cstream),
20*16467b97STreehugger Robot            tstream = new org.antlr.runtime.CommonTokenStream(lexer),
21*16467b97STreehugger Robot            parser = new t013parserParser(tstream);
22*16467b97STreehugger Robot
23*16467b97STreehugger Robot        parser.document();
24*16467b97STreehugger Robot        assertEquals(parser.reportedErrors.length, 0);
25*16467b97STreehugger Robot        assertEquals(parser.identifiers.length, 1);
26*16467b97STreehugger Robot    }
27*16467b97STreehugger Robot
28*16467b97STreehugger Robot    function testMalformedInput1() {
29*16467b97STreehugger Robot        var cstream = new org.antlr.runtime.ANTLRStringStream(""),
30*16467b97STreehugger Robot            lexer = new t013parserLexer(cstream),
31*16467b97STreehugger Robot            tstream = new org.antlr.runtime.CommonTokenStream(lexer),
32*16467b97STreehugger Robot            parser = new t013parserParser(tstream);
33*16467b97STreehugger Robot
34*16467b97STreehugger Robot        try {
35*16467b97STreehugger Robot            parser.document();
36*16467b97STreehugger Robot            fail("should have failed on empty input");
37*16467b97STreehugger Robot        } catch(e) {
38*16467b97STreehugger Robot        }
39*16467b97STreehugger Robot    }
40*16467b97STreehugger Robot</script>
41*16467b97STreehugger Robot
42*16467b97STreehugger Robot</head>
43*16467b97STreehugger Robot<body>
44*16467b97STreehugger Robot    <h1>t013parser</h1>
45*16467b97STreehugger Robot</body>
46