<!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>t022scopes</title>
<!-- ANTLR includes -->
<script type="text/javascript" src="../../lib/antlr3-all.js"></script>
<script type="text/javascript" src="t022scopesLexer.js"></script>
<script type="text/javascript" src="t022scopesParser.js"></script>
<!-- JsUnit include -->
<script type="text/javascript" src="../jsunit/app/jsUnitCore.js"></script>
<!-- Test Code -->
<script type="text/javascript">
var TParser = function() {
TParser.superclass.constructor.apply(this, arguments);
}
org.antlr.lang.extend(TParser, t022scopesParser, {
emitErrorMessage: function(msg) {},
reportError: function(e) { throw e; }
});
function testa1() {
var cstream = new org.antlr.runtime.ANTLRStringStream("foobar"),
lexer = new t022scopesLexer(cstream),
tstream = new org.antlr.runtime.CommonTokenStream(lexer),
parser = new TParser(tstream);
// just make sure we don't get any errors
parser.a();
}
function testb1() {
var cstream = new org.antlr.runtime.ANTLRStringStream("foobar"),
lexer = new t022scopesLexer(cstream),
tstream = new org.antlr.runtime.CommonTokenStream(lexer),
parser = new TParser(tstream);
try {
parser.b(false);
fail("above should have throw error");
} catch(e) {
assert(org.antlr.lang.isValue(e));
}
}
function testb2() {
var cstream = new org.antlr.runtime.ANTLRStringStream("foobar"),
lexer = new t022scopesLexer(cstream),
tstream = new org.antlr.runtime.CommonTokenStream(lexer),
parser = new TParser(tstream);
parser.b(true);
}
function testc1() {
var xinput = [
"{",
" int i;",
" int j;",
" i = 0;",
"}"
].join("\n");
var cstream = new org.antlr.runtime.ANTLRStringStream(xinput),
lexer = new t022scopesLexer(cstream),
tstream = new org.antlr.runtime.CommonTokenStream(lexer),
parser = new TParser(tstream),
i;
var symbols = parser.c();
assert(symbols.i);
assert(symbols.j);
}
function testc2() {
var xinput = [
"{",
" int i;",
" int j;",
" i = 0;",
" x = 4;",
"}"
].join("\n");
var cstream = new org.antlr.runtime.ANTLRStringStream(xinput),
lexer = new t022scopesLexer(cstream),
tstream = new org.antlr.runtime.CommonTokenStream(lexer),
parser = new TParser(tstream),
i;
try {
parser.c();
fail("shouldn't get here");
} catch(e) {
assertEquals(e.message, "x");
}
}
function testd1() {
var xinput = [
"{",
" int i;",
" int j;",
" i = 0;",
" {",
" int i;",
" int x;",
" x = 5;",
" }",
"}"
].join("\n");
var cstream = new org.antlr.runtime.ANTLRStringStream(xinput),
lexer = new t022scopesLexer(cstream),
tstream = new org.antlr.runtime.CommonTokenStream(lexer),
parser = new TParser(tstream),
i;
var symbols = parser.d();
assert(symbols.i);
assert(symbols.j);
}
function teste1() {
var xinput = "{ { { { 12 } } } }";
var cstream = new org.antlr.runtime.ANTLRStringStream(xinput),
lexer = new t022scopesLexer(cstream),
tstream = new org.antlr.runtime.CommonTokenStream(lexer),
parser = new TParser(tstream);
var res = parser.e();
assertEquals(res, 12);
}
function testf1() {
var xinput = "{ { { { 12 } } } }";
var cstream = new org.antlr.runtime.ANTLRStringStream(xinput),
lexer = new t022scopesLexer(cstream),
tstream = new org.antlr.runtime.CommonTokenStream(lexer),
parser = new TParser(tstream);
var res = parser.f();
assertUndefined(res);
}
function testf2() {
var xinput = "{ { 12 } }";
var cstream = new org.antlr.runtime.ANTLRStringStream(xinput),
lexer = new t022scopesLexer(cstream),
tstream = new org.antlr.runtime.CommonTokenStream(lexer),
parser = new TParser(tstream);
var res = parser.f();
assertUndefined(res);
}
</script>
</head>
<body>
<h1>t022scopes</h1>
</body>
</html>