How to use the wikipeg.buildParser function in wikipeg

To help you get started, we’ve selected a few wikipeg examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wikimedia / parsoid / bin / parserTests.js View on Github external
ParserTests.prototype.main = Promise.async(function *(options, mockAPIServerURL) {
	this.runDisabled = ScriptUtils.booleanOption(options['run-disabled']);
	this.runPHP = ScriptUtils.booleanOption(options['run-php']);

	// test case filtering
	this.testFilter = null; // null is the 'default' by definition
	if (options.filter || options.regex) {
		// NOTE: filter.toString() is required because a number-only arg
		// shows up as a numeric type rather than a string.
		// Ex: parserTests.js --filter 53221
		var pattern = options.regex || JSUtils.escapeRegExp(options.filter.toString());
		this.testFilter = new RegExp(pattern);
	}

	this.testParserFilePath = path.join(__dirname, '../lib/parserTests/parserTests.pegjs');
	this.testParser = PEG.buildParser(yield fs.readFile(this.testParserFilePath, 'utf8'));

	const parsedTests = yield this.getTests(options);
	this.testFormat = parsedTests[0];
	this.cases = parsedTests[1];
	if (this.testFormat && this.testFormat.text) {
		this.testFormat = +(this.testFormat.text);
	} else {
		this.testFormat = 1;
	}

	if (options.maxtests) {
		var n = Number(options.maxtests);
		console.warn('maxtests:' + n);
		if (n > 0) {
			this.cases.length = n;
		}

wikipeg

Parser generator for JavaScript and PHP

MIT
Latest version published 5 months ago

Package Health Score

63 / 100
Full package analysis

Similar packages