|
|
|
@ -643,89 +643,6 @@ testWithVaryingTrackLineAndColumn("rule references", function(options) {
|
|
|
|
|
parses(parser, "Python", "Python");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testWithVaryingTrackLineAndColumn("classes", function(options) {
|
|
|
|
|
var emptyClassParser = PEG.buildParser('start = []', options);
|
|
|
|
|
doesNotParse(emptyClassParser, "");
|
|
|
|
|
doesNotParse(emptyClassParser, "a");
|
|
|
|
|
doesNotParse(emptyClassParser, "ab");
|
|
|
|
|
|
|
|
|
|
var invertedEmptyClassParser = PEG.buildParser('start = [^]', options);
|
|
|
|
|
doesNotParse(invertedEmptyClassParser, "");
|
|
|
|
|
parses(invertedEmptyClassParser, "a", "a");
|
|
|
|
|
doesNotParse(invertedEmptyClassParser, "ab");
|
|
|
|
|
|
|
|
|
|
var nonEmptyCaseSensitiveClassParser = PEG.buildParser(
|
|
|
|
|
'start = [ab-d]',
|
|
|
|
|
options
|
|
|
|
|
);
|
|
|
|
|
parses(nonEmptyCaseSensitiveClassParser, "a", "a");
|
|
|
|
|
parses(nonEmptyCaseSensitiveClassParser, "b", "b");
|
|
|
|
|
parses(nonEmptyCaseSensitiveClassParser, "c", "c");
|
|
|
|
|
parses(nonEmptyCaseSensitiveClassParser, "d", "d");
|
|
|
|
|
doesNotParse(nonEmptyCaseSensitiveClassParser, "");
|
|
|
|
|
doesNotParse(nonEmptyCaseSensitiveClassParser, "A");
|
|
|
|
|
doesNotParse(nonEmptyCaseSensitiveClassParser, "B");
|
|
|
|
|
doesNotParse(nonEmptyCaseSensitiveClassParser, "C");
|
|
|
|
|
doesNotParse(nonEmptyCaseSensitiveClassParser, "D");
|
|
|
|
|
doesNotParse(nonEmptyCaseSensitiveClassParser, "e");
|
|
|
|
|
doesNotParse(nonEmptyCaseSensitiveClassParser, "ab");
|
|
|
|
|
|
|
|
|
|
var invertedNonEmptyCaseSensitiveClassParser = PEG.buildParser(
|
|
|
|
|
'start = [^ab-d]',
|
|
|
|
|
options
|
|
|
|
|
);
|
|
|
|
|
parses(invertedNonEmptyCaseSensitiveClassParser, "A", "A");
|
|
|
|
|
parses(invertedNonEmptyCaseSensitiveClassParser, "B", "B");
|
|
|
|
|
parses(invertedNonEmptyCaseSensitiveClassParser, "C", "C");
|
|
|
|
|
parses(invertedNonEmptyCaseSensitiveClassParser, "D", "D");
|
|
|
|
|
parses(invertedNonEmptyCaseSensitiveClassParser, "e", "e");
|
|
|
|
|
doesNotParse(invertedNonEmptyCaseSensitiveClassParser, "a", "a");
|
|
|
|
|
doesNotParse(invertedNonEmptyCaseSensitiveClassParser, "b", "b");
|
|
|
|
|
doesNotParse(invertedNonEmptyCaseSensitiveClassParser, "c", "c");
|
|
|
|
|
doesNotParse(invertedNonEmptyCaseSensitiveClassParser, "d", "d");
|
|
|
|
|
doesNotParse(invertedNonEmptyCaseSensitiveClassParser, "");
|
|
|
|
|
doesNotParse(invertedNonEmptyCaseSensitiveClassParser, "ab");
|
|
|
|
|
|
|
|
|
|
var nonEmptyCaseInsensitiveClassParser = PEG.buildParser(
|
|
|
|
|
'start = [ab-d]i',
|
|
|
|
|
options
|
|
|
|
|
);
|
|
|
|
|
parses(nonEmptyCaseInsensitiveClassParser, "a", "a");
|
|
|
|
|
parses(nonEmptyCaseInsensitiveClassParser, "b", "b");
|
|
|
|
|
parses(nonEmptyCaseInsensitiveClassParser, "c", "c");
|
|
|
|
|
parses(nonEmptyCaseInsensitiveClassParser, "d", "d");
|
|
|
|
|
parses(nonEmptyCaseInsensitiveClassParser, "A", "A");
|
|
|
|
|
parses(nonEmptyCaseInsensitiveClassParser, "B", "B");
|
|
|
|
|
parses(nonEmptyCaseInsensitiveClassParser, "C", "C");
|
|
|
|
|
parses(nonEmptyCaseInsensitiveClassParser, "D", "D");
|
|
|
|
|
doesNotParse(nonEmptyCaseInsensitiveClassParser, "");
|
|
|
|
|
doesNotParse(nonEmptyCaseInsensitiveClassParser, "e");
|
|
|
|
|
doesNotParse(nonEmptyCaseInsensitiveClassParser, "ab");
|
|
|
|
|
|
|
|
|
|
var invertedNonEmptyCaseInsensitiveClassParser = PEG.buildParser(
|
|
|
|
|
'start = [^ab-d]i',
|
|
|
|
|
options
|
|
|
|
|
);
|
|
|
|
|
parses(invertedNonEmptyCaseInsensitiveClassParser, "e", "e");
|
|
|
|
|
doesNotParse(invertedNonEmptyCaseInsensitiveClassParser, "a", "a");
|
|
|
|
|
doesNotParse(invertedNonEmptyCaseInsensitiveClassParser, "b", "b");
|
|
|
|
|
doesNotParse(invertedNonEmptyCaseInsensitiveClassParser, "c", "c");
|
|
|
|
|
doesNotParse(invertedNonEmptyCaseInsensitiveClassParser, "d", "d");
|
|
|
|
|
doesNotParse(invertedNonEmptyCaseInsensitiveClassParser, "A", "A");
|
|
|
|
|
doesNotParse(invertedNonEmptyCaseInsensitiveClassParser, "B", "B");
|
|
|
|
|
doesNotParse(invertedNonEmptyCaseInsensitiveClassParser, "C", "C");
|
|
|
|
|
doesNotParse(invertedNonEmptyCaseInsensitiveClassParser, "D", "D");
|
|
|
|
|
doesNotParse(invertedNonEmptyCaseInsensitiveClassParser, "");
|
|
|
|
|
doesNotParse(invertedNonEmptyCaseInsensitiveClassParser, "ab");
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Test that the parsing position moves forward after successful parsing of
|
|
|
|
|
* a class.
|
|
|
|
|
*/
|
|
|
|
|
var posTestParser = PEG.buildParser('start = [ab-d] [ab-d]', options);
|
|
|
|
|
parses(posTestParser, "ab", ["a", "b"]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
testWithVaryingTrackLineAndColumn("cache", function(options) {
|
|
|
|
|
var grammar = [
|
|
|
|
|
'{ var n = 0; }',
|
|
|
|
|