Working with QSL

From Catglobe Wiki
Jump to: navigation, search

<accesscontrol>Main:MyGroup</accesscontrol>

What is QSL ?

QSL stands for Questionnaire Structure Language . We can use this language to specify structure of a questionnaire template including questionnaire's properties , questions and question's properties . Though QSL has not been supported completely questionnaire template ( there are a few features missing ), it is an advance way to work with questionnaire template . Once getting familiar with QSL , user can create a questionnaire template quicker than using the GUI .

From which version QSL has supported ?

QSL started in version 5.4 (VN1197QNR - Import of Questionnaire template) . In 5.5 , we re-defined the grammar of QSL and keep it up to now . An improvement was made in 5.6 so that the engine can catch syntax error and support test resource for error message .

Before working with QSL

QSL is a domain specific language (DSL) . It is always a painful to deal with DSL by our own but everything is easier thank to ANTLR (AnoTher Tool for Language Recognition). This is a language tool that provides a framework for constructing recognizers, compilers, and translators from grammatical descriptions containing actions in a variety of target languages. It is widely used because it's easy to understand, powerful, flexible, generates human-readable output and free . It is recommended that developers read the book "The Definitive Antlr Reference Building Domain-Specific Languages" to have a background before getting into QSL . You also need to install ANTLR Runtime engine and configure environment .

Processing QSL

Process QSL.png

All the work we need to do is define the syntax for QSL ( edit file Questionnaire.g) and write a class to parse the abstract structure tree into a Questionnaire object . We use ANTLR Work to edit and debug the syntax of QSL ANTLR Work.JPG

After finished Questionnaire.g , we also use ANTLR Work to generate Java source code for the lexer and parser .

GenerateCode.JPG

Put QuestionnaireLexer.java and QuestionnaireParser.java into source code folder and compile as normal source file . The final work we need to handle is parsing the tree structure into Questionnaire object using the API library comes with ANTLR package .

ASTTree.JPG

Reference links

http://antlr.org/
http://www.ociweb.com/jnb/jnbJun2008.html