Title: GrammarDriven Generation of DomainSpecific Language Testing Tools
1Grammar-Driven Generation ofDomain-Specific
Language Testing Tools
Hui Wu
http//www.cis.uab.edu/wuh
February 08 2006
2Motivation of Proposed Research
Editor
Compiler
Domain Experts program at DSL level
Visualizer
Domain Experts deal with GPL
Debugger
Profiler
DSL translated into General Purpose Language
(GPL)
Integrated Development Environment (IDE)
Domain Experts deal with DSL
3A Horizontal Direction Debuggers for Different
Types of DSLs
- Imperative DSL Centered around assignment
expressions or control flow statements - Robot Language
17 Down 18 position(0,-1) 19 Down
F_end 20 M_end 21 Init position(0,0) 22 Call
left 23 Call down 24 Call knight 25 Set
position(5,6) 26 Call up 27 Call right 28
Print position
4A Horizontal Direction Debuggers for Different
Types of DSLs
- Declarative DSL declares the relationship
between inputs and outputs. - Feature Definition Language (FDL)
1 Car all (carbody, Transmission, Engine,
Horsepower, opt(pullsTrailer)) 2 Transmission
oneof (automatic, manual) 3 Engine moreof
(electric, gasoline) 4 Horsepower oneof
(lowPower, mediumPower, highPower) 5 include
pullsTrailer 6 pullsTrailer requires highPower
5A Horizontal Direction
- Hybrid DSL embedded GPL code within the DSL
description
Random String answer int max
JOptionPane myGUI new JOptionPane()
Random rand new Random() answer
myGUI.showInputDialog("Generate a random number
for X-axis between 1 and ") max
Integer.parseInt(answer) x
rand.nextInt(max) answer
myGUI.showInputDialog("Generate a random number
for Y-axis between 1 and ") max
Integer.parseInt(answer) y
rand.nextInt(max) myGUI.showMessageDialog(nul
l, "Generated Position(" x "," y ")")
Random F_end M_end Init position(0,0)
Call left Call down Call knight Set
position(5,6) Call up Call random Call
right Print position
6Mismatch Between Abstraction Levels
Generated Java Parser Code
ANTLR Grammar
. public final void commands() throws
RecognitionException, TokenStreamException try
// for error handling
switch ( LA(1)) case
CALL case INIT case SET
case PRINT command()
commands() break
case END
break default
throw new NoViableAltException(LT(1),
getFilename()) public final void
function_name() throws RecognitionException,
TokenStreamException try // for
error handling switch
( LA(1)) case RIGHT
match(RIGHT)
fileio.print(" //move right")
fileio.print(" move_right()")
fileio.print(" ")
break
case LEFT
match(LEFT)
sllinenumberdsllinenumber1
fileio.print(" //move left")
fileio.print(" move_left()")
fileio.print(" ")
break
. commands ( ccommand cscommands
) command ( RIGHT
fileio.print("//move right")
fileio.print("xx1")
fileio.print("timetime1")
fileio.print(" ") LEFT
fileio.print("//move left")
fileio.print("xx-1")
fileio.print("timetime1")
fileio.print(" ")
7Difficulties with Building DSL Testing Tools
- Debuggers and Profilers are difficult to build
because they depend heavily on the underlying
operating systems capabilities and lower-level
native code functionality - Manual construction of the test tools for each
new DSL can be time-consuming, expensive, and
error-prone
8Three Aspects of the Research
- Programming Language Tool Generation Environment
- Aspect-Oriented Language for Grammar
- DSL Debugger
9Related Work
- Programming Language Tool Generation Environment
- ASFSDF
- Does not generate test engines and profilers
- Jakarta Tool Suite
- Complicated mechanism (e.g., Language extension)
- Dose not provide rich transformation ability
- LISA
- Debugger, test engine, and profiler are not the
target language tools, LISA can be used as the
front-end of our framework. - SmartTools
- Base on Java and XML technologies
- Debugger, test engine, and profiler are not
target language tools
10Research Directions
Imperative DSLs
Declarative DSLs
Hybrid DSLs
construction of the same software tool (e.g.,
debugging) to different categories of DSLs
Debuggers
Unit Test Engines
vertical direction corresponds to the vector
representing the various testing tools that will
be applied to DSLs
Profilers
11Research Goal
- A Matrix of DSL Testing Tools
generalized approach to produce a software
product line of testing tools for DSLs
12Background
- Eclipse Debugger Platform
- Eclipse Unit Test Platform
- Design Maintenance System (DMS)
13Processes of DSL Debugger Generation
Robot DSL corresponding GPL code generated in
Java
DSL grammar is defined using ANTLR Notation
DSL is the input of the Lexer and Parser
generated by ANTLR
Additional Mapping code generated in Java
DSL translation process
Corresponding GPL and Mapping Code are inputs of
Mapping component
Eclipse Debugging perspective communicates with
mapping component
jdb communicates with mapping component
14Debugging A Crosscutting Grammar Concern
Base Grammar
command ( RIGHT fileio.print(" //
move right") fileio.print(" xx1") file
io.print(" timetime1") fileio.print("
") LEFT fileio.print(" //
move left") fileio.print(" xx-1") filei
o.print(" timetime1") fileio.print("
")
What if this line changes?
Change here
Duplicate Debugging Aspect Code
dsllinenumberdsllinenumber1 gplbeginlinefil
eio.getLinenumber() gplendlinefileio.getLinenumb
er() filemap.print(" mapping.add(new
Map("dsllinenumber", \"Robot.java\","gplbeginli
ne","gplendline"))")
dsllinenumberdsllinenumber1 gplbeginlinefil
eio.getLinenumber() gplendlinefileio.getLinenumb
er() filemap.print(" mapping.add(new
Map("dsllinenumber", \"Robot.java\","gplbeginli
ne","gplendline"))")
Change here
Change
15Related Work
- Aspect Oriented Language for Grammars
- AspectAsf
- weave all possible debugging aspects into all
potential program locations - AspectLISA
- aspect-oriented compiler generator based on
attribute grammars - incrementally extend a language design
- advices before and after join point are not
applicable - purpose of AspectLISA is not tool generation
16AspectG Pointcut Model
17Weaving into DSL Grammars Using AspectG
18Related Work
- DSL Debugger
- Khepera
- Support optimization code debugger
- Store transformation information in a database
- JSR-045
- Java Specification Requests for Debugging Support
for Other Languages - Java language domain with similar source code
mapping mechanism - AntlrStudio
- provides end-users debugging support on ANTLR
grammar - Based on JSR-045
- ToolBus Integrated Debugging Environment (TIDE)
- Based on ASFSDF
- 4 tedious steps to implement debugger for a new
language - UFO
- A framework for rapidly constructing dynamic
analyzers - Target Unicon language (SNOBOL-style) high level,
goal-directed, object-oriented, GPL.
19UFO Demo
20Approaches Used in This Proposed Research
Syntax-Directed Translation
Plug-In Based Software Development
ANTLR
Eclipse
Design Patterns
Automated Software Engineering
Software
6 after(int commandname) 7 call(void
antlr.Parser.match(int)) 8
args(commandname) 9
match(commandname) 10 pointcut
count_dsllinenumber() 11 call (void
P.command()) 12 after() count_dsllinenumber()
13 dsllinenumberdsllinenumber1
Model-View-Controller Adapter Pattern
Weaving Aspects into DSL Grammars
AspectG
21DSL Debugger Perspective in Eclipse
22Declarative DSL Debugger
23Hybrid DSL Debugger
24Hybrid DSL Debugger Demo
25DSL Unit Test Framework (DUTF)
- Similar to the DSL Debugging Framework
architecture and approaches - Complement to the DSL Debugging Framework,
identify the existence of program errors - To monitor the performance of DSLs at run time,
similar architecture and approaches can be
applied to DSL Profiler Framework (DPF) to
generate DSL profilers
26DSL Unit Test Perspective in Eclipse
27DSL Unit Test Perspective in Eclipse
28Experimental Validation of This Work
- Various types of DSLs serve as test cases
- Robot Language (imperative DSL)
- FDL (declarative DSL)
- Robot Language with extension (hybrid DSL)
- Qualitative Metrics-How well the generated
testing tools behave - To what degree of success can the DSL unit test
engine detect errors in DSL program units? - To what degree can the DSL debugger help
end-users to locate and fix the detected errors?
29Summary
- End-user developers (e.g., scientist, accountant,
and statistician) are in large number - Software failures caused by program errors pose a
great threat to economy - Testing and Debugging on GPLs have been
investigated for decades, but testing and
debugging DSLs has been neglected. - Several publication reviews, paper citations, and
source code requests indicate the proposed
research is in the right direction.
30Summary
- Preliminary feasibility study
- Debuggers for imperative, declarative, and hybrid
DSLs - Unit Test Engine for imperative DSLs
- Published initial experiences WGR05
- An initial investigation into weaving aspects
into DSL grammars and working on implementation
of AspectG.
31Thank you for coming!Questions?
- Summary of URLs referenced in talk
- DSL Debugger Framework
- http//www.cis.uab.edu/wuh/DDF
- ANTLR
- http//www.antlr.org
- AspectJ
- http//www.aspectj.org
- DMS
- http//www.semdesigns.com
DDF