• 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>t046rewrite</title>
6
7<!-- ANTLR includes -->
8<script type="text/javascript" src="../../lib/antlr3-all.js"></script>
9<script type="text/javascript" src="t046rewriteLexer.js"></script>
10<script type="text/javascript" src="t046rewriteParser.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 TLexer = function() {
19        TLexer.superclass.constructor.apply(this, arguments);
20    };
21    org.antlr.lang.extend(TLexer, t046rewriteLexer, {
22        recover: function(re) {
23            /* don't recover, just crash */
24            throw re;
25        }
26    });
27
28    var TParser = function() {
29        TParser.superclass.constructor.apply(this, arguments);
30    };
31    org.antlr.lang.extend(TParser, t046rewriteParser, {
32        recover: function(re) {
33            /* don't recover, just crash */
34            throw re;
35        }
36    });
37
38
39    function testValid1() {
40        var xinput = [
41                        "method foo() {",
42                        "  i = 3;",
43                        "  k = i;",
44                        "  i = k*4;",
45                        "}",
46                        "",
47                        "method bar() {",
48                        "  j = i*2;",
49                        "}"
50                     ].join("\n");
51        var xoutput = [
52                        "public class Wrapper {",
53                        "public void foo() {",
54                        "int k;",
55                        "int i;",
56                        "  i = 3;",
57                        "  k = i;",
58                        "  i = k*4;",
59                        "}",
60                        "",
61                        "public void bar() {",
62                        "int j;",
63                        "  j = i*2;",
64                        "}",
65                        "}",
66                        ""
67                      ].join("\n");
68
69        var cstream = new org.antlr.runtime.ANTLRStringStream(xinput),
70            lexer = new TLexer(cstream),
71            tstream = new org.antlr.runtime.TokenRewriteStream(lexer),
72            parser = new TParser(tstream);
73        parser.program();
74        assertEquals(tstream.toString(), xoutput);
75    }
76</script>
77
78</head>
79<body>
80    <h1>t046rewrite</h1>
81</body>
82</html>
83