Parse comments and knot declarations

This commit is contained in:
2019-03-11 09:54:57 -06:00
parent 5c015f3193
commit a932aec2b5
3 changed files with 91 additions and 15 deletions

View File

@@ -1,11 +1,28 @@
package tests;
import hank.Parser;
import hank.Parser.HankAST;
class ParserTest extends utest.Test {
var ast: HankAST;
function nextExpr() {
var next = ast[0];
ast.remove(next);
return next.expr;
}
function assertNextExpr(expr: ExprType) {
HankAssert.equals(expr, nextExpr());
}
function testParseMain() {
var parser = new Parser();
var ast = parser.parseFile('examples/main/main.hank');
trace (ast);
ast = parser.parseFile('examples/main/main.hank');
assertNextExpr(EComment(" comments in Hank start with a double-slash"));
assertNextExpr(EComment(" Or you can split comments\nacross more than one line "));
assertNextExpr(EComment(" Or you can use block comments inline "));
}
}