cc7ad9739f
Calling the parsing function could have been done without the ugly table using |eval|, but this seemed to degrade performance significantly (by about 3 %). This is probably because engines optimize badly in presence of |eval|. The method used in this patch does not change the benchmark suite execution speed statistically significantly on V8. Detailed results (benchmark suite totals): --------------------------------- Test # Before After --------------------------------- 1 38.24 kB/s 38.28 kB/s 2 38.35 kB/s 38.15 kB/s 3 38.43 kB/s 38.40 kB/s 4 38.53 kB/s 38.20 kB/s 5 38.25 kB/s 38.39 kB/s --------------------------------- Average 38.36 kB/s 38.39 kB/s --------------------------------- Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.151 Safari/534.1
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
parses = function(parser, input, expected) {
|
|
deepEqual(parser.parse(input), expected);
|
|
};
|
|
|
|
parsesWithStartRule = function(parser, input, startRule, expected) {
|
|
deepEqual(parser.parse(input, startRule), expected);
|
|
};
|
|
|
|
doesNotParse = function(parser, input) {
|
|
raises(function() { parser.parse(input); }, parser.SyntaxError);
|
|
};
|
|
|
|
doesNotParseWithMessage = function(parser, input, message) {
|
|
raises(
|
|
function() { parser.parse(input); },
|
|
function(e) {
|
|
return e instanceof parser.SyntaxError && e.message === message;
|
|
}
|
|
);
|
|
};
|
|
|
|
doesNotParseWithPos = function(parser, input, line, column) {
|
|
raises(
|
|
function() { parser.parse(input); },
|
|
function(e) {
|
|
return e instanceof parser.SyntaxError
|
|
&& e.line === line
|
|
&& e.column === column;
|
|
}
|
|
);
|
|
};
|
|
|
|
parserParses = function(input, expected) {
|
|
parses(PEG.parser, input, expected);
|
|
};
|
|
|
|
parserDoesNotParse = function(input) {
|
|
doesNotParse(PEG.parser, input);
|
|
};
|
|
|
|
parserDoesNotParseWithMessage = function(input, message) {
|
|
doesNotParseWithMessage(PEG.parser, input, message);
|
|
};
|