You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.7 KiB
58 lines
1.7 KiB
<!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>t001lexer</title>
|
|
|
|
<!-- ANTLR includes -->
|
|
<script type="text/javascript" src="../../lib/antlr3-all.js"></script>
|
|
<script type="text/javascript" src="t001lexer.js"></script>
|
|
|
|
<!-- JsUnit include -->
|
|
<script type="text/javascript" src="../jsunit/app/jsUnitCore.js"></script>
|
|
|
|
<!-- Test Code -->
|
|
<script type="text/javascript">
|
|
function TLexer() {
|
|
TLexer.superclass.constructor.apply(this, arguments);
|
|
}
|
|
org.antlr.lang.extend(TLexer, t001lexer, {
|
|
reportError: function(e) {
|
|
throw e;
|
|
}
|
|
});
|
|
|
|
function testValid() {
|
|
var stream = new org.antlr.runtime.ANTLRStringStream("0"),
|
|
lexer = new TLexer(stream),
|
|
token;
|
|
|
|
token = lexer.nextToken();
|
|
assertEquals(token.getType(), lexer.ZERO);
|
|
|
|
token = lexer.nextToken();
|
|
assertEquals(token.getType(), lexer.EOF);
|
|
}
|
|
|
|
function testMalformedInput() {
|
|
var stream = new org.antlr.runtime.ANTLRStringStream('1'),
|
|
lexer = new TLexer(stream),
|
|
token;
|
|
|
|
try {
|
|
token = lexer.nextToken();
|
|
fail("nextToken should have thrown a noviableatl on bad token.");
|
|
} catch(e) {
|
|
assert(e instanceof org.antlr.runtime.MismatchedTokenException);
|
|
assertEquals(e.expecting, '0');
|
|
assertEquals(e.getUnexpectedType(), '1');
|
|
}
|
|
}
|
|
</script>
|
|
|
|
</head>
|
|
<body>
|
|
<h1>t001lexer</h1>
|
|
</body>
|
|
</html>
|