Manual:Jsparse.php

This page is a translated version of the page Manual:Jsparse.php and the translation is 100% complete.
Other languages:

Detalhes

O arquivo jsparse.php é um script de manutenção para testes dos analisadores de validação do JavaScript, usando o analisador JSMin+. This is a useful feature to run parsing/syntax check on JavaScript files.

Arguments

This takes file(s) as their first argument which you want to validate.

For passing multiple files at once, use spaces between them to separate

Usage

php maintenance/jsparse.php filename


Checking splitList.js JavaScript file

Filename: splitList.js

// Long list into two col
$( document ).ready( function(){

	var longList = $("#longList").addClass("grid_row"),
		dlElements = longList.children().filter("dl"),
		dlElementsLength = dlElements.length;
	
	var list1 = [],
		list2 = [];
	
	var count = 0;
	dlElements.each( function(index, ele){
		if( count < dlElementsLength/2 ){
			list1.push(ele);
			list1.push( $(ele).next() );
		} else {
			list2.push(ele);
			list2.push( $(ele).next() );
		}
		count = count + 1;
	});
	
	longList.empty();
	
	var leftDiv = $("<div/>").addClass("grid_col");
	list1.forEach( function(value, index){
		leftDiv.append(value);
	});
	
	
	var rightDiv = $("<div/>").addClass("grid_col");
	list2.forEach( function(value, index){
		rightDiv.append(value);
	});
	
	longList.append(leftDiv, rightDiv );
	
});
Terminal


Checking wrongSplitList.js JavaScript file

Filename: wrongSplitList.js

// Long list into col
$( document ).ready( function(){

	var longList = $("#longList").addClass("grid_row"),
		dlElements = longList.children().filter("dl"),
		dlElementsLength = dlElements.length;
	
	var list1 = [],
		list2 = [];
	
	var count = 0;
	dlElements.each( function(index, ele){
		if( count < dlElementsLength/2 ){
			list1.push(ele);
			list1.push( $(ele).next() );
		} else {
			list2.push(ele);
			list2.push( $(ele).next() );
		}
		count = count + 1;
	});
	
	longList.empty();
	
	var leftDiv = $("<div/>").addClass("grid_col");
	list1.forEach( function(value, index){
		leftDiv.append(value);
	});
	
	
	var rightDiv = $("<div/>").addClass("grid_col");
	list2.forEach( function(value, index){
		rightDiv.append(value);
	});
	
    // Intentionally removed ); from the end for jsparse.php demo
	longList.append(leftDiv, rightDiv
	
});
Terminal


Common error

$filename ERROR: could not read file

It comes when the file does not exist or the user running the script does not have permission to read the file.

In case file does exist, check file permission. If you are root user then you can run script with sudo.

See also