The Job Description Language is used, in Grid environment, to describe tasks submitted to the batch subsystem. JDL is an extension of the Condor's Classified Advertisements (classads). The parser is written in C++ and uses the Boost::Spirit API; Spirit is a (new generation) parser generator based on C++ template (meta) programming.

JDL Syntax Analyzer

The basic version of the parser performs a syntax check within few semantic controls: jdl_grammar.hpp The header file defines the grammar and the jdl_parser class that can be used in order to parse JDL files. The following example depicts how to use the parser in order to parse JDL files:

	...
	void parse(string jdl){
		try{
			jdl_parser parser;
			parser.parse(jdl);
			cout << "Parsing OK!" << endl;
		}catch(parser_error<Errors, char const *> ex){
			cerr << "Syntax error occurred: " << endl;
			switch(ex.descriptor){
			case semicolon_expected:
				cerr << "';' expected at: ";
				break;
			...
			case attribute_expected: 
				cerr << "valid attribute expected at: ";
				break;
			default:
				cerr << "Error occured at: ";
			}
			pair<int,int> err_desc = iter2RowCol(jdl, ex.where);
			cerr << "Row: " << err_desc.first  << ", Col: " << err_desc.second << endl;
			cerr << "\" " << string(ex.where, ex.where+150) << " \"" << endl;
		
			exit(1);
		}catch(semantic_error e){
			...
		}
	}
The jdl_parser.cpp contains the complete example which can be compiled by means of the Boost.Spirit library. The executable can be produced including the Boost.Spirit library.

JDL Parser

The complete parser builds the in memory representation of the JDL structure using an Abstract Parsing Tree (APT). The APT is defined according to the Composite pattern and the Visitor pattern can be used in order to traverse the tree and check semantic conditions/properties.

Downloads

Semantic actions have been added to the syntax analyzer described in the previous section in order to create the APT which structure is depicted in the following ficure: Once the APT has been created the Visitor pattern allows to easily create tree evaluators, Several Visitors have been also defined in order to check, and extrapolate JDL's properties. For example in JDL is possible to define workflows using the Directed Acyclic Graph formalism (DAG). Workflow dependencies can be extracted by the JDL Parser using the dag_visitor class. The Visitor class hierarchy is depicted in the following figure: The complete documentation about the complete JDL Parser can be found here while the source code is available for download here.

Example: JDL DAG

	[
	   Type = "dag";
	   VirtualOrganisation = "EGEE";
	   inputsandbox = {"stdinput.in"};
	   rank = -other.GlueCEStateEstimatedResponseTimeDAG ;
	   requirements = other.GlueCEStateStatus == "ProductionDAG" ;
	   nodes = [
	      nodeA =[
		 description = [
		    JobType = "normal";
		   Executable="/usr/bin/ls";
		   StdInput="stdinput.in";
		   inputsandbox = {"stdinput.in"};
		];
	      ];
		 nodeB = [
		    description = [
		       Executable = "/bin/date";
		       inputsandbox = {root.inputsandbox[0]};
		    ];
		 ];
		 dependencies = { { nodeA, nodeB }}; 
	   ];

	   COMMENTS= {"dag with 1 remote link", "CLIENT nodeB ISB will refer to its father",
		                  "SERVER nodeB ISB will be an URL with the father's wmpURI" };
	];